From 90636a368b7c02f55efa4fce37ba58aab9b009ee Mon Sep 17 00:00:00 2001 From: Marek Kubica Date: Wed, 10 Jul 2024 10:31:54 +0200 Subject: [PATCH] test: Exercise the case that there are multiple `extra-sources` (#10708) Signed-off-by: Marek Kubica --- .../test-cases/pkg/extra-sources.t | 63 +++++++++++++++++-- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/test/blackbox-tests/test-cases/pkg/extra-sources.t b/test/blackbox-tests/test-cases/pkg/extra-sources.t index f23fae43b80..9b33c8934b7 100644 --- a/test/blackbox-tests/test-cases/pkg/extra-sources.t +++ b/test/blackbox-tests/test-cases/pkg/extra-sources.t @@ -55,17 +55,24 @@ First we need a project that will have the patch applied: > let msg = "Patch successfully applied" > EOF $ git diff > ../required.patch + $ git add needs_patch.ml + $ git commit -m "First patch" --quiet + $ cat > needs_patch.ml < let msg = "Patch successfully applied, multiple times" + > EOF + $ git diff > ../additional.patch $ cd .. - $ PATCH_MD5=$(md5sum required.patch | cut -f1 -d' ') + $ REQUIRED_PATCH_MD5=$(md5sum required.patch | cut -f1 -d' ') + $ ADDITIONAL_PATCH_MD5=$(md5sum additional.patch | cut -f1 -d' ') Then we start the oneshot server for both the source and the patch. $ webserver_oneshot --content-file needs-patch.tar --port-file tarball-port.txt & $ until test -f tarball-port.txt ; do sleep 0.1; done $ SRC_PORT=$(cat tarball-port.txt) - $ webserver_oneshot --content-file required.patch --port-file patch-port.txt & - $ until test -f patch-port.txt ; do sleep 0.1; done - $ PATCH_PORT=$(cat patch-port.txt) + $ webserver_oneshot --content-file required.patch --port-file required-patch-port.txt & + $ until test -f required-patch-port.txt ; do sleep 0.1; done + $ REQUIRED_PATCH_PORT=$(cat required-patch-port.txt) We now have the checksums as well as the port numbers, so we can define the package. @@ -78,8 +85,8 @@ package. > checksum: "md5=$SRC_MD5" > } > extra-source "required.patch" { - > src: "http://localhost:$PATCH_PORT" - > checksum: "md5=$PATCH_MD5" + > src: "http://localhost:$REQUIRED_PATCH_PORT" + > checksum: "md5=$REQUIRED_PATCH_MD5" > } > EOF @@ -114,3 +121,47 @@ correct, patched, message: - dune.lock/needs-patch.pkg:14 - dune.lock/needs-patch.pkg:8 [1] + +Set up a new version of the package which has multiple `extra-sources`, the +application order of them mattering: + + $ webserver_oneshot --content-file needs-patch.tar --port-file tarball-port.txt & + $ until test -f tarball-port.txt ; do sleep 0.1; done + $ SRC_PORT=$(cat tarball-port.txt) + $ webserver_oneshot --content-file required.patch --port-file required-patch-port.txt & + $ until test -f required-patch-port.txt ; do sleep 0.1; done + $ REQUIRED_PATCH_PORT=$(cat required-patch-port.txt) + $ webserver_oneshot --content-file additional.patch --port-file additional-patch-port.txt & + $ until test -f additional-patch-port.txt ; do sleep 0.1; done + $ ADDITIONAL_PATCH_PORT=$(cat additional-patch-port.txt) + + $ mkpkg needs-patch 0.0.2 < patches: ["required.patch" "additional.patch"] + > url { + > src: "http://localhost:$SRC_PORT" + > checksum: "md5=$SRC_MD5" + > } + > extra-source "required.patch" { + > src: "http://localhost:$REQUIRED_PATCH_PORT" + > checksum: "md5=$REQUIRED_PATCH_MD5" + > } + > extra-source "additional.patch" { + > src: "http://localhost:$ADDITIONAL_PATCH_PORT" + > checksum: "md5=$ADDITIONAL_PATCH_MD5" + > } + > EOF + +Lock the project to use that new package + + $ dune pkg lock + Solution for dune.lock: + - needs-patch.0.0.2 + +Running the binary should work and output the double patched message: + + $ dune exec ./display.exe + Error: Multiple rules generated for + _build/_private/default/.pkg/needs-patch/source: + - dune.lock/needs-patch.pkg:16 + - dune.lock/needs-patch.pkg:20 + [1]