From b7c2f8060497384df0af4f756c5b66f7d9e83f7b Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 24 Aug 2026 14:30:03 +0700 Subject: test: quote the probe script's shell assignments The extras-block probe wrote BUILD_SELECT_FILE and MATRIX_JSON by raw string concatenation, so a TMPDIR containing a space split the assignment and failed the test for a reason with nothing to do with the block under test. Reproduced with TMPDIR="/tmp/has space": test_a_real_family_list_stays_scoped fails before the fix and passes after, and the whole suite is green under both. Found by Copilot on #3845. --- test/hil/test/test_ci_metrics.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/hil/test/test_ci_metrics.py b/test/hil/test/test_ci_metrics.py index fb1019b56..7f715e48e 100644 --- a/test/hil/test/test_ci_metrics.py +++ b/test/hil/test/test_ci_metrics.py @@ -450,7 +450,7 @@ class TestWorkflowSelectionHandOff(unittest.TestCase): def _run_extras_block(self, sel): """Extract the build-extras shell block from build.yml and run it for real. Nothing else exercises it, which is why the empty/rejected conflation shipped.""" - import re as _re, subprocess, tempfile, json as _json + import re as _re, shlex, subprocess, tempfile, json as _json repo = os.path.dirname(CIRCLECI) i = self.build.index("EXAMPLE_MAP='{}'\n BUILD_FILTERED='false'") i = self.build.rindex('\n', 0, i) + 1 @@ -466,8 +466,10 @@ class TestWorkflowSelectionHandOff(unittest.TestCase): self.assertTrue(matrix, 'ci_set_matrix produced nothing') sh = os.path.join(d, 'probe.sh') with open(sh, 'w') as fh: - fh.write('BUILD_SELECT_FILE=' + selp + '\n') - fh.write("MATRIX_JSON='" + matrix + "'\n") + # shlex.quote, not hand-rolled quoting: a TMPDIR with a space in it + # made this fail for a reason that had nothing to do with the block + fh.write('BUILD_SELECT_FILE=' + shlex.quote(selp) + '\n') + fh.write('MATRIX_JSON=' + shlex.quote(matrix) + '\n') fh.write(block) # sentinel + newline separated: the block itself writes ::warning:: to # stdout, and '|' would collide with the regex's own separator -- cgit v1.3.1