Skip to content

Commit

Permalink
[refactor] Use test-func style in more tests
Browse files Browse the repository at this point in the history
csv2html, oil_lang, and tea
  • Loading branch information
Andy C committed Feb 16, 2022
1 parent 274f8a6 commit f304908
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 33 deletions.
17 changes: 6 additions & 11 deletions oil_lang/run.sh
Expand Up @@ -19,14 +19,12 @@ parse-one() {
if test $? -ne 0; then return 255; fi # make xargs quit
}

parse-all-osh() {
test-parse-osh() {
find oil_lang/testdata -name '*.sh' -o -name '*.osh' \
| xargs -n 1 -- $0 parse-one
}

all-passing() {
### Run all the examples

test-run-osh() {
for prog in oil_lang/testdata/*.{sh,osh}; do
echo $prog

Expand All @@ -45,7 +43,9 @@ all-passing() {
echo ---
bin/osh $prog
done
}

test-run-oil() {
for prog in oil_lang/testdata/*.oil; do
echo ---
bin/oil $prog all
Expand Down Expand Up @@ -73,19 +73,14 @@ demo() {
bin/osh oil_lang/testdata/assign.osh
}

all() {
parse-all-osh
all-passing
}

soil-run() {
### Used by soil/worker.sh. Prints to stdout.
all
run-test-funcs
}

run-for-release() {
### Used by devtools/release.sh. Writes a file.
run-other-suite-for-release oil-large all
run-other-suite-for-release oil-large run-test-funcs
}

"$@"
13 changes: 4 additions & 9 deletions tea/run.sh
Expand Up @@ -27,12 +27,12 @@ parse-one() {
if test $? -ne 0; then return 255; fi # make xargs quit
}

parse-all-tea() {
test-parse-all-tea() {
# Parse with the Oil binary
tea-files | xargs --verbose -n 1 -- $0 parse-one
}

usage-test() {
test-usage() {
local prog='data Point(x Int, y Int)'

bin/oil -O parse_tea -n -c "echo 'hi'; $prog"
Expand All @@ -43,19 +43,14 @@ usage-test() {
echo "$prog" | bin/tea -n
}

all() {
parse-all-tea
usage-test
}

soil-run() {
### Used by soil/worker.sh. Prints to stdout.
all
run-test-funcs
}

run-for-release() {
### Used by devtools/release.sh. Writes a file.
run-other-suite-for-release tea-large all
run-other-suite-for-release tea-large run-test-funcs
}

"$@"
2 changes: 1 addition & 1 deletion test/other.sh
Expand Up @@ -22,7 +22,7 @@ xargs-test() {

csv2html-test() {
pushd web/table
./csv2html-test.sh
./csv2html-test.sh all
popd
}

Expand Down
18 changes: 6 additions & 12 deletions web/table/csv2html-test.sh
Expand Up @@ -9,6 +9,7 @@ set -o errexit

readonly REPO_ROOT=$(readlink -f $(dirname $0))/../..

source $REPO_ROOT/test/common.sh
source $REPO_ROOT/web/table/html.sh


Expand Down Expand Up @@ -147,18 +148,11 @@ EOF

}

if test $# -eq 0; then
all() {
link-static
echo
run-test-funcs
}

test-no-schema
echo '--'
test-schema
echo '--'
test-precision
echo '--'
test-row-css-class
else
"$@"
fi

"$@"

0 comments on commit f304908

Please sign in to comment.