Project

General

Profile

1
#!/bin/bash
2
# Tests map on all input/*.csv
3
# Usage: env [n=<num-rows>] self
4

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

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

    
11
# Update generated mappings
12
../../mappings/extract_plot_map
13
../../mappings/join_all_vegbank
14

    
15
for in in input/*.csv; do
16
    stem="$(basename -- "${in%.csv}")" # remove extension and dir
17
    src="${stem%.*}" # before last "."
18
    type="${stem##*.}" # after last "."
19
    
20
    # 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")
25
    done
26
    
27
    # Test exporting to VegBank db
28
    (set -x; head -"$n" "$in"|../map2vegbank \
29
    "../../mappings/$src-VegBank.$type.csv")
30
done
(2-2/2)