tenseleyflow/bensch / ccd7ddb

Browse files

replace inline FORTSH_RC_FILE with RC_DISABLE_ENV

POSIX scripts that prepended FORTSH_RC_FILE=/dev/null now use
env \$RC_DISABLE_ENV — set by the profile system to the appropriate
rc-disable mechanism for each shell.

Also clean FORTSH_PATH -> RESOLVED_SHELL in run_posix_tests.sh.
Authored by espadonne
SHA
ccd7ddb12ef683e86410cdf911f1c95d3ed59445
Parents
73a6465
Tree
0828e31

4 changed files

StatusFile+-
M suites/posix/posix_compliance_coverage.sh 10 10
M suites/posix/posix_compliance_jobcontrol.sh 4 4
M suites/posix/posix_compliance_untested.sh 6 6
M suites/posix/run_posix_tests.sh 5 5
suites/posix/posix_compliance_coverage.shmodified
@@ -67,10 +67,10 @@ compare_posix_output() {
6767
     test_name="$1"
6868
     test_cmd="$2"
6969
 
70
-    posix_output=$(FORTSH_RC_FILE=/dev/null "$BASH_REF" -c "$test_cmd" 2>&1 | normalize_output)
70
+    posix_output=$(env $RC_DISABLE_ENV "$BASH_REF" -c "$test_cmd" 2>&1 | normalize_output)
7171
     posix_exit=$?
7272
 
73
-    shell_output=$(FORTSH_RC_FILE=/dev/null "$SHELL_BIN" -c "$test_cmd" 2>&1 | normalize_output)
73
+    shell_output=$(env $RC_DISABLE_ENV "$SHELL_BIN" -c "$test_cmd" 2>&1 | normalize_output)
7474
     shell_exit=$?
7575
 
7676
     if [ "$posix_output" = "$shell_output" ] && [ "$posix_exit" = "$shell_exit" ]; then
@@ -91,10 +91,10 @@ compare_posix_error() {
9191
     test_name="$1"
9292
     test_cmd="$2"
9393
 
94
-    posix_output=$(FORTSH_RC_FILE=/dev/null "$BASH_REF" -c "$test_cmd" 2>&1)
94
+    posix_output=$(env $RC_DISABLE_ENV "$BASH_REF" -c "$test_cmd" 2>&1)
9595
     posix_exit=$?
9696
 
97
-    shell_output=$(FORTSH_RC_FILE=/dev/null "$SHELL_BIN" -c "$test_cmd" 2>&1)
97
+    shell_output=$(env $RC_DISABLE_ENV "$SHELL_BIN" -c "$test_cmd" 2>&1)
9898
     shell_exit=$?
9999
 
100100
     posix_norm=$(normalize_error "$posix_output")
@@ -112,7 +112,7 @@ test_accepts() {
112112
     test_name="$1"
113113
     test_cmd="$2"
114114
 
115
-    if FORTSH_RC_FILE=/dev/null "$SHELL_BIN" -c "$test_cmd" >/dev/null 2>&1; then
115
+    if env $RC_DISABLE_ENV "$SHELL_BIN" -c "$test_cmd" >/dev/null 2>&1; then
116116
         pass "$test_name"
117117
     else
118118
         fail "$test_name" "should succeed" "failed or not implemented"
@@ -124,7 +124,7 @@ test_fails() {
124124
     test_name="$1"
125125
     test_cmd="$2"
126126
 
127
-    if ! FORTSH_RC_FILE=/dev/null "$SHELL_BIN" -c "$test_cmd" >/dev/null 2>&1; then
127
+    if ! env $RC_DISABLE_ENV "$SHELL_BIN" -c "$test_cmd" >/dev/null 2>&1; then
128128
         pass "$test_name"
129129
     else
130130
         fail "$test_name" "should fail" "succeeded unexpectedly"
@@ -229,7 +229,7 @@ test_trap_behavior() {
229229
     test_cmd="$2"
230230
     expected_pattern="$3"
231231
 
232
-    output=$(FORTSH_RC_FILE=/dev/null "$SHELL_BIN" -c "$test_cmd" 2>&1)
232
+    output=$(env $RC_DISABLE_ENV "$SHELL_BIN" -c "$test_cmd" 2>&1)
233233
 
234234
     if echo "$output" | grep -qE "$expected_pattern"; then
235235
         pass "$test_name"
@@ -335,8 +335,8 @@ section "271. PIPELINE - LONG CHAINS"
335335
 compare_posix_output "5-stage pipeline" 'echo test | cat | cat | cat | cat | cat'
336336
 # Pipeline timing can produce non-deterministic pipe errors — filter them out
337337
 TEST_NUM=$((TEST_NUM + 1))
338
-_pf_expected=$(FORTSH_RC_FILE=/dev/null "$BASH_REF" -c 'echo ok | false | cat; echo $?' 2>&1 | grep -v 'Broken pipe' | normalize_output)
339
-_pf_actual=$(FORTSH_RC_FILE=/dev/null "$SHELL_BIN" -c 'echo ok | false | cat; echo $?' 2>&1 | grep -v 'Broken pipe' | normalize_output)
338
+_pf_expected=$(env $RC_DISABLE_ENV "$BASH_REF" -c 'echo ok | false | cat; echo $?' 2>&1 | grep -v 'Broken pipe' | normalize_output)
339
+_pf_actual=$(env $RC_DISABLE_ENV "$SHELL_BIN" -c 'echo ok | false | cat; echo $?' 2>&1 | grep -v 'Broken pipe' | normalize_output)
340340
 if [ "$_pf_expected" = "$_pf_actual" ]; then pass "pipeline with failures"
341341
 else fail "pipeline with failures" "$_pf_expected" "$_pf_actual"; fi
342342
 
@@ -359,7 +359,7 @@ test_alias_behavior() {
359359
     test_cmd="$2"
360360
     expected_pattern="$3"
361361
 
362
-    output=$(FORTSH_RC_FILE=/dev/null "$SHELL_BIN" -c "$test_cmd" 2>&1)
362
+    output=$(env $RC_DISABLE_ENV "$SHELL_BIN" -c "$test_cmd" 2>&1)
363363
 
364364
     if echo "$output" | grep -qiE "$expected_pattern"; then
365365
         pass "$test_name"
suites/posix/posix_compliance_jobcontrol.shmodified
@@ -73,7 +73,7 @@ test_succeeds() {
7373
     test_name="$1"
7474
     test_cmd="$2"
7575
 
76
-    if FORTSH_RC_FILE=/dev/null "$SHELL_BIN" -c "$test_cmd" >/dev/null 2>&1; then
76
+    if env $RC_DISABLE_ENV "$SHELL_BIN" -c "$test_cmd" >/dev/null 2>&1; then
7777
         pass "$test_name"
7878
     else
7979
         fail "$test_name" "should succeed" "failed"
@@ -86,7 +86,7 @@ test_output() {
8686
     test_cmd="$2"
8787
     expected="$3"
8888
 
89
-    output=$(FORTSH_RC_FILE=/dev/null "$SHELL_BIN" -c "$test_cmd" 2>&1)
89
+    output=$(env $RC_DISABLE_ENV "$SHELL_BIN" -c "$test_cmd" 2>&1)
9090
     if [ "$output" = "$expected" ]; then
9191
         pass "$test_name"
9292
     else
@@ -100,7 +100,7 @@ test_contains() {
100100
     test_cmd="$2"
101101
     pattern="$3"
102102
 
103
-    output=$(FORTSH_RC_FILE=/dev/null "$SHELL_BIN" -c "$test_cmd" 2>&1)
103
+    output=$(env $RC_DISABLE_ENV "$SHELL_BIN" -c "$test_cmd" 2>&1)
104104
     if echo "$output" | grep -q "$pattern"; then
105105
         pass "$test_name"
106106
     else
@@ -202,7 +202,7 @@ test_output_unordered() {
202202
     test_cmd="$2"
203203
     shift 2
204204
 
205
-    output=$(FORTSH_RC_FILE=/dev/null "$SHELL_BIN" -c "$test_cmd" 2>&1)
205
+    output=$(env $RC_DISABLE_ENV "$SHELL_BIN" -c "$test_cmd" 2>&1)
206206
     for word in "$@"; do
207207
         if ! echo "$output" | grep -qF "$word"; then
208208
             fail "$test_name" "output containing '$word'" "$output"
suites/posix/posix_compliance_untested.shmodified
@@ -75,11 +75,11 @@ compare_posix_output() {
7575
     test_cmd="$2"
7676
 
7777
     # Run with POSIX sh
78
-    posix_output=$(FORTSH_RC_FILE=/dev/null "$BASH_REF" -c "$test_cmd" 2>&1)
78
+    posix_output=$(env $RC_DISABLE_ENV "$BASH_REF" -c "$test_cmd" 2>&1)
7979
     posix_exit=$?
8080
 
8181
     # Run with fortsh
82
-    shell_output=$(FORTSH_RC_FILE=/dev/null "$SHELL_BIN" -c "$test_cmd" 2>&1)
82
+    shell_output=$(env $RC_DISABLE_ENV "$SHELL_BIN" -c "$test_cmd" 2>&1)
8383
     shell_exit=$?
8484
 
8585
     # Compare outputs
@@ -101,10 +101,10 @@ compare_posix_error() {
101101
     test_name="$1"
102102
     test_cmd="$2"
103103
 
104
-    posix_output=$(FORTSH_RC_FILE=/dev/null "$BASH_REF" -c "$test_cmd" 2>&1)
104
+    posix_output=$(env $RC_DISABLE_ENV "$BASH_REF" -c "$test_cmd" 2>&1)
105105
     posix_exit=$?
106106
 
107
-    shell_output=$(FORTSH_RC_FILE=/dev/null "$SHELL_BIN" -c "$test_cmd" 2>&1)
107
+    shell_output=$(env $RC_DISABLE_ENV "$SHELL_BIN" -c "$test_cmd" 2>&1)
108108
     shell_exit=$?
109109
 
110110
     posix_norm=$(normalize_error "$posix_output")
@@ -122,7 +122,7 @@ test_accepts() {
122122
     test_name="$1"
123123
     test_cmd="$2"
124124
 
125
-    if FORTSH_RC_FILE=/dev/null "$SHELL_BIN" -c "$test_cmd" >/dev/null 2>&1; then
125
+    if env $RC_DISABLE_ENV "$SHELL_BIN" -c "$test_cmd" >/dev/null 2>&1; then
126126
         pass "$test_name"
127127
     else
128128
         fail "$test_name" "should succeed" "failed or not implemented"
@@ -134,7 +134,7 @@ test_fails() {
134134
     test_name="$1"
135135
     test_cmd="$2"
136136
 
137
-    if ! FORTSH_RC_FILE=/dev/null "$SHELL_BIN" -c "$test_cmd" >/dev/null 2>&1; then
137
+    if ! env $RC_DISABLE_ENV "$SHELL_BIN" -c "$test_cmd" >/dev/null 2>&1; then
138138
         pass "$test_name"
139139
     else
140140
         fail "$test_name" "should fail" "succeeded unexpectedly"
suites/posix/run_posix_tests.shmodified
@@ -21,16 +21,16 @@ SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
2121
 # Find fortsh binary - check multiple locations
2222
 if [ -n "$SHELL_BIN" ] && [ -x "$SHELL_BIN" ]; then
2323
     # Use environment variable if set
24
-    FORTSH_PATH="$SHELL_BIN"
24
+    RESOLVED_SHELL="$SHELL_BIN"
2525
 elif [ -x "$SCRIPT_DIR/../bin/fortsh" ]; then
2626
     # Look in ../bin/fortsh (relative to tests/)
27
-    FORTSH_PATH="$SCRIPT_DIR/../bin/fortsh"
27
+    RESOLVED_SHELL="$SCRIPT_DIR/../bin/fortsh"
2828
 elif [ -x "./bin/fortsh" ]; then
2929
     # Look in ./bin/fortsh (from project root)
30
-    FORTSH_PATH="./bin/fortsh"
30
+    RESOLVED_SHELL="./bin/fortsh"
3131
 elif [ -x "$(pwd)/bin/fortsh" ]; then
3232
     # Look in current working directory
33
-    FORTSH_PATH="$(pwd)/bin/fortsh"
33
+    RESOLVED_SHELL="$(pwd)/bin/fortsh"
3434
 else
3535
     printf "${RED}ERROR: shell binary not found!${NC}\n"
3636
     printf "Searched locations:\n"
@@ -42,7 +42,7 @@ else
4242
     exit 1
4343
 fi
4444
 
45
-export SHELL_BIN="$FORTSH_PATH"
45
+export SHELL_BIN="$RESOLVED_SHELL"
4646
 
4747
 # Test suite files
4848
 TEST_SUITES="