| 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 | YSH=bin/ysh
 | 
| 12 | 
 | 
| 13 | test-byo-protocol() {
 | 
| 14 |   return
 | 
| 15 | 
 | 
| 16 |   # Usually the "BYO" command does this
 | 
| 17 |   BYO_COMMAND=detect $YSH stdlib/table.ysh
 | 
| 18 | 
 | 
| 19 |   # TODO: need assertions here
 | 
| 20 |   # assert status
 | 
| 21 | 
 | 
| 22 |   # assert-ok 'echo hi'
 | 
| 23 |   # assert-stdout 'echo hi'
 | 
| 24 |   # assert-fail 2 '(exit 2)'
 | 
| 25 | 
 | 
| 26 |   # I think we usually don't need this
 | 
| 27 |   # assert-fail-stdout 2 '(exit 2)'
 | 
| 28 | 
 | 
| 29 |   BYO_COMMAND=z $YSH stdlib/table.ysh
 | 
| 30 | 
 | 
| 31 |   # missing
 | 
| 32 |   BYO_COMMAND=run-test $YSH stdlib/table.ysh
 | 
| 33 | 
 | 
| 34 |   # TODO: test file with no tests
 | 
| 35 | }
 | 
| 36 | 
 | 
| 37 | soil-run() {
 | 
| 38 |   test-byo-protocol
 | 
| 39 | 
 | 
| 40 |   # Run this directly; don't create circular deps on BYO, etc.
 | 
| 41 |   stdlib/osh/no-quotes.sh test-nq-capture
 | 
| 42 | 
 | 
| 43 |   test/byo-client.sh run-tests $YSH stdlib/stream.ysh 
 | 
| 44 | 
 | 
| 45 |   test/byo-client.sh run-tests $YSH stdlib/table.ysh 
 | 
| 46 | 
 | 
| 47 |   # Run shebang, bash
 | 
| 48 |   test/byo-client.sh run-tests stdlib/osh/two-test.sh 
 | 
| 49 | 
 | 
| 50 |   # Run with osh
 | 
| 51 |   test/byo-client.sh run-tests bin/osh stdlib/osh/two-test.sh 
 | 
| 52 | }
 | 
| 53 | 
 | 
| 54 | "$@"
 |