1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Usage:
|
4 | # devtools/tsv-lib-test.sh <function name>
|
5 |
|
6 | set -o nounset
|
7 | set -o pipefail
|
8 | set -o errexit
|
9 |
|
10 | REPO_ROOT=$(cd "$(dirname $0)/.."; pwd)
|
11 | source test/tsv-lib.sh
|
12 | source test/common.sh # fail
|
13 |
|
14 | test-concat-rows() {
|
15 | set +o errexit
|
16 |
|
17 | mkdir -p _tmp
|
18 | cat >_tmp/test1.csv <<EOF
|
19 | name,age
|
20 | alice,0
|
21 | bob,10
|
22 | EOF
|
23 |
|
24 | cat >_tmp/test2.csv <<EOF
|
25 | name,age
|
26 | carol,20
|
27 | EOF
|
28 |
|
29 | tsv-concat _tmp/test{1,2}.csv
|
30 |
|
31 | cat >_tmp/bad.csv <<EOF
|
32 | name,age,another
|
33 | dave,30,oops
|
34 | EOF
|
35 |
|
36 | tsv-concat _tmp/test{1,2}.csv _tmp/bad.csv
|
37 | if test $? -eq 1; then
|
38 | echo 'Expected failure OK'
|
39 | else
|
40 | fail 'Should have failed'
|
41 | fi
|
42 | }
|
43 |
|
44 | test-add-const-column() {
|
45 | here-schema-tsv >_tmp/add.tsv <<EOF
|
46 | name age
|
47 | alice 10
|
48 | bob 20
|
49 | EOF
|
50 | cat _tmp/add.tsv
|
51 |
|
52 | tsv-add-const-column host_name $(hostname) < _tmp/add.tsv
|
53 | }
|
54 |
|
55 | test-tsv2html() {
|
56 | cat >_tmp/test2.tsv <<EOF
|
57 | name
|
58 | carol
|
59 | EOF
|
60 |
|
61 | tsv2html _tmp/test2.tsv
|
62 |
|
63 | # This test passes on my desktop, but 'other-tests' Soil image doesn't have
|
64 | # python3 yet.
|
65 | #tsv2html3 _tmp/test2.tsv
|
66 | }
|
67 |
|
68 | soil-run() {
|
69 | run-test-funcs
|
70 | }
|
71 |
|
72 | "$@"
|