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