1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Compare Python implementation with other shells.
|
4 | #
|
5 | # Contrast with test/spec-cpp.sh, which compares the Python and C++ version.
|
6 | #
|
7 | # Usage:
|
8 | # test/spec-py.sh <function name>
|
9 |
|
10 | set -o nounset
|
11 | set -o pipefail
|
12 | set -o errexit
|
13 |
|
14 | REPO_ROOT=$(cd "$(dirname $0)/.."; pwd)
|
15 |
|
16 | source test/spec-common.sh
|
17 | source devtools/run-task.sh
|
18 |
|
19 | run-file() {
|
20 | local spec_name=$1
|
21 | shift
|
22 |
|
23 | sh-spec spec/$spec_name.test.sh \
|
24 | --compare-shells \
|
25 | --oils-bin-dir $PWD/bin "$@"
|
26 | }
|
27 |
|
28 | osh-all() {
|
29 | test/spec.sh check-survey-shells
|
30 |
|
31 | # $suite $compare_mode $spec_subdir
|
32 | test/spec-runner.sh all-parallel osh compare-py osh-py "$@"
|
33 |
|
34 | # By default, it runs sh_spec.py with --compare-shells
|
35 | # Can also add:
|
36 | # --ovm-bin-dir
|
37 | # --oils-cpp-bin-dir
|
38 | # to compare with more
|
39 | }
|
40 |
|
41 | ysh-all() {
|
42 | # $suite $compare_mode $spec_subdir
|
43 | test/spec-runner.sh all-parallel ysh compare-py ysh-py "$@"
|
44 | }
|
45 |
|
46 | ysh-ovm-tarball() {
|
47 | ### Regression test run by CI
|
48 |
|
49 | local version
|
50 | version=$(head -n 1 oil-version.txt)
|
51 |
|
52 | local tar_root=$REPO_ROOT/_tmp/oil-tar-test/oil-$version
|
53 |
|
54 | pushd $tar_root
|
55 | $REPO_ROOT/devtools/bin.sh make-ovm-links
|
56 | popd
|
57 |
|
58 | # Run the file that depends on stdlib/
|
59 |
|
60 | #test/spec.sh ysh-stdlib --ovm-bin-dir $tar_root/_bin
|
61 |
|
62 | set +o errexit
|
63 | ysh-all-serial --ovm-bin-dir $tar_root/_bin
|
64 | local status=$?
|
65 | set +o errexit
|
66 |
|
67 | echo
|
68 | echo status=$status
|
69 | }
|
70 |
|
71 | ysh-stdlib-regress() {
|
72 | test/spec.sh ysh-stdlib --ovm-bin-dir $REPO_ROOT/_bin "$@"
|
73 | }
|
74 |
|
75 | osh-minimal() {
|
76 | ### Some tests that work on the minimal build. Run by Soil.
|
77 |
|
78 | # depends on link-busybox-ash, then source dev-shell.sh at the top of this
|
79 | # file
|
80 | test/spec.sh check-survey-shells
|
81 |
|
82 | # suite compare_mode spec_subdir
|
83 | test/spec-runner.sh all-parallel osh-minimal compare-py osh-minimal "$@"
|
84 | }
|
85 |
|
86 |
|
87 | osh-all-serial() { MAX_PROCS=1 $0 osh-all "$@"; }
|
88 | ysh-all-serial() { MAX_PROCS=1 $0 ysh-all "$@"; }
|
89 | osh-minimal-serial() { MAX_PROCS=1 $0 osh-minimal "$@"; }
|
90 |
|
91 | interactive-osh() {
|
92 | ### Run spec files tagged 'interactive' in soil/interactive, which uses a terminal
|
93 | # This repeats what 'compare-py' does.
|
94 |
|
95 | # Doesn't seem to trigger "Stopped" bug, but it hangs in the CI unless serial
|
96 |
|
97 | # pass '1' to make it serial. default is N-1 CPUS in test/spec-common.sh
|
98 | local max_procs=${1:-1}
|
99 |
|
100 | # Note: without MAX_PROCS=1, I observed at least 2 instances of hanging (for
|
101 | # 30 minutes)
|
102 | #
|
103 | # TODO:
|
104 | # - better diagnostics from those hanging instances
|
105 | # - note: worked OK (failed to hang) one time in soil/host-shim.sh local-test-uke
|
106 | # - I suspect job control, we need to test it more throoughly, by simulating
|
107 | # the kernel in Python unit tests
|
108 |
|
109 | # $suite $compare_mode $spec_subdir
|
110 | MAX_PROCS=$max_procs test/spec-runner.sh all-parallel \
|
111 | interactive osh-only interactive-osh "$@"
|
112 | }
|
113 |
|
114 | debug-2023-06() {
|
115 | # 2023-06-30:
|
116 | # HANGING BUG after removing test/spec_param.py, and using run-file
|
117 | # All of the sudden test/spec-py.sh interactive-osh hangs in Docker, and then
|
118 | # this does too
|
119 | # It reproduces LOCALLY as well
|
120 | # But doesn't reproduce outside the container on my machine
|
121 | #
|
122 | # I get an ORPHANED bash -i command running at 100%, outside the container
|
123 | # Remember that runs with docker -t
|
124 |
|
125 | # NARROWED DOWN: the bug was that bash ALWAYS fails inside the container
|
126 | #
|
127 | # We don't run with bash and a terminal in the CI
|
128 |
|
129 | test/spec.sh run-file-with-osh builtin-history
|
130 | }
|
131 |
|
132 | interactive-bash() {
|
133 | # Triggers the "Stopped" bug with bash alone, unless max_procs=1
|
134 |
|
135 | # pass '1' to make it serial. default is N-1 CPUS in test/spec-common.sh
|
136 | local max_procs=${1:-}
|
137 |
|
138 | # $suite $compare_mode $spec_subdir
|
139 | MAX_PROCS=$max_procs test/spec-runner.sh all-parallel \
|
140 | interactive bash-only interactive-bash "$@"
|
141 | }
|
142 |
|
143 | interactive-osh-bash() {
|
144 | # Triggers the "Stopped" bug with osh and bash!
|
145 |
|
146 | # Note: there's no longer a way to run with 2 shells? We could do
|
147 | # test/sh_spec.py --shells-from-argv foo.test.sh osh bash
|
148 | echo TODO
|
149 | }
|
150 |
|
151 | all-and-smoosh() {
|
152 | ### Published with each release
|
153 |
|
154 | # Args are flags to sh_spec.py
|
155 | # --oils-bin-dir
|
156 | # --ovm-bin-dir
|
157 | local -a more_flags=( "$@" )
|
158 |
|
159 | # Note: MAX_PROCS=1 prevents [#oil-dev > Random Spec Test Stoppages]
|
160 | # Still need to fix that bug
|
161 | MAX_PROCS=1 osh-all "${more_flags[@]}"
|
162 | ysh-all "${more_flags[@]}"
|
163 |
|
164 | # These aren't all green/yellow yet, and are slow.
|
165 | test/spec.sh smoosh-html "${more_flags[@]}"
|
166 | test/spec.sh smoosh-hang-html "${more_flags[@]}"
|
167 | }
|
168 |
|
169 | run-task "$@"
|