2023-12-18 14:55:52 +00:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright 2023 Google Inc.
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2024-01-15 10:11:04 +00:00
|
|
|
import {ok} from 'node:assert';
|
2024-01-09 10:49:27 +00:00
|
|
|
import {execSync} from 'node:child_process';
|
2024-01-15 10:11:04 +00:00
|
|
|
import {parseArgs} from 'node:util';
|
2023-12-04 13:55:45 +00:00
|
|
|
|
2023-12-18 14:55:52 +00:00
|
|
|
import {AngularProjectMulti, AngularProjectSingle} from './projects.mjs';
|
2023-12-04 13:55:45 +00:00
|
|
|
|
2024-01-15 10:11:04 +00:00
|
|
|
const {values: args} = parseArgs({
|
|
|
|
options: {
|
|
|
|
testRunner: {
|
|
|
|
type: 'string',
|
|
|
|
short: 't',
|
|
|
|
default: undefined,
|
|
|
|
},
|
|
|
|
name: {
|
|
|
|
type: 'string',
|
|
|
|
short: 'n',
|
|
|
|
default: undefined,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2023-12-04 13:55:45 +00:00
|
|
|
if (process.env.CI) {
|
2023-12-18 14:55:52 +00:00
|
|
|
// Need to install in CI
|
2024-01-09 10:49:27 +00:00
|
|
|
execSync('npm install -g @angular/cli@latest @angular-devkit/schematics-cli');
|
2024-01-15 10:11:04 +00:00
|
|
|
const runners = ['node', 'jest', 'jasmine', 'mocha'];
|
|
|
|
const groups = [];
|
|
|
|
|
|
|
|
for (const runner of runners) {
|
|
|
|
groups.push([
|
|
|
|
new AngularProjectSingle(runner),
|
|
|
|
new AngularProjectMulti(runner),
|
|
|
|
]);
|
|
|
|
}
|
2023-12-04 13:55:45 +00:00
|
|
|
|
2024-01-15 10:11:04 +00:00
|
|
|
const angularProjects = await Promise.allSettled(
|
|
|
|
groups.flat().map(async project => {
|
|
|
|
return await project.create();
|
|
|
|
})
|
|
|
|
);
|
|
|
|
ok(
|
|
|
|
angularProjects.every(project => {
|
|
|
|
return project.status === 'fulfilled';
|
|
|
|
}),
|
|
|
|
'Building of 1 or more projects failed!'
|
|
|
|
);
|
2023-12-04 13:55:45 +00:00
|
|
|
|
2024-01-15 10:11:04 +00:00
|
|
|
for await (const runnerGroup of groups) {
|
|
|
|
const smokeResults = await Promise.allSettled(
|
|
|
|
runnerGroup.map(async project => {
|
|
|
|
return await project.runSmoke();
|
|
|
|
})
|
|
|
|
);
|
|
|
|
ok(
|
|
|
|
smokeResults.every(project => {
|
|
|
|
return project.status === 'fulfilled';
|
|
|
|
}),
|
|
|
|
`Smoke test for ${runnerGroup[0].runner} failed!`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
const single = new AngularProjectSingle(args.testRunner, args.name);
|
|
|
|
const multi = new AngularProjectMulti(args.testRunner, args.name);
|
|
|
|
|
|
|
|
await Promise.all([single.create(), multi.create()]);
|
|
|
|
await Promise.all([single.runSmoke(), multi.runSmoke()]);
|
|
|
|
}
|