Skip to content

Commit 4295428

Browse files
committed
fixup! fixup! ansible: stop promotion if missing assets
1 parent 51b86c9 commit 4295428

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

ansible/www-standalone/tools/promote/check_assets.test.mjs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ async function executeMe (stagingDir, distDir) {
1010
return new Promise((resolve, reject) => {
1111
const args = [ '--no-warnings', join(import.meta.dirname, 'check_assets.js'), stagingDir, distDir ];
1212
execFile(process.execPath, args, (err, stdout, stderr) => {
13-
if (err) {
14-
return reject(err);
15-
}
1613
if (stderr) {
1714
console.log('STDERR:', stderr);
1815
}
19-
resolve(stdout);
16+
// Return both stdout and exit code, even if there's an error
17+
const exitCode = err ? (err.code || 1) : 0;
18+
resolve({ stdout, exitCode });
2019
});
2120
});
2221
}
@@ -86,7 +85,8 @@ const testcases = [
8685
' • node-v10.1.0-linux-armv6l.tar.gz\n' +
8786
' • node-v10.1.0-linux-armv6l.tar.xz\n' +
8887
' • node-v10.1.0.pkg\n' +
89-
'... Canceling the promotion',
88+
'... Canceling the promotion\n',
89+
expectedExitCode: 1,
9090
setup: async function setup (version, fixtureStagingDir, fixtureDistDir) {
9191
await makeFixture(version, true, fixtureStagingDir);
9292
await Promise.all([
@@ -159,11 +159,8 @@ const testcases = [
159159
' • node-v9.9.9-linux-x86.tar.xz\n' +
160160
' • node-v9.9.9-sunos-x86.tar.gz\n' +
161161
' • node-v9.9.9-sunos-x86.tar.xz\n' +
162-
' \u001b[31m\u001b[1m✖\u001b[22m\u001b[39m The following assets were found in staging but are not expected for v9.x:\n' +
163-
' • docs/apilinks.json\n' +
164-
' Does the expected assets list for v9.x need to be updated?\n' +
165-
' https://github.com/nodejs/build/tree/main/ansible/www-standalone/tools/promote/expected_assets/v9.x\n' +
166-
' \u001b[33mPromote if you are certain this is the the correct course of action\u001b[39m\n',
162+
'... Canceling the promotion\n',
163+
expectedExitCode: 1,
167164
setup: async function setup (version, fixtureStagingDir, fixtureDistDir) {
168165
// use the 10.x list, which is missing the x86 files, it'll check the 9.x
169166
const expectedAssets = await loadExpectedAssets(version, 'v10.x');
@@ -303,14 +300,15 @@ describe(`${basename(import.meta.filename, '.test.mjs')} tests`, async () => {
303300
afterEach(async (context) => {
304301
await rm(context.testDir, { recursive: true, force: true, maxRetries: 10 });
305302
});
306-
for (const { name, version, expectedStdout, setup } of testcases) {
303+
for (const { name, version, expectedStdout, expectedExitCode = 0, setup } of testcases) {
307304
it(name, async (context) => {
308305
const fixtureStagingDir = join(context.fixtureStagingDir, version);
309306
const fixtureDistDir = join(context.fixtureDistDir, version);
310307
await setup(version, fixtureStagingDir, fixtureDistDir);
311308

312-
const stdout = await executeMe(fixtureStagingDir, fixtureDistDir);
309+
const { stdout, exitCode } = await executeMe(fixtureStagingDir, fixtureDistDir);
313310
assert.strictEqual(stdout, expectedStdout);
311+
assert.strictEqual(exitCode, expectedExitCode);
314312
});
315313
}
316314
});

0 commit comments

Comments
 (0)