Skip to content

Commit 8993ee5

Browse files
committed
tests: partitioning: Verify run action postprocess cwd
Extend the partitioning test to enforce the expected working directory behaviour for postprocess actions. When a recipe is executed with an explicit --artifactdir, postprocess run actions should execute with: * cwd == $ARTIFACTDIR * $ARTIFACTDIR != $RECIPEDIR The test now checks all three conditions: * test.img exists in the current directory, * the working directory is $ARTIFACTDIR, * that $ARTIFACTDIR is different from $RECIPEDIR. This ensures correct isolation between recipe sources and build artifacts and catches regressions where postprocess commands incorrectly inherit the recipe directory as their working directory. Signed-off-by: Christopher Obbard <[email protected]>
1 parent 8d90b84 commit 8993ee5

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ jobs:
197197
test:
198198
- { name: "recipes", case: "recipes" }
199199
- { name: "templating", case: "templating", variables: " -t escaped:\\$ba\\'d\\$gers\\ snakes" }
200-
- { name: "partitioning", case: "partitioning" }
200+
- { name: "partitioning", case: "partitioning", variables: "--artifactdir=/scratch" }
201201
- { name: "msdos partitioning", case: "msdos" }
202202
- { name: "debian (amd64, debootstrap)", case: "debian", variables: "-t architecture:amd64" }
203203
- { name: "debian (amd64, mmdebstrap)", case: "debian", variables: "-t architecture:amd64 -t tool:mmdebstrap" }

tests/partitioning/test.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,19 @@ actions:
6060
bash -c 'diff -u \
6161
<(jq "del(.partitiontable.partitions[].uuid)" "${RECIPEDIR}/expected.json") \
6262
<(jq "del(.partitiontable.partitions[].uuid)" "${RECIPEDIR}/actual.json")'
63+
64+
# Verify that postprocess commands have cwd set to artifact directory
65+
# by ensuring:
66+
# - test.img exists in the current directory,
67+
# - the working directory is $ARTIFACTDIR,
68+
# - that $ARTIFACTDIR is different from $RECIPEDIR.
69+
#
70+
# This test is run with --artifactdir=/scratch so the artifact directory
71+
# is different from the recipe directory.
72+
- action: run
73+
postprocess: true
74+
description: Verify postprocess cwd is artifact directory
75+
command: |
76+
test -f test.img
77+
test "${ARTIFACTDIR}" = "$(pwd)"
78+
test "${ARTIFACTDIR}" != "${RECIPEDIR}"

0 commit comments

Comments
 (0)