| 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}
|
| 9 | source $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 |
|
| 15 | YSH='bin/ysh +o no_exported'
|
| 16 |
|
| 17 | test-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 |
|
| 41 | test-quote() {
|
| 42 | local name=quote
|
| 43 | devtools/byo.sh test --test-filter 'make' $YSH stdlib/ysh/$name-test.ysh
|
| 44 | }
|
| 45 |
|
| 46 | ysh-test() {
|
| 47 | local name=$1
|
| 48 | shift
|
| 49 | devtools/byo.sh test $YSH stdlib/ysh/$name-test.ysh "$@"
|
| 50 | }
|
| 51 |
|
| 52 | soil-run() {
|
| 53 | test-byo-protocol
|
| 54 |
|
| 55 | for name in def args list math quote yblocks; do
|
| 56 | ysh-test $name
|
| 57 | done
|
| 58 |
|
| 59 | devtools/byo.sh test $YSH stdlib/ysh/stream.ysh
|
| 60 | devtools/byo.sh test $YSH stdlib/ysh/table.ysh
|
| 61 |
|
| 62 | # special demo
|
| 63 | devtools/byo.sh test $YSH demo/rich-history.ysh
|
| 64 |
|
| 65 | # Run shebang, bash
|
| 66 | devtools/byo.sh test stdlib/osh/two-test.sh
|
| 67 | devtools/byo.sh test stdlib/osh/no-quotes-test.sh
|
| 68 | devtools/byo.sh test stdlib/osh/byo-server-test.sh
|
| 69 |
|
| 70 | # Run with osh
|
| 71 | devtools/byo.sh test bin/osh stdlib/osh/two-test.sh
|
| 72 |
|
| 73 | }
|
| 74 |
|
| 75 | "$@"
|