2019-05-20 14:52:22 +01:00
|
|
|
;;; Gash -- Guile As SHell
|
|
|
|
;;; Copyright © 2018 Timothy Sample <samplet@ngyro.com>
|
|
|
|
;;;
|
|
|
|
;;; This file is part of Gash.
|
|
|
|
;;;
|
|
|
|
;;; Gash is free software: you can redistribute it and/or modify
|
|
|
|
;;; it under the terms of the GNU General Public License as published by
|
|
|
|
;;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;;; (at your option) any later version.
|
|
|
|
;;;
|
|
|
|
;;; Gash is distributed in the hope that it will be useful,
|
|
|
|
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
;;;
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2018-11-08 19:53:55 +00:00
|
|
|
(use-modules (gnu packages bash)
|
|
|
|
(gnu packages python)
|
|
|
|
(gnu packages time)
|
|
|
|
(guix gexp)
|
|
|
|
(guix git-download)
|
|
|
|
(guix modules)
|
|
|
|
(guix monads)
|
|
|
|
(guix packages)
|
|
|
|
(guix store))
|
|
|
|
|
2019-06-07 15:01:42 +01:00
|
|
|
(let* ((commit "0869f9cd4d63ff6317ed7c3718e15c14aeb44d79")
|
|
|
|
(version (git-version "0.6.pre21" "0" commit))
|
2018-11-08 19:53:55 +00:00
|
|
|
(source
|
|
|
|
(origin
|
|
|
|
(method git-fetch)
|
|
|
|
(uri (git-reference
|
|
|
|
(url "https://github.com/oilshell/oil.git")
|
|
|
|
(commit commit)))
|
|
|
|
(file-name (string-append "oil-" version "-checkout"))
|
|
|
|
(sha256
|
|
|
|
(base32
|
2019-06-07 15:01:42 +01:00
|
|
|
"0pyz4mgqmn7dl514klmxsw8z8kdnsh91a7ixnczilswbqka2j75g")))))
|
2018-11-08 19:53:55 +00:00
|
|
|
(run-with-store (open-connection)
|
|
|
|
(with-imported-modules (source-module-closure
|
|
|
|
'((guix build utils)))
|
|
|
|
(gexp->derivation
|
|
|
|
(string-append "oil-tests-" version)
|
|
|
|
#~(begin
|
2018-11-11 02:19:54 +00:00
|
|
|
(use-modules (guix build utils)
|
|
|
|
(ice-9 match)
|
2018-11-16 02:00:24 +00:00
|
|
|
(ice-9 rdelim)
|
|
|
|
(ice-9 regex)
|
|
|
|
(srfi srfi-1))
|
2018-11-08 19:53:55 +00:00
|
|
|
(copy-recursively #$source #$output)
|
|
|
|
(setenv "PATH" (list->search-path-as-string
|
|
|
|
(map (lambda (p)
|
|
|
|
(string-append p "/bin"))
|
|
|
|
(list #$bash-minimal
|
|
|
|
#$python-2
|
|
|
|
#$time))
|
|
|
|
":"))
|
|
|
|
(chdir #$output)
|
|
|
|
(for-each patch-shebang
|
|
|
|
'("spec/bin/argv.py"
|
2018-11-15 19:38:03 +00:00
|
|
|
"spec/bin/printenv.py"
|
2018-11-08 19:53:55 +00:00
|
|
|
"test/common.sh"
|
|
|
|
"test/sh_spec.py"
|
|
|
|
"test/spec-runner.sh"
|
|
|
|
"test/spec.sh"))
|
|
|
|
(substitute* "test/common.sh"
|
|
|
|
(("/usr/bin/env time") (which "time")))
|
2018-11-11 02:19:54 +00:00
|
|
|
|
2019-05-18 02:14:35 +01:00
|
|
|
;; Disable all shells except for Bash. This is mostly for
|
|
|
|
;; reproducibility, since it is annoying when the tests
|
|
|
|
;; fail because a different set of reference shells are
|
|
|
|
;; available.
|
2018-11-16 02:15:08 +00:00
|
|
|
(substitute* "test/spec.sh"
|
2019-05-18 02:14:35 +01:00
|
|
|
(("BUSYBOX_ASH=_tmp/shells/ash") "BUSYBOX_ASH=")
|
|
|
|
(("readonly DASH=\\$[(]shell-path dash[)]") "readonly DASH=")
|
|
|
|
(("readonly MKSH=\\$[(]shell-path mksh[)]") "readonly MKSH=")
|
|
|
|
(("readonly ZSH=\\$[(]shell-path zsh[)]") "readonly ZSH="))
|
2018-11-16 02:15:08 +00:00
|
|
|
|
2018-11-08 19:53:55 +00:00
|
|
|
;; This is not necessary, but it makes the output nicer.
|
|
|
|
(substitute* "test/spec.sh"
|
2018-11-11 02:19:54 +00:00
|
|
|
(("which \\$name") "which $name 2>/dev/null"))
|
|
|
|
|
|
|
|
;; We want to omit tests that use features we do not
|
|
|
|
;; support yet. This lets us add tests quickly, and expand
|
|
|
|
;; to the more integrated tests as we are able.
|
2018-11-16 02:00:24 +00:00
|
|
|
(let ((filter-tests
|
2018-11-11 02:19:54 +00:00
|
|
|
(lambda (tests file)
|
|
|
|
(format #t "Removing tests from ~a:~%" file)
|
|
|
|
(with-atomic-file-replacement file
|
|
|
|
(lambda (in out)
|
2018-11-16 02:00:24 +00:00
|
|
|
(let loop ((line (read-line in 'concat))
|
|
|
|
(transformers #t))
|
2018-11-11 02:19:54 +00:00
|
|
|
(cond
|
|
|
|
((eof-object? line) #t)
|
|
|
|
((string-prefix? "####" line)
|
|
|
|
(let* ((name-part (substring line 4))
|
|
|
|
(name (string-trim-both name-part)))
|
2018-11-16 02:00:24 +00:00
|
|
|
(match (assoc name tests)
|
|
|
|
((_ . ())
|
|
|
|
(format #t " - ~a~%" name)
|
|
|
|
(loop (read-line in 'concat) #f))
|
|
|
|
((_ . (transformers ..1))
|
|
|
|
(format #t " * ~a~%" name)
|
|
|
|
(display line out)
|
|
|
|
(loop (read-line in 'concat) transformers))
|
|
|
|
(#f
|
|
|
|
(display line out)
|
|
|
|
(loop (read-line in 'concat) #t)))))
|
2018-11-11 02:19:54 +00:00
|
|
|
(else
|
2018-11-16 02:00:24 +00:00
|
|
|
(match transformers
|
|
|
|
(#f #t)
|
|
|
|
(#t (display line out))
|
|
|
|
(((targets replacements) ..1)
|
|
|
|
(display
|
|
|
|
(fold (lambda (target replacement line)
|
|
|
|
(regexp-substitute/global
|
|
|
|
#f target line
|
|
|
|
'pre replacement 'post))
|
|
|
|
line
|
|
|
|
targets replacements)
|
|
|
|
out)))
|
|
|
|
(loop (read-line in 'concat) transformers))))))))
|
|
|
|
(tests-to-filter
|
2019-06-07 16:51:53 +01:00
|
|
|
`(("spec/case_.test.sh"
|
2018-11-21 18:38:44 +00:00
|
|
|
(;; These two are Bash specific.
|
|
|
|
("Case statement with ;;&")
|
|
|
|
("Case statement with ;&")))
|
2018-11-26 02:53:52 +00:00
|
|
|
("spec/errexit.test.sh"
|
|
|
|
(;; We do not have the time built-in.
|
|
|
|
("errexit and time { }")
|
|
|
|
;; Follow Dash on this one.
|
|
|
|
("errexit with (( ))"
|
Remove (almost) all references to Geesh.
gash/environment.scm: Remove file.
geesh/*: Move these files into the 'gash' folder and replace all
instances of the word 'geesh'.
scripts/geesh.in: Remove file.
HACKING, INSTALL, Makefile.am, configure.ac, guix.scm,
tests/bootstrap/bash-without-bash.scm, tests/spec/Makefile.am,
tests/spec/check-spec, tests/spec/oil.scm, tests/unit/*,
tools/coverage.in: Replace all instances of the word 'geesh'.
Co-authored-by: Jan Nieuwenhuizen <janneke@gnu.org>
2019-02-15 00:55:07 +00:00
|
|
|
("N-I dash" "N-I dash/gash"))
|
2018-11-26 02:53:52 +00:00
|
|
|
;; These next two are due to a difference
|
|
|
|
;; between the Oil shell and every other shell.
|
|
|
|
;; Oil thinks that setting the errexit option in
|
|
|
|
;; a context in which it is normally ignored
|
|
|
|
;; should make it no longer ignored. We leave
|
|
|
|
;; it ignored like every other shell.
|
|
|
|
("setting errexit while it's being ignored")
|
|
|
|
("setting errexit while it's being ignored in a subshell")
|
|
|
|
;; We do not do background processes yet.
|
|
|
|
("background processes respect errexit")))
|
2018-11-21 19:58:49 +00:00
|
|
|
("spec/loop.test.sh"
|
|
|
|
(;; We do not do tilde expansion yet.
|
|
|
|
("Tilde expansion within for loop")
|
|
|
|
;; This is beyond POSIX.
|
|
|
|
("Brace Expansion within Array"
|
Remove (almost) all references to Geesh.
gash/environment.scm: Remove file.
geesh/*: Move these files into the 'gash' folder and replace all
instances of the word 'geesh'.
scripts/geesh.in: Remove file.
HACKING, INSTALL, Makefile.am, configure.ac, guix.scm,
tests/bootstrap/bash-without-bash.scm, tests/spec/Makefile.am,
tests/spec/check-spec, tests/spec/oil.scm, tests/unit/*,
tools/coverage.in: Replace all instances of the word 'geesh'.
Co-authored-by: Jan Nieuwenhuizen <janneke@gnu.org>
2019-02-15 00:55:07 +00:00
|
|
|
("N-I dash" "N-I dash/gash"))
|
2018-11-21 19:58:49 +00:00
|
|
|
;; We match Bash here.
|
|
|
|
("for loop with invalid identifier"
|
Remove (almost) all references to Geesh.
gash/environment.scm: Remove file.
geesh/*: Move these files into the 'gash' folder and replace all
instances of the word 'geesh'.
scripts/geesh.in: Remove file.
HACKING, INSTALL, Makefile.am, configure.ac, guix.scm,
tests/bootstrap/bash-without-bash.scm, tests/spec/Makefile.am,
tests/spec/check-spec, tests/spec/oil.scm, tests/unit/*,
tools/coverage.in: Replace all instances of the word 'geesh'.
Co-authored-by: Jan Nieuwenhuizen <janneke@gnu.org>
2019-02-15 00:55:07 +00:00
|
|
|
("OK bash" "OK bash/gash"))
|
2018-11-21 19:58:49 +00:00
|
|
|
;; For these next two, we do not have arithmetic
|
|
|
|
;; substitution, but we can use 'expr' instead.
|
|
|
|
("while in pipe"
|
|
|
|
("\\$\\(\\(i\\+1\\)\\)" "$(expr $i + 1)"))
|
|
|
|
("while in pipe with subshell"
|
2019-06-07 15:01:42 +01:00
|
|
|
("\\$\\(\\(i\\+1\\)\\)" "$(expr $i + 1)"))
|
2019-06-07 16:51:53 +01:00
|
|
|
;; The Oil shell handles this statically. We
|
|
|
|
;; will treat it as a fatal run-time error (for
|
|
|
|
;; now).
|
|
|
|
("too many args to continue"
|
|
|
|
("## status: 2" ,(string-append
|
|
|
|
"## status: 2\n"
|
|
|
|
"## OK gash status: 1\n"
|
|
|
|
"## OK gash STDOUT:\n"
|
|
|
|
"a\n"
|
|
|
|
"## END")))))
|
2018-11-21 18:38:44 +00:00
|
|
|
("spec/quote.test.sh"
|
2018-11-16 18:34:39 +00:00
|
|
|
(;; We match KornShell on these two tests.
|
|
|
|
("Unterminated single quote"
|
Remove (almost) all references to Geesh.
gash/environment.scm: Remove file.
geesh/*: Move these files into the 'gash' folder and replace all
instances of the word 'geesh'.
scripts/geesh.in: Remove file.
HACKING, INSTALL, Makefile.am, configure.ac, guix.scm,
tests/bootstrap/bash-without-bash.scm, tests/spec/Makefile.am,
tests/spec/check-spec, tests/spec/oil.scm, tests/unit/*,
tools/coverage.in: Replace all instances of the word 'geesh'.
Co-authored-by: Jan Nieuwenhuizen <janneke@gnu.org>
2019-02-15 00:55:07 +00:00
|
|
|
("OK mksh" "OK mksh/gash"))
|
2018-11-16 18:34:39 +00:00
|
|
|
("Unterminated double quote"
|
Remove (almost) all references to Geesh.
gash/environment.scm: Remove file.
geesh/*: Move these files into the 'gash' folder and replace all
instances of the word 'geesh'.
scripts/geesh.in: Remove file.
HACKING, INSTALL, Makefile.am, configure.ac, guix.scm,
tests/bootstrap/bash-without-bash.scm, tests/spec/Makefile.am,
tests/spec/check-spec, tests/spec/oil.scm, tests/unit/*,
tools/coverage.in: Replace all instances of the word 'geesh'.
Co-authored-by: Jan Nieuwenhuizen <janneke@gnu.org>
2019-02-15 00:55:07 +00:00
|
|
|
("OK mksh" "OK mksh/gash"))
|
2018-11-16 18:34:39 +00:00
|
|
|
;; The rest of these are well beyond POSIX.
|
|
|
|
("$''")
|
|
|
|
("$'' with quotes")
|
|
|
|
("$'' with newlines")
|
|
|
|
("$'' octal escapes don't have leading 0")
|
|
|
|
("$'' octal escapes with fewer than 3 chars")
|
|
|
|
("$\"\"")))
|
|
|
|
("spec/word-split.test.sh"
|
2018-11-11 02:21:47 +00:00
|
|
|
(;; This test requires local variables, which is
|
|
|
|
;; a Bash extension.
|
2018-11-16 02:00:24 +00:00
|
|
|
("IFS is scoped")
|
2018-11-11 02:21:47 +00:00
|
|
|
;; We do not do tilde expansion yet.
|
2018-11-16 02:00:24 +00:00
|
|
|
("Tilde sub is not split, but var sub is")
|
2018-11-16 02:06:10 +00:00
|
|
|
;; These tests rely on 'echo -e', but we can use
|
|
|
|
;; Guile instead.
|
|
|
|
("IFS empty doesn't do splitting"
|
|
|
|
("echo -e ' a b\\\\tc\\\\n'"
|
|
|
|
"guile -c '(display \" a b\\tc\\n\")'"))
|
|
|
|
("IFS unset behaves like $' \\t\\n'"
|
|
|
|
("echo -e ' a b\\\\tc\\\\n'"
|
|
|
|
"guile -c '(display \" a b\\tc\\n\")'"))))
|
2018-11-16 18:53:43 +00:00
|
|
|
("spec/var-sub.test.sh"
|
|
|
|
(;; We match Bash here.
|
|
|
|
("Bad var sub"
|
Remove (almost) all references to Geesh.
gash/environment.scm: Remove file.
geesh/*: Move these files into the 'gash' folder and replace all
instances of the word 'geesh'.
scripts/geesh.in: Remove file.
HACKING, INSTALL, Makefile.am, configure.ac, guix.scm,
tests/bootstrap/bash-without-bash.scm, tests/spec/Makefile.am,
tests/spec/check-spec, tests/spec/oil.scm, tests/unit/*,
tools/coverage.in: Replace all instances of the word 'geesh'.
Co-authored-by: Jan Nieuwenhuizen <janneke@gnu.org>
2019-02-15 00:55:07 +00:00
|
|
|
("OK bash" "OK bash/gash"))
|
2018-11-16 18:53:43 +00:00
|
|
|
;; This test expects 'ls' to be at '/bin/ls',
|
|
|
|
;; which isn't the case on GuixSD.
|
|
|
|
("Braced block inside ${}"
|
|
|
|
("which ls" "guile -c '(display \"/bin/ls\")'"))
|
|
|
|
;; We match KornShell here.
|
|
|
|
("Here doc with bad \"$@\" delimiter"
|
Remove (almost) all references to Geesh.
gash/environment.scm: Remove file.
geesh/*: Move these files into the 'gash' folder and replace all
instances of the word 'geesh'.
scripts/geesh.in: Remove file.
HACKING, INSTALL, Makefile.am, configure.ac, guix.scm,
tests/bootstrap/bash-without-bash.scm, tests/spec/Makefile.am,
tests/spec/check-spec, tests/spec/oil.scm, tests/unit/*,
tools/coverage.in: Replace all instances of the word 'geesh'.
Co-authored-by: Jan Nieuwenhuizen <janneke@gnu.org>
2019-02-15 00:55:07 +00:00
|
|
|
("OK mksh" "OK mksh/gash"))))
|
2018-11-15 19:40:09 +00:00
|
|
|
("spec/redirect.test.sh"
|
|
|
|
(;; We match Bash and Dash here, just not Oil.
|
2018-11-16 02:06:10 +00:00
|
|
|
("Redirect in assignment is invalid"
|
Remove (almost) all references to Geesh.
gash/environment.scm: Remove file.
geesh/*: Move these files into the 'gash' folder and replace all
instances of the word 'geesh'.
scripts/geesh.in: Remove file.
HACKING, INSTALL, Makefile.am, configure.ac, guix.scm,
tests/bootstrap/bash-without-bash.scm, tests/spec/Makefile.am,
tests/spec/check-spec, tests/spec/oil.scm, tests/unit/*,
tools/coverage.in: Replace all instances of the word 'geesh'.
Co-authored-by: Jan Nieuwenhuizen <janneke@gnu.org>
2019-02-15 00:55:07 +00:00
|
|
|
("OK bash" "OK bash/gash"))
|
2018-11-15 19:40:09 +00:00
|
|
|
;; Again, we match Dash here (though not Bash).
|
2018-11-16 02:06:10 +00:00
|
|
|
("Redirect in assignment"
|
Remove (almost) all references to Geesh.
gash/environment.scm: Remove file.
geesh/*: Move these files into the 'gash' folder and replace all
instances of the word 'geesh'.
scripts/geesh.in: Remove file.
HACKING, INSTALL, Makefile.am, configure.ac, guix.scm,
tests/bootstrap/bash-without-bash.scm, tests/spec/Makefile.am,
tests/spec/check-spec, tests/spec/oil.scm, tests/unit/*,
tools/coverage.in: Replace all instances of the word 'geesh'.
Co-authored-by: Jan Nieuwenhuizen <janneke@gnu.org>
2019-02-15 00:55:07 +00:00
|
|
|
("OK dash" "OK dash/gash"))
|
2018-11-15 19:40:09 +00:00
|
|
|
;; This test requires arithmetic substitutions.
|
2018-11-16 02:00:24 +00:00
|
|
|
("Redirect in function body is evaluated multiple times")
|
2018-11-16 02:06:10 +00:00
|
|
|
;; We match KornShell here.
|
|
|
|
("Prefix redirect for loop -- not allowed"
|
Remove (almost) all references to Geesh.
gash/environment.scm: Remove file.
geesh/*: Move these files into the 'gash' folder and replace all
instances of the word 'geesh'.
scripts/geesh.in: Remove file.
HACKING, INSTALL, Makefile.am, configure.ac, guix.scm,
tests/bootstrap/bash-without-bash.scm, tests/spec/Makefile.am,
tests/spec/check-spec, tests/spec/oil.scm, tests/unit/*,
tools/coverage.in: Replace all instances of the word 'geesh'.
Co-authored-by: Jan Nieuwenhuizen <janneke@gnu.org>
2019-02-15 00:55:07 +00:00
|
|
|
("OK mksh" "OK mksh/gash"))
|
2018-11-15 19:40:09 +00:00
|
|
|
;; We do not support named file descriptors
|
|
|
|
;; (they are not in POSIX).
|
2018-11-16 02:00:24 +00:00
|
|
|
("Named file descriptor")
|
2018-11-26 01:59:18 +00:00
|
|
|
;; This requires the errexit option, which we do
|
|
|
|
;; not use yet.
|
2018-11-16 02:00:24 +00:00
|
|
|
(">| to clobber")
|
2018-11-15 19:40:09 +00:00
|
|
|
;; This is Bash specific.
|
2018-11-16 02:00:24 +00:00
|
|
|
("&> redirects stdout and stderr")
|
2018-11-15 19:40:09 +00:00
|
|
|
;; This seems to go beyond POSIX.
|
2018-11-16 02:00:24 +00:00
|
|
|
("1>&2- to close file descriptor")
|
2018-11-15 19:40:09 +00:00
|
|
|
;; Again, this is Bash specific.
|
2018-11-16 02:00:24 +00:00
|
|
|
("&>> appends stdout and stderr"))))))
|
2018-11-11 02:19:54 +00:00
|
|
|
(for-each (match-lambda
|
2018-11-16 02:00:24 +00:00
|
|
|
((file tests) (filter-tests tests file)))
|
|
|
|
tests-to-filter)))))))
|
2018-11-11 02:19:54 +00:00
|
|
|
|
|
|
|
;; Local Variables:
|
|
|
|
;; eval: (put 'with-atomic-file-replacement 'scheme-indent-function 1)
|
|
|
|
;; End:
|