From 2bf184afadfd088156fe865ee6a5926f8d65ac2e Mon Sep 17 00:00:00 2001 From: Ali Caglayan Date: Thu, 13 Nov 2025 22:38:28 +0000 Subject: [PATCH] test(cram): partial promotions when script exits Signed-off-by: Ali Caglayan --- .../cram/partial-promotion-on-error.t | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 test/blackbox-tests/test-cases/cram/partial-promotion-on-error.t diff --git a/test/blackbox-tests/test-cases/cram/partial-promotion-on-error.t b/test/blackbox-tests/test-cases/cram/partial-promotion-on-error.t new file mode 100644 index 00000000000..62dcb299aa9 --- /dev/null +++ b/test/blackbox-tests/test-cases/cram/partial-promotion-on-error.t @@ -0,0 +1,41 @@ +Test that cram tests with unreachable commands can still partially promote +output from commands that executed successfully. + + $ cat > dune-project < (lang dune 3.21) + > EOF + +Create a test with some successful commands, then an exit, then unreachable +commands: + + $ cat > test.t < $ echo "First command" + > $ echo "Second command" + > $ exit 1 + > $ echo "This will never execute" + > $ echo "Neither will this" + > EOF + +The test should fail but still capture output from executed commands: + $ dune runtest + File "test.t", line 1, characters 0-0: + Error: Files _build/default/test.t and _build/default/test.t.corrected + differ. + [1] + $ dune promote + Promoting _build/default/test.t.corrected to test.t. + +After promotion, the test file should have output from successful commands and +UNREACHABLE markers for the rest: + $ cat test.t + $ echo "First command" + First command + $ echo "Second command" + Second command + $ exit 1 + ***** UNREACHABLE ***** + $ echo "This will never execute" + ***** UNREACHABLE ***** + $ echo "Neither will this" + ***** UNREACHABLE ***** +