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

67 lines, 24 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
41soil-run() {
42 test-byo-protocol
43
44 devtools/byo.sh test $YSH stdlib/ysh/def-test.ysh
45 #return
46 devtools/byo.sh test $YSH stdlib/ysh/args-test.ysh
47 devtools/byo.sh test $YSH stdlib/ysh/list-test.ysh
48 devtools/byo.sh test $YSH stdlib/ysh/math-test.ysh
49
50 devtools/byo.sh test $YSH stdlib/ysh/yblocks-test.ysh
51 devtools/byo.sh test $YSH stdlib/ysh/stream.ysh
52 devtools/byo.sh test $YSH stdlib/ysh/table.ysh
53
54 # special demo
55 devtools/byo.sh test $YSH demo/rich-history.ysh
56
57 # Run shebang, bash
58 devtools/byo.sh test stdlib/osh/two-test.sh
59 devtools/byo.sh test stdlib/osh/no-quotes-test.sh
60 devtools/byo.sh test stdlib/osh/byo-server-test.sh
61
62 # Run with osh
63 devtools/byo.sh test bin/osh stdlib/osh/two-test.sh
64
65}
66
67"$@"