fortrangoingonforty/fortsh / aa0bbe2

Browse files

resolve FORTSH_BIN to absolute path so test scripts survive cd to temp dirs

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
aa0bbe2dc53f0f4e14443edb0356c9c2f7fde7df
Parents
ad3a3fe
Tree
bc03026

2 changed files

StatusFile+-
M Makefile 6 5
M tests/run_all_tests.sh 4 4
Makefilemodified
@@ -389,21 +389,22 @@ release: clean $(TARGET)
389389
 	@echo "Release build complete! Binary size: $$(du -h $(TARGET) | cut -f1)"
390390
 
391391
 # Test suite targets
392
+FORTSH_ABS = $(CURDIR)/$(TARGET)
392393
 
393394
 # POSIX compliance: single canonical test script (fastest)
394395
 test-posix: $(TARGET)
395396
 	@echo "Running POSIX compliance tests..."
396
-	FORTSH_BIN=$(TARGET) ./tests/posix_compliance_test.sh
397
+	FORTSH_BIN=$(FORTSH_ABS) ./tests/posix_compliance_test.sh
397398
 
398399
 # Full POSIX suite: all shell-based POSIX test scripts via the comprehensive runner
399400
 test-posix-full: $(TARGET)
400401
 	@echo "Running full POSIX compliance test suite..."
401
-	FORTSH_BIN=$(TARGET) ./tests/run_all_tests.sh --posix-only
402
+	FORTSH_BIN=$(FORTSH_ABS) ./tests/run_all_tests.sh --posix-only
402403
 
403404
 # Quick POSIX suite: skip slow coverage/untested suites
404405
 test-posix-quick: $(TARGET)
405406
 	@echo "Running quick POSIX compliance tests..."
406
-	FORTSH_BIN=$(TARGET) ./tests/run_all_tests.sh --posix-only --quick
407
+	FORTSH_BIN=$(FORTSH_ABS) ./tests/run_all_tests.sh --posix-only --quick
407408
 
408409
 # Interactive PTY tests (requires Python venv with pexpect)
409410
 test-interactive: $(TARGET)
@@ -425,12 +426,12 @@ test-interactive: $(TARGET)
425426
 # Full test run: POSIX + interactive (no memory rebuild)
426427
 test-full: $(TARGET)
427428
 	@echo "Running full test suite (POSIX + interactive)..."
428
-	FORTSH_BIN=$(TARGET) ./tests/run_all_tests.sh --full
429
+	FORTSH_BIN=$(FORTSH_ABS) ./tests/run_all_tests.sh --full
429430
 
430431
 # Everything including memory pool tests (SLOW: rebuilds fortsh)
431432
 test-all: $(TARGET)
432433
 	@echo "Running all test suites..."
433
-	FORTSH_BIN=$(TARGET) ./tests/run_all_tests.sh --all
434
+	FORTSH_BIN=$(FORTSH_ABS) ./tests/run_all_tests.sh --all
434435
 
435436
 # Help target
436437
 help:
tests/run_all_tests.shmodified
@@ -113,13 +113,13 @@ done
113113
 # Get script directory
114114
 SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
115115
 
116
-# Find fortsh binary
116
+# Find fortsh binary and resolve to absolute path (child scripts may cd)
117117
 if [ -n "$FORTSH_BIN" ] && [ -x "$FORTSH_BIN" ]; then
118
-    FORTSH_PATH="$FORTSH_BIN"
118
+    FORTSH_PATH="$(cd "$(dirname "$FORTSH_BIN")" && pwd)/$(basename "$FORTSH_BIN")"
119119
 elif [ -x "$SCRIPT_DIR/../bin/fortsh" ]; then
120
-    FORTSH_PATH="$SCRIPT_DIR/../bin/fortsh"
120
+    FORTSH_PATH="$(cd "$SCRIPT_DIR/../bin" && pwd)/fortsh"
121121
 elif [ -x "./bin/fortsh" ]; then
122
-    FORTSH_PATH="./bin/fortsh"
122
+    FORTSH_PATH="$(cd ./bin && pwd)/fortsh"
123123
 else
124124
     printf "${RED}ERROR: fortsh binary not found!${NC}\n"
125125
     printf "Please build fortsh first with 'make' or set FORTSH_BIN\n"