OILS / stdlib / TEST.sh View on Github | oils.pub

69 lines, 26 significant
1#!/usr/bin/env bash
2#
3# Run tests in this directory.
4#
5# Usage:
6# stdlib/TEST.sh <function name>
7
8: ${LIB_OSH=stdlib/osh}
9source $LIB_OSH/bash-strict.sh
10
11# TODO: byo-server.sh uses $BYO_COMMAND and $BYO_ARG
12# I guess we need a YSH version then? We could hack it with
13# $(sh -c 'echo $BYO_COMMAND')
14
15YSH='bin/ysh +o no_exported'
16
17test-byo-protocol() {
18 return
19
20 # Usually the "BYO" command does this
21 BYO_COMMAND=detect $YSH stdlib/table.ysh
22
23 # TODO: need assertions here
24 # assert status
25
26 # assert-ok 'echo hi'
27 # assert-stdout 'echo hi'
28 # assert-fail 2 '(exit 2)'
29
30 # I think we usually don't need this
31 # assert-fail-stdout 2 '(exit 2)'
32
33 BYO_COMMAND=z $YSH stdlib/table.ysh
34
35 # missing
36 BYO_COMMAND=run-test $YSH stdlib/table.ysh
37
38 # TODO: test file with no tests
39}
40
41ysh-test() {
42 local name=$1
43 devtools/byo.sh test $YSH stdlib/ysh/$name-test.ysh
44}
45
46soil-run() {
47 test-byo-protocol
48
49 for name in def args list math quote yblocks; do
50 ysh-test $name
51 done
52
53 devtools/byo.sh test $YSH stdlib/ysh/stream.ysh
54 devtools/byo.sh test $YSH stdlib/ysh/table.ysh
55
56 # special demo
57 devtools/byo.sh test $YSH demo/rich-history.ysh
58
59 # Run shebang, bash
60 devtools/byo.sh test stdlib/osh/two-test.sh
61 devtools/byo.sh test stdlib/osh/no-quotes-test.sh
62 devtools/byo.sh test stdlib/osh/byo-server-test.sh
63
64 # Run with osh
65 devtools/byo.sh test bin/osh stdlib/osh/two-test.sh
66
67}
68
69"$@"