From 2e4e07897562153c0973bbca9e5c1089c8307304 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Mon, 31 Dec 2018 14:49:01 +0100 Subject: [PATCH] Fix some environment-dependent tests. * gash/environment.scm (initial-variables): Add 'SHELL' and 'SHELLOPTS'. * tests/100-cd.sh, tests/100-cd.stdout: Use '/tmp' instead of '/bin'. * tests/50-redirect-in-out.sh, tests/50-redirect-space.sh, tests/50-redirect.sh: Use '/tmp' and PID for temporary files. * tests/50-redirect-sed.sh: Make sure 'DESTDIR' is unset and use '/bin/GASH' in place of '/bin/gash'. * tests/50-redirect-sed.stdout, tests/data/diff.scm: Use '/bin/GASH' in place of '/bin/gash'. * Makefile.am (FULL_TESTS): Add tests/50-redirect-sed.sh, tests/50-redirect-space.sh, and tests/100-cd.sh; remove tests/50-redirect-merge.sh. (BROKEN_TESTS): Remove tests/10-if-redirect.sh, tests/50-redirect-sed.sh, tests/50-redirect-space.sh, and tests/100-cd.sh; add tests/50-redirect-merge.sh. Co-authored-by: Timothy Sample --- Makefile.am | 9 ++++----- gash/environment.scm | 4 +++- tests/100-cd.sh | 2 +- tests/100-cd.stdout | 2 +- tests/50-redirect-in-out.sh | 6 +++--- tests/50-redirect-sed.sh | 3 ++- tests/50-redirect-sed.stdout | 2 +- tests/50-redirect-space.sh | 6 +++--- tests/50-redirect.sh | 6 +++--- tests/data/diff.scm | 2 +- 10 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Makefile.am b/Makefile.am index b419d0c..7fa633a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -210,7 +210,8 @@ FULL_TESTS = \ tests/50-redirect-in.sh \ tests/50-redirect-append.sh \ tests/50-redirect-pipe.sh \ - tests/50-redirect-merge.sh \ + tests/50-redirect-sed.sh \ + tests/50-redirect-space.sh \ tests/50-redirect-in-out.sh \ tests/60-function.sh \ tests/60-function-at.sh \ @@ -223,6 +224,7 @@ FULL_TESTS = \ tests/70-slash.sh \ tests/70-slash-string.sh \ tests/70-slash-string-slash.sh \ + tests/100-cd.sh \ tests/100-cd-foo.sh \ tests/100-test.sh \ tests/100-test-file.sh \ @@ -247,10 +249,7 @@ XFAIL_TESTS = \ # that pass or fail based on environmental # factors. BROKEN_TESTS = \ - tests/10-if-redirect.sh \ - tests/50-redirect-sed.sh \ - tests/50-redirect-space.sh \ - tests/100-cd.sh + tests/50-redirect-merge.sh EXTRA_DIST = \ scripts/gash.in diff --git a/gash/environment.scm b/gash/environment.scm index 7239def..2e31f8b 100644 --- a/gash/environment.scm +++ b/gash/environment.scm @@ -108,7 +108,9 @@ (alist->hash-table (map (match-lambda ((name . value) `(,name . ,(vector value #t #f)))) - (append `(("PWD" . ,(initial-pwd env))) + (append `(("PWD" . ,(initial-pwd env)) + ("SHELL" . ,(car (command-line))) + ("SHELLOPTS" . "")) env))))) (define *variables* (initial-variables)) diff --git a/tests/100-cd.sh b/tests/100-cd.sh index 16911ea..1817731 100644 --- a/tests/100-cd.sh +++ b/tests/100-cd.sh @@ -1,2 +1,2 @@ -cd /bin +cd /tmp pwd diff --git a/tests/100-cd.stdout b/tests/100-cd.stdout index 5e56e04..ceeb05b 100644 --- a/tests/100-cd.stdout +++ b/tests/100-cd.stdout @@ -1 +1 @@ -/bin +/tmp diff --git a/tests/50-redirect-in-out.sh b/tests/50-redirect-in-out.sh index 7d81744..6aa8934 100644 --- a/tests/50-redirect-in-out.sh +++ b/tests/50-redirect-in-out.sh @@ -1,3 +1,3 @@ -cat < tests/data/foo > bar -cat bar -rm bar +cat < tests/data/foo > /tmp/bar$$ +cat /tmp/bar$$ +rm /tmp/bar$$ diff --git a/tests/50-redirect-sed.sh b/tests/50-redirect-sed.sh index f66236a..ee22797 100644 --- a/tests/50-redirect-sed.sh +++ b/tests/50-redirect-sed.sh @@ -1,5 +1,6 @@ +unset DESTDIR sed \ - -e "s,^#! /bin/sh,#! /bin/gash," \ + -e "s,^#! /bin/sh,#! /bin/GASH," \ tests/data/diff.scm > $DESTDIR/tmp/diff.scm cat $DESTDIR/tmp/diff.scm rm $DESTDIR/tmp/diff.scm diff --git a/tests/50-redirect-sed.stdout b/tests/50-redirect-sed.stdout index 800bdd8..bfc05fe 100644 --- a/tests/50-redirect-sed.stdout +++ b/tests/50-redirect-sed.stdout @@ -1,3 +1,3 @@ -#! /bin/gash +#! /bin/GASH !# diff --git a/tests/50-redirect-space.sh b/tests/50-redirect-space.sh index fe40da0..7451564 100644 --- a/tests/50-redirect-space.sh +++ b/tests/50-redirect-space.sh @@ -1,3 +1,3 @@ -echo foo > bar -cat bar -rm bar +echo foo > /tmp/bar$$ +cat /tmp/bar$$ +rm /tmp/bar$$ diff --git a/tests/50-redirect.sh b/tests/50-redirect.sh index da5cff4..6aaecd9 100644 --- a/tests/50-redirect.sh +++ b/tests/50-redirect.sh @@ -1,3 +1,3 @@ -echo foo 1>./bar -cat bar -rm bar +echo foo 1>/tmp/bar$$ +cat /tmp/bar$$ +rm /tmp/bar$$ diff --git a/tests/data/diff.scm b/tests/data/diff.scm index c7efd07..bfc05fe 100644 --- a/tests/data/diff.scm +++ b/tests/data/diff.scm @@ -1,3 +1,3 @@ -#! /bin/sh +#! /bin/GASH !#