From e55994a72e9273936c702360df427e7331e4203a Mon Sep 17 00:00:00 2001 From: Etienne Marais Date: Wed, 26 Jun 2024 14:52:12 +0200 Subject: [PATCH] fix: use files instead of stdout (tmp) Signed-off-by: Etienne Marais --- .../pkg/absolute-paths-in-sections.t | 8 ++- .../test-cases/pkg/build-single-package.t | 9 ++- .../test-cases/pkg/command-from-user-path.t | 6 +- .../test-cases/pkg/default-git-branch.t | 9 ++- .../test-cases/pkg/different-dune-in-path.t | 15 ++++- .../test-cases/pkg/git-source.t | 6 +- test/blackbox-tests/test-cases/pkg/helpers.sh | 11 ++++ .../test-cases/pkg/installed-binary.t | 6 +- .../test-cases/pkg/lock-directory-selection.t | 21 ++++--- test/blackbox-tests/test-cases/pkg/make.t | 5 +- .../pkg/opam-package-install-no-build.t | 11 +++- .../test-cases/pkg/opam-package-subst-patch.t | 10 +++- .../pkg/opam-package-with-build-env.t | 19 ++++-- .../pkg/opam-package-with-patch-filter.t | 10 +++- .../pkg/opam-package-with-patch-multiple.t | 10 +++- .../test-cases/pkg/opam-package-with-patch.t | 10 +++- .../test-cases/pkg/opam-package-with-setenv.t | 39 +++++++------ .../test-cases/pkg/opam-package-with-subst.t | 10 +++- .../test-cases/pkg/opam-var/make-over-gmake.t | 10 ++-- .../test-cases/pkg/opam-var/opam-var-global.t | 7 ++- .../test-cases/pkg/opam-var/opam-var-os.t | 31 +++++----- .../test-cases/pkg/opam-var/opam-var-switch.t | 58 ++++++++++--------- .../pin-stanza/update-non-dune-local-pin.t | 28 +++++---- .../test-cases/pkg/pkg-action-when.t | 13 +++-- .../pkg/run-converted-opam-commands.t | 45 +++++++------- .../test-cases/pkg/set-ocamlfind-destdir.t | 10 +++- .../test-cases/pkg/source-caching.t | 7 ++- test/blackbox-tests/test-cases/pkg/tarball.t | 5 +- 28 files changed, 270 insertions(+), 159 deletions(-) diff --git a/test/blackbox-tests/test-cases/pkg/absolute-paths-in-sections.t b/test/blackbox-tests/test-cases/pkg/absolute-paths-in-sections.t index 9c9e55f68ca1..3f2f32c51444 100644 --- a/test/blackbox-tests/test-cases/pkg/absolute-paths-in-sections.t +++ b/test/blackbox-tests/test-cases/pkg/absolute-paths-in-sections.t @@ -7,8 +7,8 @@ Test that section pforms are substituted with absolute paths. $ cat >dune.lock/test.pkg < (version 0.0.1) > (install (progn - > (run echo --prefix %{prefix}) - > (run echo --prefix=%{prefix}))) + > (run sh -c "echo --prefix %{prefix} > %{etc}/cmd-output") + > (run sh -c "echo --prefix=%{prefix} >> %{etc}/cmd-output"))) > EOF $ cat >dune-project <&1 | strip_sandbox + + $ dune build ; \ + > show_pkg_output test | strip_sandbox --prefix $SANDBOX/_private/default/.pkg/test/target $SANDBOX/_private/default/.pkg/test/target diff --git a/test/blackbox-tests/test-cases/pkg/build-single-package.t b/test/blackbox-tests/test-cases/pkg/build-single-package.t index dcb9b6de47a7..099de6357c47 100644 --- a/test/blackbox-tests/test-cases/pkg/build-single-package.t +++ b/test/blackbox-tests/test-cases/pkg/build-single-package.t @@ -10,7 +10,8 @@ Requesting to build a single package should not build unrelated things: $ pkg() { > make_lockpkg $1 < (build (run echo building $1)) + > (build (run sh -c "echo building $1 > cat-output-$1")) + > (install (run cp "cat-output-$1" %{etc})) > (version dev) > EOF > } @@ -22,10 +23,12 @@ These two packages are independent: We should only see the result of building "foo" - $ build_pkg foo + $ build_pkg foo ; \ + > show_pkg_output foo "cat-output-foo" building foo We should only see the result of building "bar" - $ build_pkg bar + $ build_pkg bar ; \ + > show_pkg_output bar "cat-output-bar" building bar diff --git a/test/blackbox-tests/test-cases/pkg/command-from-user-path.t b/test/blackbox-tests/test-cases/pkg/command-from-user-path.t index 567c132817a5..221f447f3b0e 100644 --- a/test/blackbox-tests/test-cases/pkg/command-from-user-path.t +++ b/test/blackbox-tests/test-cases/pkg/command-from-user-path.t @@ -6,7 +6,7 @@ Create a directory containing a shell script and add the directory to PATH. $ mkdir bin $ cat > bin/hello < #!/bin/sh - > echo "Hello, World!" + > echo "Hello, World!" > cmd-output > EOF $ chmod a+x bin/hello $ export PATH=$PATH:$PWD/bin @@ -16,8 +16,10 @@ Create a lockdir with a lockfile that runs the shell script in a build command. $ cat >dune.lock/test.pkg <<'EOF' > (version 0.0.1) > (build (run hello)) + > (install (run cp "cmd-output" %{etc})) > EOF The build command is run from an environment including the custom PATH variable. - $ build_pkg test + $ build_pkg test ; \ + > show_pkg_output test Hello, World! diff --git a/test/blackbox-tests/test-cases/pkg/default-git-branch.t b/test/blackbox-tests/test-cases/pkg/default-git-branch.t index ab77b217fc7c..979d3c3b768b 100644 --- a/test/blackbox-tests/test-cases/pkg/default-git-branch.t +++ b/test/blackbox-tests/test-cases/pkg/default-git-branch.t @@ -26,12 +26,14 @@ This bug is reported in #10063 $ make_lockpkg foo < (source (fetch (url "git+file://$PWD/$src"))) > (version 0.0.1) - > (build (run cat file)) + > (build (run sh -c "cat file > cmd-output")) + > (install (run cp "cmd-output" %{etc})) > EOF Build the package - $ build_pkg foo + $ build_pkg foo ; \ + > show_pkg_output foo branch 2 Change the default branch @@ -41,5 +43,6 @@ Change the default branch And now rebuild - $ build_pkg foo + $ build_pkg foo ; \ + > show_pkg_output foo branch 1 diff --git a/test/blackbox-tests/test-cases/pkg/different-dune-in-path.t b/test/blackbox-tests/test-cases/pkg/different-dune-in-path.t index d57ecc84af7c..4c7516f27ed6 100644 --- a/test/blackbox-tests/test-cases/pkg/different-dune-in-path.t +++ b/test/blackbox-tests/test-cases/pkg/different-dune-in-path.t @@ -41,6 +41,9 @@ Make lockfiles for the packages. > (build > (run dune build -p %{pkg-self:name} @install)) > + > (install + > (run sh -c "test -f cmd-output && cp cmd-output %{etc} || true")) + > > (source > (fetch > (url $PWD/foo.tar.gz))) @@ -55,6 +58,9 @@ Make lockfiles for the packages. > ; Exercise that the dune exe can be located when it's launched by a subprocess. > (run sh -c "dune build -p %{pkg-self:name} @install")) > + > (install + > (run sh -c "test -f cmd-output && cp cmd-output %{etc} || true")) + > > (source > (fetch > (url $PWD/bar.tar.gz))) @@ -69,13 +75,16 @@ Make a fake dune exe: $ mkdir bin $ cat > bin/dune < #!/bin/sh - > echo "Fake dune! (args: \$@)" + > echo "Fake dune! (args: \$@)" > cmd-output > EOF $ chmod a+x bin/dune $ dune clean + Try building in an environment where `dune` refers to the fake dune. $ DUNE=$(which dune) # otherwise we would start by running the wrong dune - $ PATH=$PWD/bin:$PATH $DUNE build - Fake dune! (args: build -p bar @install) + $ PATH=$PWD/bin:$PATH $DUNE build ; \ + > show_pkg_output foo ; \ + > show_pkg_output bar Fake dune! (args: build -p foo @install) + Fake dune! (args: build -p bar @install) diff --git a/test/blackbox-tests/test-cases/pkg/git-source.t b/test/blackbox-tests/test-cases/pkg/git-source.t index 31e710c2b6c4..22e656c9a601 100644 --- a/test/blackbox-tests/test-cases/pkg/git-source.t +++ b/test/blackbox-tests/test-cases/pkg/git-source.t @@ -17,8 +17,10 @@ Test fetching from git $ cat >dune.lock/test.pkg < (version 0.0.1) > (source (fetch (url "git+file://$MYGITREPO"))) - > (build (run cat foo)) + > (build (run sh -c "cat foo > cmd-output")) + > (install (run cp cmd-output %{etc})) > EOF - $ build_pkg test + $ build_pkg test ; \ + > show_pkg_output test hello world diff --git a/test/blackbox-tests/test-cases/pkg/helpers.sh b/test/blackbox-tests/test-cases/pkg/helpers.sh index e407ffb48a42..6ef8be3f1c13 100644 --- a/test/blackbox-tests/test-cases/pkg/helpers.sh +++ b/test/blackbox-tests/test-cases/pkg/helpers.sh @@ -20,6 +20,17 @@ show_pkg_targets() { find $pkg_root/$1/target | sort | sed "s#$pkg_root/$1/target##" } +show_pkg_output() { + if [ "$#" -eq "1" ] + then + output="cmd-output" + else + output="$2" + fi + cat "_build/_private/default/.pkg/$1/target/etc/$output" +} + + show_pkg_cookie() { $dune internal dump $pkg_root/$1/target/cookie } diff --git a/test/blackbox-tests/test-cases/pkg/installed-binary.t b/test/blackbox-tests/test-cases/pkg/installed-binary.t index 05ab57e4ddbf..6251e068db73 100644 --- a/test/blackbox-tests/test-cases/pkg/installed-binary.t +++ b/test/blackbox-tests/test-cases/pkg/installed-binary.t @@ -6,7 +6,8 @@ Test that installed binaries are visible in dependent packages $ cat >dune.lock/test.pkg < (version 0.0.1) > (build - > (system "\| echo "#!/bin/sh\necho from test package" > foo; + > (system "\| echo "#!/bin/sh\necho \"from test package\" > cmd-output" > foo; + > "\| echo "echo from test package" >> foo; > "\| chmod +x foo; > "\| touch libxxx lib_rootxxx; > "\| cat >test.install < (progn > (run foo) > (run mkdir -p %{prefix}))) + > (install (run cp "cmd-output" %{etc})) > EOF - $ build_pkg usetest + $ build_pkg usetest ; show_pkg_output usetest from test package $ show_pkg_targets test diff --git a/test/blackbox-tests/test-cases/pkg/lock-directory-selection.t b/test/blackbox-tests/test-cases/pkg/lock-directory-selection.t index 22b57353d6d9..5b08e036aed0 100644 --- a/test/blackbox-tests/test-cases/pkg/lock-directory-selection.t +++ b/test/blackbox-tests/test-cases/pkg/lock-directory-selection.t @@ -5,15 +5,18 @@ Test that dune can dynamically select a lockdir with a cond statement $ mkrepo $ mkpkg arm64-only < install: [ "echo" "arm64-only" ] + > build: [ "sh" "-c" " echo arm64-only > cmd-output-arm64"] + > install: [ "cp" "cmd-output-arm64" etc ] > EOF $ mkpkg linux-only < install: [ "echo" "linux-only" ] + > build: [ "sh" "-c" " echo linux-only > cmd-output-linux"] + > install: [ "cp" "cmd-output-linux" etc ] > EOF $ mkpkg macos-only < install: [ "echo" "macos-only" ] + > build: [ "sh" "-c" " echo macos-only > cmd-output-macos"] + > install: [ "cp" "cmd-output-macos" etc ] > EOF $ cat >dune-workspace < show_pkg_output macos-only "cmd-output-macos" macos-only Build macos package on macos: $ dune clean - $ DUNE_CONFIG__OS=macos DUNE_CONFIG__ARCH=amd64 dune build _build/_private/default/.pkg/macos-only/target/ + $ DUNE_CONFIG__OS=macos DUNE_CONFIG__ARCH=amd64 dune build _build/_private/default/.pkg/macos-only/target/ && \ + > show_pkg_output macos-only "cmd-output-macos" macos-only Build linux package on macos (will fail): @@ -98,7 +103,8 @@ Build macos package on linux (will fail): Build linux package on linux: $ dune clean - $ DUNE_CONFIG__OS=linux DUNE_CONFIG__ARCH=amd64 dune build _build/_private/default/.pkg/linux-only/target/ + $ DUNE_CONFIG__OS=linux DUNE_CONFIG__ARCH=amd64 dune build _build/_private/default/.pkg/linux-only/target/ && \ + > show_pkg_output linux-only "cmd-output-linux" linux-only Try setting the os to one which doesn't have a corresponding lockdir: @@ -133,5 +139,6 @@ Test that cond statements can have a default value: Solution for dune.lock: - linux-only.0.0.1 $ dune clean - $ dune build _build/_private/default/.pkg/linux-only/target/ + $ dune build _build/_private/default/.pkg/linux-only/target/ && \ + > show_pkg_output linux-only "cmd-output-linux" linux-only diff --git a/test/blackbox-tests/test-cases/pkg/make.t b/test/blackbox-tests/test-cases/pkg/make.t index 75c62aece8aa..735e4699ef15 100644 --- a/test/blackbox-tests/test-cases/pkg/make.t +++ b/test/blackbox-tests/test-cases/pkg/make.t @@ -5,13 +5,14 @@ Build a package with make $ cat >foo/Makefile < .DEFAULT: foo > .PHONY: foo - > foo: ; @echo running makefile + > foo: ; @echo running makefile > cmd-output > EOF $ make_lockdir $ cat >dune.lock/foo.pkg < (version 0.0.1) > (build (run %{make})) + > (install (run cp "cmd-output" %{etc})) > (source (copy $PWD/foo)) > EOF - $ build_pkg foo + $ build_pkg foo && show_pkg_output foo running makefile diff --git a/test/blackbox-tests/test-cases/pkg/opam-package-install-no-build.t b/test/blackbox-tests/test-cases/pkg/opam-package-install-no-build.t index f35d996a281b..85a9425dee31 100644 --- a/test/blackbox-tests/test-cases/pkg/opam-package-install-no-build.t +++ b/test/blackbox-tests/test-cases/pkg/opam-package-install-no-build.t @@ -5,7 +5,10 @@ In this test we test the translation of an opam package with only an install ste Make a package with only an install step $ mkpkg install-no-build < install: ["echo" "just installing"] + > install: [ + > [ "sh" "-c" "echo just installing > cmd-output" ] + > [ "cp" "cmd-output" etc ] + > ] > EOF $ mkdir -p $mock_packages/install-no-build/install-no-build.0.0.1/ @@ -19,9 +22,11 @@ The lockfile should only contain an install step. (version 0.0.1) (install - (run echo "just installing")) + (progn + (run sh -c "echo just installing > cmd-output") + (run cp cmd-output %{etc}))) Building should only do the install step. - $ build_pkg install-no-build + $ build_pkg install-no-build && show_pkg_output install-no-build just installing diff --git a/test/blackbox-tests/test-cases/pkg/opam-package-subst-patch.t b/test/blackbox-tests/test-cases/pkg/opam-package-subst-patch.t index 8137533d7d6e..c5b3c017192e 100644 --- a/test/blackbox-tests/test-cases/pkg/opam-package-subst-patch.t +++ b/test/blackbox-tests/test-cases/pkg/opam-package-subst-patch.t @@ -9,7 +9,8 @@ Make a package with a substs and patches field field $ mkpkg with-substs-and-patches < substs: ["foo.patch"] > patches: ["foo.patch"] - > build: [ "sh" "-c" "[ -e foo.ml ] && cat foo.ml" ] + > build: [ "sh" "-c" "[ -e foo.ml ] && cat foo.ml > cmd-output" ] + > install: [ "cp" "cmd-output" etc ] > EOF $ opam_repo=$mock_packages/with-substs-and-patches/with-substs-and-patches.0.0.1 @@ -26,11 +27,14 @@ The lockfile should contain the substitute and patch actions. $ cat dune.lock/with-substs-and-patches.pkg (version 0.0.1) + (install + (run cp cmd-output %{etc})) + (build (progn (substitute foo.patch.in foo.patch) (patch foo.patch) - (run sh -c "[ -e foo.ml ] && cat foo.ml"))) + (run sh -c "[ -e foo.ml ] && cat foo.ml > cmd-output"))) (source (copy $TESTCASE_ROOT/source)) $ mkdir source @@ -51,5 +55,5 @@ The lockfile should contain the substitute and patch actions. The file foo.ml should have been built: - $ build_pkg with-substs-and-patches + $ build_pkg with-substs-and-patches && show_pkg_output with-substs-and-patches This is right diff --git a/test/blackbox-tests/test-cases/pkg/opam-package-with-build-env.t b/test/blackbox-tests/test-cases/pkg/opam-package-with-build-env.t index adfee2d1370b..e0be55aa1049 100644 --- a/test/blackbox-tests/test-cases/pkg/opam-package-with-build-env.t +++ b/test/blackbox-tests/test-cases/pkg/opam-package-with-build-env.t @@ -7,8 +7,12 @@ file. Make a package with a build-env field $ mkpkg with-build-env <<'EOF' > build-env: [ [ MY_ENV_VAR = "Hello from env var!" ] ] - > build: ["sh" "-c" "echo $MY_ENV_VAR"] - > install: ["sh" "-c" "echo $MY_ENV_VAR"] + > build: ["sh" "-c" "echo $MY_ENV_VAR > cmd-output-build"] + > install: [ + > ["sh" "-c" "echo $MY_ENV_VAR > cmd-output-install"] + > ["cp" "cmd-output-build" etc] + > ["cp" "cmd-output-install" etc] + > ] > EOF $ solve with-build-env @@ -22,15 +26,20 @@ The lockfile should contain a setenv action. (install (withenv ((= MY_ENV_VAR "Hello from env var!")) - (run sh -c "echo $MY_ENV_VAR"))) + (progn + (run sh -c "echo $MY_ENV_VAR > cmd-output-install") + (run cp cmd-output-build %{etc}) + (run cp cmd-output-install %{etc})))) (build (withenv ((= MY_ENV_VAR "Hello from env var!")) - (run sh -c "echo $MY_ENV_VAR"))) + (run sh -c "echo $MY_ENV_VAR > cmd-output-build"))) This should print the value given in the build-env field. - $ MY_ENV_VAR="invisible" build_pkg with-build-env + $ MY_ENV_VAR="invisible" build_pkg with-build-env && \ + > show_pkg_output with-build-env "cmd-output-build" && \ + > show_pkg_output with-build-env "cmd-output-install" Hello from env var! Hello from env var! diff --git a/test/blackbox-tests/test-cases/pkg/opam-package-with-patch-filter.t b/test/blackbox-tests/test-cases/pkg/opam-package-with-patch-filter.t index 046fb5d4e69c..8e10efbbd641 100644 --- a/test/blackbox-tests/test-cases/pkg/opam-package-with-patch-filter.t +++ b/test/blackbox-tests/test-cases/pkg/opam-package-with-patch-filter.t @@ -7,7 +7,8 @@ lock file. Make a package with a patch behind a filter $ mkpkg with-patch-filter < patches: ["foo.patch" {switch = "foobar"}] - > build: ["cat" "foo.ml"] + > build: ["sh" "-c" "cat foo.ml > cmd-output"] + > install: ["cp" "cmd-output" etc] > EOF $ mkdir -p $mock_packages/with-patch-filter/with-patch-filter.0.0.1/files @@ -33,12 +34,15 @@ The lockfile should contain the patch action with the appropriate filter. $ cat dune.lock/with-patch-filter.pkg (version 0.0.1) + (install + (run cp cmd-output %{etc})) + (build (progn (when (= %{switch} foobar) (patch foo.patch)) - (run cat foo.ml))) + (run sh -c "cat foo.ml > cmd-output"))) (source (copy $TESTCASE_ROOT/source)) $ mkdir source @@ -46,5 +50,5 @@ The lockfile should contain the patch action with the appropriate filter. > This is right; the patch should never be applied. > EOF - $ build_pkg with-patch-filter + $ build_pkg with-patch-filter && show_pkg_output with-patch-filter This is right; the patch should never be applied. diff --git a/test/blackbox-tests/test-cases/pkg/opam-package-with-patch-multiple.t b/test/blackbox-tests/test-cases/pkg/opam-package-with-patch-multiple.t index dc0543aa12c2..382bac721de1 100644 --- a/test/blackbox-tests/test-cases/pkg/opam-package-with-patch-multiple.t +++ b/test/blackbox-tests/test-cases/pkg/opam-package-with-patch-multiple.t @@ -9,7 +9,8 @@ file and the second patches two, one of the files is in a subdirectory.:w $ mkpkg with-patch < patches: ["foo.patch" "dir/bar.patch"] - > build: ["cat" "foo.ml" "bar.ml" "dir/baz.ml"] + > build: [ "sh" "-c" "cat foo.ml bar.ml dir/baz.ml > cmd-output"] + > install: [ "cp" "cmd-output" etc ] > EOF $ opam_dir=$mock_packages/with-patch/with-patch.0.0.1 @@ -63,11 +64,14 @@ The lockfile should contain the patch action. $ cat dune.lock/with-patch.pkg (version 0.0.1) + (install + (run cp cmd-output %{etc})) + (build (progn (patch foo.patch) (patch dir/bar.patch) - (run cat foo.ml bar.ml dir/baz.ml))) + (run sh -c "cat foo.ml bar.ml dir/baz.ml > cmd-output"))) (source (copy $TESTCASE_ROOT/source)) $ mkdir -p source/dir @@ -83,7 +87,7 @@ The lockfile should contain the patch action. The build step of the opam file correctly cats the patched files. - $ build_pkg with-patch + $ build_pkg with-patch && show_pkg_output with-patch This is right This is right This is right diff --git a/test/blackbox-tests/test-cases/pkg/opam-package-with-patch.t b/test/blackbox-tests/test-cases/pkg/opam-package-with-patch.t index 0c812c80aa4b..f45cf43c0607 100644 --- a/test/blackbox-tests/test-cases/pkg/opam-package-with-patch.t +++ b/test/blackbox-tests/test-cases/pkg/opam-package-with-patch.t @@ -7,7 +7,8 @@ appropriate build step. Make a package with a patch $ mkpkg with-patch < patches: ["foo.patch"] - > build: ["cat" "foo.ml"] + > build: [ "sh" "-c" "cat foo.ml > cmd-output"] + > install: [ "cp" "cmd-output" etc ] > EOF @@ -34,10 +35,13 @@ The lockfile should contain the patch action. $ cat dune.lock/with-patch.pkg (version 0.0.1) + (install + (run cp cmd-output %{etc})) + (build (progn (patch foo.patch) - (run cat foo.ml))) + (run sh -c "cat foo.ml > cmd-output"))) (source (copy $TESTCASE_ROOT/source)) $ mkdir source @@ -45,5 +49,5 @@ The lockfile should contain the patch action. > This is wrong > EOF - $ build_pkg with-patch + $ build_pkg with-patch && show_pkg_output with-patch This is right diff --git a/test/blackbox-tests/test-cases/pkg/opam-package-with-setenv.t b/test/blackbox-tests/test-cases/pkg/opam-package-with-setenv.t index ebb1cca955c9..93bde1fd1bb0 100644 --- a/test/blackbox-tests/test-cases/pkg/opam-package-with-setenv.t +++ b/test/blackbox-tests/test-cases/pkg/opam-package-with-setenv.t @@ -19,12 +19,13 @@ Make another package that depends on that and outputs the exported env vars $ mkpkg deps-on-with-setenv <<'EOF' > depends: [ "with-setenv" ] > build: [ - > [ "sh" "-c" "echo $EXPORTED_ENV_VAR" ] - > [ "sh" "-c" "echo $prepend_without_trailing_sep" ] - > [ "sh" "-c" "echo $prepend_with_trailing_sep" ] - > [ "sh" "-c" "echo $append_without_leading_sep" ] - > [ "sh" "-c" "echo $append_with_leading_sep" ] + > [ "sh" "-c" "echo $EXPORTED_ENV_VAR > cmd-output" ] + > [ "sh" "-c" "echo $prepend_without_trailing_sep >> cmd-output" ] + > [ "sh" "-c" "echo $prepend_with_trailing_sep >> cmd-output" ] + > [ "sh" "-c" "echo $append_without_leading_sep >> cmd-output" ] + > [ "sh" "-c" "echo $append_with_leading_sep >> cmd-output" ] > ] + > install: [ "cp" "cmd-output" etc ] > EOF > solve deps-on-with-setenv Solution for dune.lock: @@ -44,13 +45,16 @@ The exported env from the first package should be in the lock dir. $ cat dune.lock/deps-on-with-setenv.pkg (version 0.0.1) + (install + (run cp cmd-output %{etc})) + (build (progn - (run sh -c "echo $EXPORTED_ENV_VAR") - (run sh -c "echo $prepend_without_trailing_sep") - (run sh -c "echo $prepend_with_trailing_sep") - (run sh -c "echo $append_without_leading_sep") - (run sh -c "echo $append_with_leading_sep"))) + (run sh -c "echo $EXPORTED_ENV_VAR > cmd-output") + (run sh -c "echo $prepend_without_trailing_sep >> cmd-output") + (run sh -c "echo $prepend_with_trailing_sep >> cmd-output") + (run sh -c "echo $append_without_leading_sep >> cmd-output") + (run sh -c "echo $append_with_leading_sep >> cmd-output"))) (depends with-setenv) @@ -70,7 +74,7 @@ Appended without leading sep > prepend_with_trailing_sep="foo:bar" \ > append_without_leading_sep="foo:bar" \ > append_with_leading_sep="foo:bar" \ - > build_pkg deps-on-with-setenv + > build_pkg deps-on-with-setenv && show_pkg_output deps-on-with-setenv Hello from the other package! Prepended without trailing sep Prepended with trailing sep @@ -93,12 +97,13 @@ difference between a propagated export_env versus the initial env. > mkpkg deps-on-with-setenv-2 <<'EOF' > depends: [ "with-setenv-2" ] > build: [ - > [ "sh" "-c" "echo $EXPORTED_ENV_VAR" ] - > [ "sh" "-c" "echo $prepend_without_trailing_sep" ] - > [ "sh" "-c" "echo $prepend_with_trailing_sep" ] - > [ "sh" "-c" "echo $append_without_leading_sep" ] - > [ "sh" "-c" "echo $append_with_leading_sep" ] + > [ "sh" "-c" "echo $EXPORTED_ENV_VAR > cmd-output" ] + > [ "sh" "-c" "echo $prepend_without_trailing_sep >> cmd-output" ] + > [ "sh" "-c" "echo $prepend_with_trailing_sep >> cmd-output" ] + > [ "sh" "-c" "echo $append_without_leading_sep >> cmd-output" ] + > [ "sh" "-c" "echo $append_with_leading_sep >> cmd-output" ] > ] + > install: [ "cp" "cmd-output" etc ] > EOF > solve deps-on-with-setenv-2 Solution for dune.lock: @@ -125,7 +130,7 @@ Appended 2nd time without leading sep:Appended without leading sep > prepend_with_trailing_sep="foo:bar" \ > append_without_leading_sep="foo:bar" \ > append_with_leading_sep="foo:bar" \ - > build_pkg deps-on-with-setenv-2 + > build_pkg deps-on-with-setenv-2 && show_pkg_output deps-on-with-setenv-2 Hello from the second package! Prepended 2nd time without trailing sep:Prepended without trailing sep Prepended 2nd time with sep:Prepended with trailing sep diff --git a/test/blackbox-tests/test-cases/pkg/opam-package-with-subst.t b/test/blackbox-tests/test-cases/pkg/opam-package-with-subst.t index a4f488838a23..c3c7e3b621c1 100644 --- a/test/blackbox-tests/test-cases/pkg/opam-package-with-subst.t +++ b/test/blackbox-tests/test-cases/pkg/opam-package-with-subst.t @@ -6,7 +6,8 @@ We test how opam files with substs fields are translated into the dune.lock file Make a package with a substs field $ mkpkg with-substs < substs: ["foo.ml"] - > build: [ "sh" "-c" "[ -e foo.ml ] && cat foo.ml" ] + > build: [ "sh" "-c" "[ -e foo.ml ] && cat foo.ml > cmd-output" ] + > install: [ "cp" "cmd-output" etc ] > EOF $ solve with-substs @@ -20,10 +21,13 @@ The lockfile should contain the substitute action. $ cat dune.lock/with-substs.pkg (version 0.0.1) + (install + (run cp cmd-output %{etc})) + (build (progn (substitute foo.ml.in foo.ml) - (run sh -c "[ -e foo.ml ] && cat foo.ml"))) + (run sh -c "[ -e foo.ml ] && cat foo.ml > cmd-output"))) (source (copy $TESTCASE_ROOT/source)) $ mkdir source @@ -33,5 +37,5 @@ The lockfile should contain the substitute action. The file foo.ml should have been built: - $ build_pkg with-substs + $ build_pkg with-substs && show_pkg_output with-substs I have been substituted. diff --git a/test/blackbox-tests/test-cases/pkg/opam-var/make-over-gmake.t b/test/blackbox-tests/test-cases/pkg/opam-var/make-over-gmake.t index 6c11fab4ec95..7b3aeb8c98e9 100644 --- a/test/blackbox-tests/test-cases/pkg/opam-var/make-over-gmake.t +++ b/test/blackbox-tests/test-cases/pkg/opam-var/make-over-gmake.t @@ -6,18 +6,20 @@ opam doesn't resolve make but rather runs make literally so it is up to whatever PATH to resolve it. This does mean that make is preferred over gmake so we should replicate that behaviour. -We create a dummy package that will output the value of the opam make variable: +We create a dummy package that will output to a file the value of the opam make variable: $ mkrepo > mkpkg testpkg << EOF - > build: [ "echo" make ] + > build: [ "sh" "-c" "echo %{make}% > cmd-output" ] + > install: [ "cp" "cmd-output" etc ] > EOF > solve testpkg 2> /dev/null We now create dummy versions of make and gmake. $ cat > make; cat > gmake + We add the current directory to PATH. Dune will expand %{make} and should prefer make over gmake. $ PATH=.:$PATH - > build_pkg testpkg + > build_pkg testpkg ; \ + > show_pkg_output testpkg $TESTCASE_ROOT/gmake - diff --git a/test/blackbox-tests/test-cases/pkg/opam-var/opam-var-global.t b/test/blackbox-tests/test-cases/pkg/opam-var/opam-var-global.t index b6b5ce67df51..9efa7124bb41 100644 --- a/test/blackbox-tests/test-cases/pkg/opam-var/opam-var-global.t +++ b/test/blackbox-tests/test-cases/pkg/opam-var/opam-var-global.t @@ -33,9 +33,10 @@ Therefore we modify the lockfile here to remove these from the opam file: $ mkpkg testpkg << EOF > build: [ - > [ "echo" jobs ] - > [ "echo" group ] + > [ "sh" "-c" "echo %{jobs}% >> cmd-output" ] + > [ "sh" "-c" "echo %{group}% >> cmd-output" ] > ] + > install: [ "cp" "cmd-output" etc ] > EOF > solve testpkg Solution for dune.lock: @@ -43,6 +44,6 @@ Therefore we modify the lockfile here to remove these from the opam file: The value for "jobs" should always be 1. $ GROUP="$(id -gn)" - > build_pkg testpkg 2>&1 | sed "s/$GROUP/GROUP/g" + > build_pkg testpkg && show_pkg_output testpkg| sed "s/$GROUP/GROUP/g" 1 GROUP diff --git a/test/blackbox-tests/test-cases/pkg/opam-var/opam-var-os.t b/test/blackbox-tests/test-cases/pkg/opam-var/opam-var-os.t index fbaf5fdc5a0a..8207cf5ceef9 100644 --- a/test/blackbox-tests/test-cases/pkg/opam-var/opam-var-os.t +++ b/test/blackbox-tests/test-cases/pkg/opam-var/opam-var-os.t @@ -10,12 +10,13 @@ to compare their values. $ mkrepo > mkpkg testpkg < build: [ - > ["echo" arch] - > ["echo" os] - > ["echo" os-distribution] - > ["echo" os-family] - > ["echo" os-version] + > [ "sh" "-c" "echo %{arch}% >> cmd-output" ] + > [ "sh" "-c" "echo %{os}% >> cmd-output"] + > [ "sh" "-c" "echo %{os-distribution}% >> cmd-output"] + > [ "sh" "-c" "echo %{os-family}% >> cmd-output"] + > [ "sh" "-c" "echo %{os-version}% >> cmd-output"] > ] + > install: [ "cp" "cmd-output" etc ] > EOF > solve testpkg Solution for dune.lock: @@ -23,17 +24,20 @@ to compare their values. $ cat dune.lock/testpkg.pkg (version 0.0.1) + (install + (run cp cmd-output %{etc})) + (build (progn - (run echo %{arch}) - (run echo %{os}) - (run echo %{os_distribution}) - (run echo %{os_family}) - (run echo %{os_version}))) + (run sh -c "echo %{arch} >> cmd-output") + (run sh -c "echo %{os} >> cmd-output") + (run sh -c "echo %{os_distribution} >> cmd-output") + (run sh -c "echo %{os_family} >> cmd-output") + (run sh -c "echo %{os_version} >> cmd-output"))) We write all the dune values to a file and then diff them with the output of opam var. - $ build_pkg testpkg 2> dune-vars + $ build_pkg testpkg && show_pkg_output testpkg > dune-vars The two files should be identical. @@ -45,13 +49,14 @@ separately here: $ mkpkg testpkg < build: [ - > ["echo" sys-ocaml-version] + > [ "sh" "-c" "echo %{sys-ocaml-version}% > cmd-output" ] > ] + > install: [ "cp" "cmd-output" etc ] > EOF > solve testpkg Solution for dune.lock: - testpkg.0.0.1 $ ocaml_version="$(ocaml -vnum)" - $ build_pkg testpkg 2>&1 | sed "s/$ocaml_version/OCAML_VERSION/g" + $ build_pkg testpkg && show_pkg_output testpkg | sed "s/$ocaml_version/OCAML_VERSION/g" OCAML_VERSION diff --git a/test/blackbox-tests/test-cases/pkg/opam-var/opam-var-switch.t b/test/blackbox-tests/test-cases/pkg/opam-var/opam-var-switch.t index 79c7e46a2f66..f948aeae3d27 100644 --- a/test/blackbox-tests/test-cases/pkg/opam-var/opam-var-switch.t +++ b/test/blackbox-tests/test-cases/pkg/opam-var/opam-var-switch.t @@ -10,20 +10,21 @@ opam-var-unsupported.t $ mkrepo $ mkpkg testpkg < build: [ - > [ "echo" switch ] - > [ "echo" build ] - > [ "echo" prefix ] - > [ "echo" lib ] - > [ "echo" libexec ] - > [ "echo" bin ] - > [ "echo" sbin ] - > [ "echo" share ] - > [ "echo" doc ] - > [ "echo" etc ] - > [ "echo" man ] - > [ "echo" toplevel ] - > [ "echo" stublibs ] + > [ "sh" "-c" "echo %{switch}% >> cmd-output" ] + > [ "sh" "-c" "echo %{build}% >> cmd-output" ] + > [ "sh" "-c" "echo %{prefix}% >> cmd-output" ] + > [ "sh" "-c" "echo %{lib}% >> cmd-output" ] + > [ "sh" "-c" "echo %{libexec}% >> cmd-output" ] + > [ "sh" "-c" "echo %{bin}% >> cmd-output" ] + > [ "sh" "-c" "echo %{sbin}% >> cmd-output" ] + > [ "sh" "-c" "echo %{share}% >> cmd-output" ] + > [ "sh" "-c" "echo %{doc}% >> cmd-output" ] + > [ "sh" "-c" "echo %{etc}% >> cmd-output" ] + > [ "sh" "-c" "echo %{man}% >> cmd-output" ] + > [ "sh" "-c" "echo %{toplevel}% >> cmd-output" ] + > [ "sh" "-c" "echo %{stublibs}% >> cmd-output" ] > ] + > install: [ "cp" "cmd-output" etc ] > EOF > solve testpkg Solution for dune.lock: @@ -31,23 +32,26 @@ opam-var-unsupported.t $ cat dune.lock/testpkg.pkg (version 0.0.1) + (install + (run cp cmd-output %{etc})) + (build (progn - (run echo %{switch}) - (run echo %{build}) - (run echo %{prefix}) - (run echo %{lib}) - (run echo %{libexec}) - (run echo %{bin}) - (run echo %{sbin}) - (run echo %{share}) - (run echo %{doc}) - (run echo %{etc}) - (run echo %{man}) - (run echo %{toplevel}) - (run echo %{stublibs}))) + (run sh -c "echo %{switch} >> cmd-output") + (run sh -c "echo %{build} >> cmd-output") + (run sh -c "echo %{prefix} >> cmd-output") + (run sh -c "echo %{lib} >> cmd-output") + (run sh -c "echo %{libexec} >> cmd-output") + (run sh -c "echo %{bin} >> cmd-output") + (run sh -c "echo %{sbin} >> cmd-output") + (run sh -c "echo %{share} >> cmd-output") + (run sh -c "echo %{doc} >> cmd-output") + (run sh -c "echo %{etc} >> cmd-output") + (run sh -c "echo %{man} >> cmd-output") + (run sh -c "echo %{toplevel} >> cmd-output") + (run sh -c "echo %{stublibs} >> cmd-output"))) - $ build_pkg testpkg 2>&1 | sed -E 's#.*.sandbox/[^/]+#.sandbox/$SANDBOX#g' + $ build_pkg testpkg && show_pkg_output testpkg | sed -E 's#.*.sandbox/[^/]+#.sandbox/$SANDBOX#g' dune .sandbox/$SANDBOX/_private/default/.pkg/testpkg/source .sandbox/$SANDBOX/_private/default/.pkg/testpkg/target diff --git a/test/blackbox-tests/test-cases/pkg/pin-stanza/update-non-dune-local-pin.t b/test/blackbox-tests/test-cases/pkg/pin-stanza/update-non-dune-local-pin.t index 6fbbecae7bfb..ad245244b6fa 100644 --- a/test/blackbox-tests/test-cases/pkg/pin-stanza/update-non-dune-local-pin.t +++ b/test/blackbox-tests/test-cases/pkg/pin-stanza/update-non-dune-local-pin.t @@ -27,7 +27,7 @@ Make a package "foo" whose build will fail after printing a message: > EOF $ cat >foo/Makefile < all: - > echo aaa + > echo aaa 1>&2 > false > EOF @@ -37,22 +37,30 @@ Make a package "foo" whose build will fail after printing a message: Attempt to build the package the first time: (the error from make is grep'd out because it is not consistant across different systems) - $ dune build 2>&1 | grep -v make - echo aaa + $ dune build + File "dune.lock/foo.pkg", line 4, characters 6-13: + 4 | (run %{make})) + ^^^^^^^ + Error: Logs for package foo aaa - false - -> required by _build/_private/default/.pkg/foo/target/cookie + make: *** [Makefile:3: all] Error 1 + + [1] Update the message that gets printed while building foo: $ cat >foo/Makefile < all: - > echo bbb + > echo bbb 1>&2 > false > EOF The change to the package is picked up: - $ dune build 2>&1 | grep -v make - echo bbb + $ dune build + File "dune.lock/foo.pkg", line 4, characters 6-13: + 4 | (run %{make})) + ^^^^^^^ + Error: Logs for package foo bbb - false - -> required by _build/_private/default/.pkg/foo/target/cookie + make: *** [Makefile:3: all] Error 1 + + [1] diff --git a/test/blackbox-tests/test-cases/pkg/pkg-action-when.t b/test/blackbox-tests/test-cases/pkg/pkg-action-when.t index be76fde8612d..0a8063618635 100644 --- a/test/blackbox-tests/test-cases/pkg/pkg-action-when.t +++ b/test/blackbox-tests/test-cases/pkg/pkg-action-when.t @@ -10,18 +10,19 @@ Case with a mix of uncoditional and conditional actions in a progn action > (install > (progn > (when (= foo foo) - > (run echo a)) + > (run sh -c "echo a >> cmd-output")) > (when (<> foo foo) - > (run echo b)) + > (run sh -c "echo b >> cmd-output")) > (when (<> foo bar) - > (run echo c)) + > (run sh -c "echo c >> cmd-output")) > (when (< 1 2) - > (run echo d)) + > (run sh -c "echo d >> cmd-output")) > (when (< 2 1) - > (run echo e)))) + > (run sh -c "echo e >> cmd-output")) + > (run cp "cmd-output" %{etc}))) > EOF - $ build_pkg test + $ build_pkg test && show_pkg_output test a c d diff --git a/test/blackbox-tests/test-cases/pkg/run-converted-opam-commands.t b/test/blackbox-tests/test-cases/pkg/run-converted-opam-commands.t index 6ba613ae513b..c67155704aaa 100644 --- a/test/blackbox-tests/test-cases/pkg/run-converted-opam-commands.t +++ b/test/blackbox-tests/test-cases/pkg/run-converted-opam-commands.t @@ -8,37 +8,40 @@ Generate a mock opam repository $ mkpkg foo < install: [ - > ["echo" "package: %{name}%.%{version}%"] - > ["echo" "enable: %{enable}%"] - > ["echo" "installed: %{installed}%"] - > ["echo" "string selection: %{installed?foo:bar}%"] - > ["echo" "package conjunction: %{foo+bar+_:installed}%"] - > ["echo" "package conjunction string selection: %{foo+bar+_:installed?foo:bar}%"] + > [ "sh" "-c" "echo package: %{name}%.%{version}% >> cmd-output"] + > [ "sh" "-c" "echo enable: %{enable}% >> cmd-output"] + > [ "sh" "-c" "echo installed: %{installed}% >> cmd-output"] + > [ "sh" "-c" "echo string selection: %{installed?foo:bar}% >> cmd-output"] + > [ "sh" "-c" "echo package conjunction: %{foo+bar+_:installed}% >> cmd-output"] + > [ "sh" "-c" "echo package conjunction string selection: %{foo+bar+_:installed?foo:bar}% >> cmd-output"] + > [ "cp" "cmd-output" etc ] > ] > EOF $ mkpkg bar < install: [ - > ["echo" "installed"] { installed } - > ["echo" "pinned"] { pinned } - > ["echo" "installed or pinned"] { installed | pinned } - > ["echo" "installed and pinned"] { installed & pinned } - > ["echo" "version greater than 0.1 (version is %{version}%)"] { version > "0.1" } - > ["echo" "version greater than 0 (version is %{version}%)"] { version > "0" } - > ["echo" "disjunction with some undefined vars"] { madeup | false | installed | madeup2 } - > ["echo" "conjunction with some undefined vars"] { ! (madeup & false & installed & madeup2) } - > ["echo" "check if variable 'madeup' is defined"] { ? madeup } - > ["echo" "check if variable 'installed' is defined"] { ? installed } + > [ "sh" "-c" "echo installed >> cmd-output" ] { installed } + > [ "sh" "-c" "echo pinned >> cmd-output" ] { pinned } + > [ "sh" "-c" "echo installed or pinned >> cmd-output" ] { installed | pinned } + > [ "sh" "-c" "echo installed and pinned >> cmd-output" ] { installed & pinned } + > [ "sh" "-c" "echo \"version greater than 0.1 (version is %{version}%)\" >> cmd-output" ] { version > "0.1" } + > [ "sh" "-c" "echo \"version greater than 0 (version is %{version}%)\" >> cmd-output" ] { version > "0" } + > [ "sh" "-c" "echo \"disjunction with some undefined vars\" >> cmd-output" ] { madeup | false | installed | madeup2 } + > [ "sh" "-c" "echo \"conjunction with some undefined vars\" >> cmd-output" ] { ! (madeup & false & installed & madeup2) } + > [ "sh" "-c" "echo \"check if variable 'madeup' is defined\" >> cmd-output" ] { ? madeup } + > [ "sh" "-c" "echo \"check if variable 'installed' is defined\" >> cmd-output" ] { ? installed } + > [ "cp" "cmd-output" etc ] > ] > EOF $ mkpkg baz < install: [ - > ["echo" "installed" { installed } "not installed" { ! installed }] - > ["echo" "madeup:installed" { madeup:installed } "not madeup:installed" { ! madeup:installed }] - > ["not-a-program" { ! (2 < 3) } "echo" "hello" ] - > ["echo" "madeup-defined" { ? madeup } "installed-defined" { ? installed } ] + > [ "sh" "-c" "echo \"installed\" >> cmd-output" { installed } "echo \"not installed\" >> cmd-output" { ! installed }] + > [ "sh" "-c" "echo \"madeup:installed\" >> cmd-output" { madeup:installed } "echo \"not madeup:installed\" >> cmd-output" { ! madeup:installed }] + > [ "not-a-program" { ! (2 < 3) } "sh" "-c" "echo \"hello\" >> cmd-output" ] + > [ "sh" "-c" "echo \"madeup-defined\" >> cmd-output" { ? madeup } "echo \"installed-defined\" >> cmd-output" { ? installed } "echo \"\">> cmd-output" ] + > [ "cp" "cmd-output" etc ] > ] > EOF @@ -75,7 +78,7 @@ Generate a mock opam repository > (depends > $1)) > EOF - > build_pkg $1 + > build_pkg $1 && show_pkg_output $1 > } $ build_single_package foo diff --git a/test/blackbox-tests/test-cases/pkg/set-ocamlfind-destdir.t b/test/blackbox-tests/test-cases/pkg/set-ocamlfind-destdir.t index 0bff04916720..97de65fe4ce7 100644 --- a/test/blackbox-tests/test-cases/pkg/set-ocamlfind-destdir.t +++ b/test/blackbox-tests/test-cases/pkg/set-ocamlfind-destdir.t @@ -5,10 +5,14 @@ install and build commands. $ make_lockdir $ cat >dune.lock/test.pkg <<'EOF' > (version 0.0.1) - > (build (run sh -c "echo [build] OCAMLFIND_DESTDIR=$OCAMLFIND_DESTDIR")) - > (install (run sh -c "echo [install] OCAMLFIND_DESTDIR=$OCAMLFIND_DESTDIR")) + > (build (run sh -c "echo [build] OCAMLFIND_DESTDIR=$OCAMLFIND_DESTDIR >> cmd-output")) + > (install + > (progn + > (run sh -c "echo [install] OCAMLFIND_DESTDIR=$OCAMLFIND_DESTDIR >> cmd-output") + > (run cp "cmd-output" %{etc}))) > EOF - $ build_pkg test 2>&1 | sed "s#$(pwd)#PWD#" | sed 's#\.sandbox/.*/_private#\.sandbox/SANDBOX/_private#' + $ build_pkg test && show_pkg_output test | \ + > sed "s#$(pwd)#PWD#" | sed 's#\.sandbox/.*/_private#\.sandbox/SANDBOX/_private#' [build] OCAMLFIND_DESTDIR=PWD/_build/.sandbox/SANDBOX/_private/default/.pkg/test/target/lib [install] OCAMLFIND_DESTDIR=PWD/_build/.sandbox/SANDBOX/_private/default/.pkg/test/target/lib diff --git a/test/blackbox-tests/test-cases/pkg/source-caching.t b/test/blackbox-tests/test-cases/pkg/source-caching.t index f2ed6e11a1d2..d1cd1d510d80 100644 --- a/test/blackbox-tests/test-cases/pkg/source-caching.t +++ b/test/blackbox-tests/test-cases/pkg/source-caching.t @@ -15,7 +15,8 @@ This test demonstratest that fetching package sources should be cached $ makepkg() { > make_lockpkg $1 < (build (run echo building $1)) + > (build (run sh -c "echo building $1 > cmd-output")) + > (install (run cp "cmd-output" %{etc})) > (source > (fetch > (url "http://0.0.0.0:$port") @@ -26,7 +27,7 @@ This test demonstratest that fetching package sources should be cached $ makepkg foo This command is expected to download the source: - $ build_pkg foo + $ build_pkg foo && show_pkg_output foo building foo $ wait @@ -35,5 +36,5 @@ This command is expected to download the source: This command isn't expected to download the source. It will not be available as the server will disappear after serving the first command. - $ build_pkg bar 2>&1 + $ build_pkg bar && show_pkg_output bar building bar diff --git a/test/blackbox-tests/test-cases/pkg/tarball.t b/test/blackbox-tests/test-cases/pkg/tarball.t index 20b313ff2262..361bbd6b68d2 100644 --- a/test/blackbox-tests/test-cases/pkg/tarball.t +++ b/test/blackbox-tests/test-cases/pkg/tarball.t @@ -27,9 +27,10 @@ twice in one test (even on different ports) > make_lockpkg foo < (version 0.1.0) > (source (fetch (url http://0.0.0.0:$port))) - > (build (run sh -c "find . | sort")) + > (build (run sh -c "find . | sort > ../cmd-output")) + > (install (run cp "../cmd-output" %{etc})) > EOF - > build_pkg foo + > build_pkg foo && show_pkg_output foo > rm -rf _build > } $ runtest tarball1.tar.gz