diff --git a/.gitignore b/.gitignore index 5e43614..5a02310 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,6 @@ pre-inst-env scripts/geesh tests/*.trs tests/config.scm +tests/spec/oil +tests/spec/oil-link tools/coverage diff --git a/Makefile.am b/Makefile.am index 2bb567b..f14e4f0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -36,6 +36,10 @@ endif # HAVE_GENHTML test-list: ; @echo $(TESTS) +.PHONY: check-spec +check-spec: + $(MAKE) $(AM_MAKEFLAGS) -L -C tests/spec check + MODULES = \ geesh/built-ins/echo.scm \ geesh/built-ins/false.scm \ @@ -63,3 +67,6 @@ CLEANFILES = \ $(GOBJECTS) \ $(TESTS:tests/%.scm=%.log) \ $(TESTS:tests/%.scm=%.trs) + +clean-local: + $(MAKE) $(AM_MAKEFLAGS) -L -C tests/spec clean diff --git a/configure.ac b/configure.ac index 77c3da2..cea23ae 100644 --- a/configure.ac +++ b/configure.ac @@ -14,6 +14,7 @@ AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([pre-inst-env], [chmod +x pre-inst-env]) AC_CONFIG_FILES([scripts/geesh], [chmod +x scripts/geesh]) AC_CONFIG_FILES([tests/config.scm]) +AC_CONFIG_FILES([tests/spec/Makefile]) AC_CONFIG_FILES([tools/coverage], [chmod +x tools/coverage]) AC_OUTPUT diff --git a/tests/spec/Makefile.am b/tests/spec/Makefile.am new file mode 100644 index 0000000..2e628e1 --- /dev/null +++ b/tests/spec/Makefile.am @@ -0,0 +1,25 @@ +oil-link: oil.scm + if test -L oil-link; then unlink oil-link; fi + guix build --root=oil-link --file=oil.scm + +oil: oil-link + rm -rf oil + cp -R -H oil-link "$@" + chmod -R u+w "$@" + +oil/bin/geesh: oil + echo "#!/bin/sh" > "$@" + echo "$(abs_top_builddir)/pre-inst-env geesh" >> "$@" + chmod a+x "$@" + +check: oil/bin/geesh ; + +TEST_EXTENSIONS = .sh +SH_LOG_COMPILER = ./check-spec + +TESTS = \ + oil/spec/smoke.test.sh + +clean-local: + rm -rf oil + if test -L oil-link; then unlink oil-link; fi diff --git a/tests/spec/check-spec b/tests/spec/check-spec new file mode 100755 index 0000000..057256e --- /dev/null +++ b/tests/spec/check-spec @@ -0,0 +1,10 @@ +#!/bin/sh + +cd oil +export OSH_LIST=bin/geesh + +test_name=$(basename "$1") +test_name=${test_name%.sh} +test_name=${test_name%.test} + +./test/spec.sh "$test_name" --verbose diff --git a/tests/spec/oil.scm b/tests/spec/oil.scm new file mode 100644 index 0000000..c32bc29 --- /dev/null +++ b/tests/spec/oil.scm @@ -0,0 +1,49 @@ +(use-modules (gnu packages bash) + (gnu packages python) + (gnu packages time) + (guix gexp) + (guix git-download) + (guix modules) + (guix monads) + (guix packages) + (guix store)) + +(let* ((commit "4d10a3d2a477a9f4e0d92b8c1fe37c7ee9507aa8") + (version (git-version "0.6.pre5" "0" commit)) + (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 + "0gq3c4m4sz27qmfk6c6k0l7q0fas2gbal1yj0dd97yz3pgkl1vqz"))))) + (run-with-store (open-connection) + (with-imported-modules (source-module-closure + '((guix build utils))) + (gexp->derivation + (string-append "oil-tests-" version) + #~(begin + (use-modules (guix build utils)) + (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" + "test/common.sh" + "test/sh_spec.py" + "test/spec-runner.sh" + "test/spec.sh")) + (substitute* "test/common.sh" + (("/usr/bin/env time") (which "time"))) + ;; This is not necessary, but it makes the output nicer. + (substitute* "test/spec.sh" + (("which \\$name") "which $name 2>/dev/null")))))))