OILS / test / spec-export.sh View on Github | oils.pub

51 lines, 30 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# ./spec-export.sh <function name>
5
6set -o nounset
7set -o pipefail
8set -o errexit
9
10source build/dev-shell.sh
11
12download-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?
20BAD-install-yq() {
21 sudo apt-get install yq
22}
23
24yq() {
25 _tmp/yq/yq_linux_amd64 "$@"
26}
27
28yq-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
36export-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
42yahtzee-all() {
43 # doesn't actually take into acount OSH
44 YAHTZEE_DIR=_tmp/yahtzee test/spec-py.sh osh-all
45}
46
47yahtzee-report() {
48 wc -l _tmp/yahtzee/* | sort -n
49}
50
51"$@"