| 1 | #!/usr/bin/env bash
|
| 2 | #
|
| 3 | # Usage:
|
| 4 | # ./spec-export.sh <function name>
|
| 5 |
|
| 6 | set -o nounset
|
| 7 | set -o pipefail
|
| 8 | set -o errexit
|
| 9 |
|
| 10 | source build/dev-shell.sh
|
| 11 |
|
| 12 | download-yq() {
|
| 13 | local dir=_tmp/yq
|
| 14 | mkdir -p $dir
|
| 15 | wget --no-clobber --directory-prefix "$dir" \
|
| 16 | https://github.com/mikefarah/yq/releases/download/v4.45.4/yq_linux_amd64.tar.gz
|
| 17 | }
|
| 18 |
|
| 19 | # this is a Python yq, that doesn't use multi-line strings for readability?
|
| 20 | BAD-install-yq() {
|
| 21 | sudo apt-get install yq
|
| 22 | }
|
| 23 |
|
| 24 | yq() {
|
| 25 | _tmp/yq/yq_linux_amd64 "$@"
|
| 26 | }
|
| 27 |
|
| 28 | yq-demo() {
|
| 29 | #jq -n --slurpfile one <(seq 1 4) --slurpfile five <(seq 5 6) '{one: $one, five: $five}'
|
| 30 |
|
| 31 | # -P pretty prints
|
| 32 | jq -R -s '{this_script: ., assertions: [1, 2, {shell: "mksh"}]}' < $0 | yq eval -P
|
| 33 | }
|
| 34 |
|
| 35 | # TODO: massage this format more
|
| 36 | export-demo() {
|
| 37 | for name in spec/as*.test.sh; do
|
| 38 | test/sh_spec.py --test-case-json $name | yq eval -P
|
| 39 | done
|
| 40 | }
|
| 41 |
|
| 42 | yahtzee-all() {
|
| 43 | # doesn't actually take into acount OSH
|
| 44 | YAHTZEE_DIR=_tmp/yahtzee test/spec-py.sh osh-all
|
| 45 | }
|
| 46 |
|
| 47 | yahtzee-report() {
|
| 48 | wc -l _tmp/yahtzee/* | sort -n
|
| 49 | }
|
| 50 |
|
| 51 | "$@"
|