Project

General

Profile

« Previous | Next » 

Revision 118

test/map: Added support for database input

View differences:

map
5 5
selfDir="$(dirname -- "$0")"
6 6
cd "$selfDir"
7 7

  
8
shopt -s nullglob
9

  
8 10
test -n "$n" || n=2
9 11
let n++ # include header row
10 12

  
......
12 14
../../mappings/extract_plot_map
13 15
../../mappings/join_all_vegbank
14 16

  
15
for in in input/*.csv; do
16
    stem="$(basename -- "${in%.csv}")" # remove extension and dir
17
function importCsv()
18
{
19
    (set -x; head -"$n" "$in")
20
}
21

  
22
function exportXml()
23
{
24
    out="$stem.$in_type.$out_fmt.xml"
25
    (set -x; ../map "../../mappings/$src-$out_fmt.$table.csv" >"output/$out"\
26
    && diff "accepted_output/$out" "output/$out")
27
}
28

  
29
function exportDb()
30
{
31
    (set -x; ../map2vegbank "../../mappings/$src-VegBank.$table.csv")
32
}
33

  
34
for in in input/*.{csv,sh}; do
35
    ext="${in##*.}" # after last "."
36
    stem="$(basename -- "${in%.*}")" # remove extension and dir
17 37
    src="${stem%.*}" # before last "."
18
    type="${stem##*.}" # after last "."
38
    table="${stem##*.}" # after last "."
39
    if test "_$ext" == "_csv"; then in_type=CSV
40
    elif test "_$ext" == "_sh"; then in_type=DB
41
    fi
19 42
    
20 43
    # Test exporting to XML
21
    for fmt in VegX VegBank; do
22
        out="$stem.$fmt.xml"
23
        (set -x; head -"$n" "$in"|../map "../../mappings/$src-$fmt.$type.csv" \
24
        >"output/$out" && diff "accepted_output/$out" "output/$out")
44
    for out_fmt in VegX VegBank; do
45
        if test "_$ext" == "_csv"; then importCsv|exportXml
46
        elif test "_$ext" == "_sh"; then (. "$in"; exportXml)
47
        fi
25 48
    done
26 49
    
27 50
    # Test exporting to VegBank db
28
    (set -x; head -"$n" "$in"|../map2vegbank \
29
    "../../mappings/$src-VegBank.$type.csv")
51
    if test "_$ext" == "_csv"; then importCsv|exportDb
52
    elif test "_$ext" == "_sh"; then (. "$in"; exportDb)
53
    fi
30 54
done

Also available in: Unified diff