From a0326ba08a8a16b8fbe1d154fc32af81719baf90 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 2 Jun 2026 10:33:31 +0000 Subject: [PATCH] test(cache): share copy rule project fixture Extract the repeated Dune cache test project with a copy rule and source file into a shared blackbox-test helper. Signed-off-by: Rudi Grinberg --- test/blackbox-tests/setup-script.sh | 13 +++++++++++++ test/blackbox-tests/test-cases/dune-cache/config.t | 11 +---------- test/blackbox-tests/test-cases/dune-cache/dedup.t | 11 +---------- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/test/blackbox-tests/setup-script.sh b/test/blackbox-tests/setup-script.sh index 90e7a77e31f..c47209717a0 100644 --- a/test/blackbox-tests/setup-script.sh +++ b/test/blackbox-tests/setup-script.sh @@ -844,6 +844,19 @@ write_cross_compilation_repro_project() { fi } +make_dune_cache_copy_project() { + make_dune_project 2.1 + cat > dune <<-'EOF' + (rule + (deps source) + (targets target) + (action (copy source target))) + EOF + cat > source <<-'EOF' + \_o< COIN + EOF +} + make_two_context_workspace() { local version="${1:-3.13}" local name="${2:-alt-context}" diff --git a/test/blackbox-tests/test-cases/dune-cache/config.t b/test/blackbox-tests/test-cases/dune-cache/config.t index 81f435247ec..823f0627088 100644 --- a/test/blackbox-tests/test-cases/dune-cache/config.t +++ b/test/blackbox-tests/test-cases/dune-cache/config.t @@ -10,16 +10,7 @@ Check that old cache configuration format works fine with an old language > (cache-trim-period 1h) > (cache-trim-size 1GB) > EOF - $ make_dune_project 2.1 - $ cat > dune < (rule - > (deps source) - > (targets target) - > (action (copy source target))) - > EOF - $ cat > source < \_o< COIN - > EOF + $ make_dune_cache_copy_project Test that DUNE_CACHE_ROOT can be used to control the cache location diff --git a/test/blackbox-tests/test-cases/dune-cache/dedup.t b/test/blackbox-tests/test-cases/dune-cache/dedup.t index 750c7935e06..e0d7afe7847 100644 --- a/test/blackbox-tests/test-cases/dune-cache/dedup.t +++ b/test/blackbox-tests/test-cases/dune-cache/dedup.t @@ -3,16 +3,7 @@ Test deduplication of build artifacts when using Dune cache with hard links. $ export DUNE_CACHE=enabled $ export DUNE_CACHE_ROOT=$(dune_cmd native-path $PWD/.cache) - $ make_dune_project 2.1 - $ cat > dune < (rule - > (deps source) - > (targets target) - > (action (copy source target))) - > EOF - $ cat > source < \_o< COIN - > EOF + $ make_dune_cache_copy_project Here we build [target], which is a copy of [source]. After the build, the same file will appear in the build directory twice: (i) as [_build/default/source],