OILS / test / spec-alpine.sh View on Github | oilshell.org

154 lines, 87 significant
1#!/usr/bin/env bash
2#
3# Analogous to test/spec.sh, but for the environment set up by test/alpine2.sh.
4#
5# Usage:
6# test/spec-alpine.sh <function name>
7
8set -o nounset
9set -o pipefail
10set -o errexit
11shopt -s strict:all 2>/dev/null || true # dogfood for OSH
12
13source test/common.sh
14source test/spec-common.sh
15
16readonly SH=osh # just use the one in the $PATH
17
18builtin-bracket() {
19 # some tests depend on 'bin' existing
20 # Also running as root so you can read anything! Doh! Need a real user.
21 sh-spec spec/builtin-bracket.test.sh --oils-failures-allowed 3 \
22 $SH "$@"
23}
24
25# This is bash/OSH only
26builtin-completion() {
27 # 8 failures instead of 1
28 sh-spec spec/builtin-completion.test.sh --oils-failures-allowed 8 \
29 $SH "$@"
30}
31
32builtin-eval-source() {
33 sh-spec spec/builtin-eval-source.test.sh $SH "$@"
34}
35
36builtin-trap() {
37 sh-spec spec/builtin-trap.test.sh --oils-failures-allowed 3 \
38 $SH "$@"
39}
40
41builtins() {
42 # 6 failures instead of 1
43 sh-spec spec/builtins.test.sh --oils-failures-allowed 6 \
44 $SH "$@"
45}
46
47errexit-oil() {
48 sh-spec spec/errexit-oil.test.sh $SH "$@"
49}
50
51glob() {
52 # 11 failures rather than 7 under Ubuntu. Probably due to musl libc globbing
53 # differences.
54 sh-spec spec/glob.test.sh --oils-failures-allowed 11 \
55 $SH "$@"
56}
57
58introspect() {
59 sh-spec spec/introspect.test.sh $SH "$@"
60}
61
62loop() {
63 # 1 failure instead of 0
64 sh-spec spec/loop.test.sh --oils-failures-allowed 1 \
65 $SH "$@"
66}
67
68smoke() {
69 # 1 failure instead of 0
70 sh-spec spec/smoke.test.sh --oils-failures-allowed 1 $SH "$@"
71}
72
73strict-options() {
74 sh-spec spec/strict-options.test.sh $SH "$@"
75}
76
77var-op-len() {
78 sh-spec spec/var-op-len.test.sh $SH "$@"
79}
80
81run-file() {
82 ### Run a test with the given name.
83
84 local test_name=$1
85 shift
86
87 if declare -F "$test_name"; then
88 # Delegate to a function in this file.
89 "$test_name" "$@"
90 else
91 # Run it with OSH
92 sh-spec spec/$test_name.test.sh $SH "$@"
93 fi
94}
95
96all() {
97 # TODO: Test this function and run in CI
98
99 export OSH_LIST=osh YSH_LIST=ysh
100
101 # this is like test/spec.sh {oil,osh}-all
102 # $suite $compare_mode $spec_subdir
103 test/spec-runner.sh all-parallel oil release-alpine oil-language
104 test/spec-runner.sh all-parallel osh release-alpine survey
105}
106
107home-page() {
108 cat <<EOF
109<h1>Spec Test Results</h2>
110
111<a href="_tmp/spec/osh.html">osh.html</a> <br/>
112<a href="_tmp/spec/oil.html">oil.html</a> <br/>
113
114EOF
115}
116
117# oilshell.org/spec-results/$date-$hostname-$distro.wwz/
118# _tmp/spec/ # from _tmp/spec
119# osh.html
120# oil.html
121# web/ # from web
122
123manifest() {
124 find index.html _tmp/spec/ web/ -type f
125}
126
127archive-results() {
128 local archive_type=${1:-zip} # zip or tar
129
130 home-page > index.html
131 local out_name="$(date +%Y-%m-%d__%H-%M-%S)__$(hostname)"
132
133 case $archive_type in
134 # zip isn't in POSIX so some systems might not have it.
135 tar)
136 local out=$out_name.tar.gz
137 manifest | xargs -- tar -c -z > $out
138 ;;
139
140 zip)
141 # .wwz is just a zip file that is served
142 local out=$out_name.wwz
143 manifest | xargs -- zip $out
144 ;;
145
146 *)
147 die "Invalid type $archive_type"
148 ;;
149 esac
150
151 ls -l $out
152}
153
154"$@"