Skip to content

Commit fb49d11

Browse files
committed
test(ci): cover the single-cache matrix cardinality (#2036 review)
Reduced coverage to 0-cached and 2-cached, leaving the 1-cached cardinality unchecked -- a mistaken \`length > 1\` in the has-work check would pass while wrongly suppressing a valid single-platform build. Generalize the Node stub to report caching per artifact-name suffix and add the iOS-cached case to the same reused harness.
1 parent 9eaea0b commit fb49d11

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

test/ci/trusted-fixture-artifact.test.mjs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,17 +334,22 @@ test('producer maps each platform to its resolved lookup and matrix artifact nam
334334
'',
335335
].join('\n'),
336336
);
337-
const writeNodeStub = (cached) =>
337+
// cachedPlatforms: which platform artifact-name suffixes (".ios", ".android")
338+
// the lookup should report as already cached.
339+
const writeNodeStub = (cachedPlatforms) =>
338340
fs.writeFileSync(
339341
path.join(binDir, 'node'),
340342
[
341343
'#!/bin/sh',
342344
'printf "%s\\n" "$*" >> "$TEST_NODE_LOG"',
343-
cached ? 'printf "111"' : 'true',
345+
'case "$4" in',
346+
...cachedPlatforms.map((platform) => ` *.${platform}) printf "111" ;;`),
347+
' *) true ;;',
348+
'esac',
344349
'',
345350
].join('\n'),
346351
);
347-
writeNodeStub(false);
352+
writeNodeStub([]);
348353
fs.chmodSync(path.join(binDir, 'node'), 0o755);
349354

350355
const run = fingerprintStep.run
@@ -388,7 +393,17 @@ test('producer maps each platform to its resolved lookup and matrix artifact nam
388393
'.github/actions/setup-fixture-app/trusted-artifact.mjs find octo/repo fingerprint.android-hash.android current-head',
389394
]);
390395

391-
writeNodeStub(true);
396+
// A mistaken `length > 1` in the has-work check would pass here while
397+
// wrongly suppressing this valid single-platform build.
398+
writeNodeStub(['ios']);
399+
const iosCached = runFingerprint('output-ios-cached');
400+
assert.deepEqual(
401+
iosCached.matrix.include.map(({ platform }) => platform),
402+
['android'],
403+
);
404+
assert.equal(iosCached.hasWork, 'has-work=true');
405+
406+
writeNodeStub(['ios', 'android']);
392407
const bothCached = runFingerprint('output-both-cached');
393408
assert.deepEqual(bothCached.matrix, { include: [] });
394409
assert.equal(bothCached.hasWork, 'has-work=false');

0 commit comments

Comments
 (0)