2021-07-22 13:37:34 +00:00
|
|
|
import path from 'canonical-path';
|
|
|
|
|
import {spawn} from 'cross-spawn';
|
|
|
|
|
import fs from 'fs-extra';
|
2023-03-02 16:11:07 +00:00
|
|
|
import getPort from 'get-port';
|
2022-08-11 19:01:31 +00:00
|
|
|
import {globbySync} from 'globby';
|
2022-07-06 23:16:50 +00:00
|
|
|
import os from 'os';
|
2021-07-22 13:37:34 +00:00
|
|
|
import shelljs from 'shelljs';
|
|
|
|
|
import treeKill from 'tree-kill';
|
|
|
|
|
import yargs from 'yargs';
|
|
|
|
|
import {hideBin} from 'yargs/helpers'
|
2023-03-02 16:11:07 +00:00
|
|
|
|
|
|
|
|
import {getAdjustedChromeBinPathForWindows} from '../windows-chromium-path.js';
|
|
|
|
|
|
|
|
|
|
import {constructExampleSandbox} from './example-sandbox.mjs';
|
2017-10-06 13:48:37 +00:00
|
|
|
|
|
|
|
|
shelljs.set('-e');
|
2017-04-13 21:35:13 +00:00
|
|
|
|
2022-10-06 19:19:19 +00:00
|
|
|
process.env.CHROME_BIN = getAdjustedChromeBinPathForWindows();
|
2022-07-06 23:16:50 +00:00
|
|
|
|
|
|
|
|
// Resolve CHROME_BIN and CHROMEDRIVER_BIN from relative paths to absolute paths within the
|
|
|
|
|
// runfiles tree so that subprocesses spawned in a different working directory can still find them.
|
|
|
|
|
process.env.CHROME_BIN = path.resolve(process.env.CHROME_BIN);
|
|
|
|
|
process.env.CHROMEDRIVER_BIN = path.resolve(process.env.CHROMEDRIVER_BIN);
|
2021-07-22 13:37:34 +00:00
|
|
|
|
2023-03-02 16:11:07 +00:00
|
|
|
const {argv} =
|
|
|
|
|
yargs(hideBin(process.argv))
|
|
|
|
|
.command('* <examplePath> <yarnPath> <exampleDepsWorkspaceName>')
|
|
|
|
|
.option('localPackage', {
|
|
|
|
|
array: true,
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: [],
|
|
|
|
|
describe: 'Locally built package to substitute, in the form `packageName#packagePath`'
|
|
|
|
|
})
|
|
|
|
|
.version(false)
|
|
|
|
|
.strict();
|
2020-03-23 15:31:55 +00:00
|
|
|
|
2022-09-29 18:24:32 +00:00
|
|
|
const EXAMPLE_PATH = path.resolve(argv.examplePath);
|
2022-07-06 23:16:50 +00:00
|
|
|
const NODE = process.execPath;
|
2022-09-29 18:24:32 +00:00
|
|
|
const VENDORED_YARN = path.resolve(argv.yarnPath);
|
|
|
|
|
const EXAMPLE_DEPS_WORKSPACE_NAME = argv.exampleDepsWorkspaceName;
|
|
|
|
|
const LOCAL_PACKAGES = argv.localPackage.reduce((pkgs, pkgNameAndPath) => {
|
2022-08-11 19:01:31 +00:00
|
|
|
const [pkgName, pkgPath] = pkgNameAndPath.split('#');
|
|
|
|
|
pkgs[pkgName] = path.resolve(pkgPath);
|
|
|
|
|
return pkgs;
|
|
|
|
|
}, {});
|
|
|
|
|
|
2017-08-22 19:31:15 +00:00
|
|
|
const SJS_SPEC_FILENAME = 'e2e-spec.ts';
|
2018-04-13 02:20:01 +00:00
|
|
|
const CLI_SPEC_FILENAME = 'e2e/src/app.e2e-spec.ts';
|
2017-04-13 21:35:13 +00:00
|
|
|
const EXAMPLE_CONFIG_FILENAME = 'example-config.json';
|
test(docs-infra): improve debugging when docs example tests fail without exiting (#43683)
When the docs examples tests run with `--cliSpecsConcurrency` greater
than 1 (as happens on CI), the output of each process is [buffered][1]
(to avoid interleaved output from multiple, parallel processes) and is
only printed out once the process exits (either successfully or with an
error). However, in cases where a process did not exit, the buffered
output would be never printed out, thus making debugging the failure
harder. This is the case, for example, if a build error happens during
`ng e2e`. This can be seen in action in [this CI job][2], where the job
fails due to no output, but the error (which is an incompatible TS
version) is never printed out.
To make debugging such situations easier in the future, this commit
updates the `spawnExt()` helper to reject (causing the buffered output
to be printed out) if there is no output from the spawned process for
more than 5 minutes.
[1]: https://github.com/angular/angular/blob/c721135e370b34c840756bcfb22c8119b4c8c452/aio/tools/examples/run-example-e2e.mjs#L293
[2]: https://circleci.com/gh/angular/angular/1061751
PR Close #43683
2021-10-05 17:14:39 +00:00
|
|
|
const MAX_NO_OUTPUT_TIMEOUT = 1000 * 60 * 5; // 5 minutes
|
2019-02-05 21:20:05 +00:00
|
|
|
|
2017-04-13 21:35:13 +00:00
|
|
|
/**
|
2022-08-11 19:01:31 +00:00
|
|
|
* Run Protractor End-to-End Tests for a Docs Example
|
|
|
|
|
*
|
2023-03-02 16:11:07 +00:00
|
|
|
* Usage: node run-example-e2e.mjs <examplePath> <yarnPath> <exampleDepsWorkspaceName>
|
|
|
|
|
* [localPackage...]
|
2022-08-11 19:01:31 +00:00
|
|
|
*
|
|
|
|
|
* Args:
|
|
|
|
|
* examplePath: path to the example
|
|
|
|
|
* yarnPath: path to a vendored version of yarn
|
|
|
|
|
* exampleDepsWorkspaceName: name of bazel workspace containing example node_omodules
|
2023-03-02 16:11:07 +00:00
|
|
|
* localPackages: a vararg of local packages to substitute in place npm deps, in the
|
|
|
|
|
* form @package/name#pathToPackage.
|
2017-04-13 21:35:13 +00:00
|
|
|
*
|
|
|
|
|
* Flags
|
2019-09-05 15:55:40 +00:00
|
|
|
* --retry to retry failed tests (useful for overcoming flakes)
|
|
|
|
|
* e.g. --retry 3 // To try each test up to 3 times.
|
2017-04-13 21:35:13 +00:00
|
|
|
*/
|
2022-08-11 19:01:31 +00:00
|
|
|
|
|
|
|
|
async function runE2e(examplePath) {
|
2022-07-06 23:16:50 +00:00
|
|
|
const exampleName = path.basename(examplePath);
|
|
|
|
|
const maxAttempts = argv.retry || 1;
|
2022-09-29 18:24:32 +00:00
|
|
|
const exampleTestPath = generatePathForExampleTest(exampleName);
|
|
|
|
|
|
2023-03-03 15:05:02 +00:00
|
|
|
console.info('Running example tests in directory: ', exampleTestPath)
|
|
|
|
|
|
2022-07-06 23:16:50 +00:00
|
|
|
try {
|
2023-03-02 16:11:07 +00:00
|
|
|
await constructExampleSandbox(
|
|
|
|
|
examplePath, exampleTestPath,
|
|
|
|
|
path.resolve('..', EXAMPLE_DEPS_WORKSPACE_NAME, 'node_modules'), LOCAL_PACKAGES);
|
2022-09-29 18:24:32 +00:00
|
|
|
|
2022-07-06 23:16:50 +00:00
|
|
|
let testFn;
|
2022-09-29 18:24:32 +00:00
|
|
|
if (isSystemJsTest(exampleTestPath)) {
|
|
|
|
|
testFn = () => runE2eTestsSystemJS(exampleName, exampleTestPath);
|
|
|
|
|
} else if (isCliTest(exampleTestPath)) {
|
|
|
|
|
testFn = () => runE2eTestsCLI(exampleName, exampleTestPath);
|
2022-07-06 23:16:50 +00:00
|
|
|
} else {
|
|
|
|
|
throw new Error(`Unknown e2e test type for example ${exampleName}`);
|
|
|
|
|
}
|
2023-03-02 16:11:07 +00:00
|
|
|
|
2022-07-06 23:16:50 +00:00
|
|
|
await attempt(testFn, maxAttempts);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error(e);
|
|
|
|
|
process.exitCode = 1;
|
|
|
|
|
} finally {
|
2022-09-29 18:24:32 +00:00
|
|
|
fs.rmSync(exampleTestPath, {recursive: true, force: true});
|
2017-09-28 16:29:04 +00:00
|
|
|
}
|
2022-07-06 23:16:50 +00:00
|
|
|
}
|
2017-04-13 21:35:13 +00:00
|
|
|
|
2022-07-06 23:16:50 +00:00
|
|
|
async function attempt(testFn, maxAttempts) {
|
|
|
|
|
let attempts = 0;
|
|
|
|
|
let passed = false;
|
2017-04-13 21:35:13 +00:00
|
|
|
|
2022-07-06 23:16:50 +00:00
|
|
|
while (true) {
|
|
|
|
|
attempts++;
|
2023-03-02 16:42:57 +00:00
|
|
|
passed = true;
|
|
|
|
|
try {
|
|
|
|
|
await testFn();
|
|
|
|
|
} catch (e) {
|
|
|
|
|
passed = false;
|
|
|
|
|
}
|
2017-04-13 21:35:13 +00:00
|
|
|
|
2022-07-06 23:16:50 +00:00
|
|
|
if (passed || (attempts >= maxAttempts)) break;
|
|
|
|
|
}
|
2019-09-05 15:55:40 +00:00
|
|
|
|
2022-07-06 23:16:50 +00:00
|
|
|
if (!passed) {
|
|
|
|
|
throw new Error('Test failed');
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-04 19:33:25 +00:00
|
|
|
|
2022-09-29 18:24:32 +00:00
|
|
|
function generatePathForExampleTest(exampleName) {
|
2022-07-06 23:16:50 +00:00
|
|
|
// Note that bazel provides a writeable tmp dir for tests in the env var TEST_TMPDIR,
|
|
|
|
|
// however we do not use it here as in non-sandboxed mode the temp dir sits under the
|
|
|
|
|
// execroot, so yarn will find the .yarnrc in the root of the workspace. If there is ever
|
|
|
|
|
// a version mismatch (e.g., if we use multiple vendored yarn versions) then this could
|
|
|
|
|
// cause subtle errors. Instead, just use a temp dir that bazel doesn't know about.
|
2022-09-29 18:24:32 +00:00
|
|
|
return fs.mkdtempSync(`${os.tmpdir()}${path.sep}${exampleName}-`)
|
2022-07-06 23:16:50 +00:00
|
|
|
}
|
2017-08-22 19:31:15 +00:00
|
|
|
|
2022-07-06 23:16:50 +00:00
|
|
|
function isSystemJsTest(examplePath) {
|
|
|
|
|
return fs.existsSync(path.join(examplePath, SJS_SPEC_FILENAME));
|
|
|
|
|
}
|
2019-02-05 21:20:05 +00:00
|
|
|
|
2022-07-06 23:16:50 +00:00
|
|
|
function isCliTest(examplePath) {
|
|
|
|
|
return fs.existsSync(path.join(examplePath, CLI_SPEC_FILENAME));
|
2017-04-13 21:35:13 +00:00
|
|
|
}
|
|
|
|
|
|
2022-08-25 02:35:36 +00:00
|
|
|
async function runE2eTestsSystemJS(exampleName, appDir) {
|
2017-04-13 21:35:13 +00:00
|
|
|
const config = loadExampleConfig(appDir);
|
|
|
|
|
|
2022-08-25 02:35:36 +00:00
|
|
|
const runArgs = await overrideSystemJsExampleToUseRandomPort(config, appDir);
|
|
|
|
|
|
2022-07-06 23:16:50 +00:00
|
|
|
const appBuildSpawnInfo = spawnExt(NODE, [VENDORED_YARN, config.build], {cwd: appDir});
|
2022-08-25 02:35:36 +00:00
|
|
|
const appRunSpawnInfo = spawnExt(NODE, [VENDORED_YARN, ...runArgs, '-s'], {cwd: appDir}, true);
|
2017-04-13 21:35:13 +00:00
|
|
|
|
2023-03-02 16:42:57 +00:00
|
|
|
try {
|
|
|
|
|
await runProtractorSystemJS(exampleName, appBuildSpawnInfo.promise, appDir);
|
|
|
|
|
} finally {
|
|
|
|
|
treeKill(appRunSpawnInfo.proc.pid);
|
|
|
|
|
}
|
2021-04-16 12:57:26 +00:00
|
|
|
|
|
|
|
|
if (fs.existsSync(appDir + '/aot/index.html')) {
|
2023-03-02 16:42:57 +00:00
|
|
|
await runProtractorAoT(exampleName, appDir);
|
2021-04-16 12:57:26 +00:00
|
|
|
}
|
2017-04-13 21:35:13 +00:00
|
|
|
}
|
|
|
|
|
|
2022-08-25 02:35:36 +00:00
|
|
|
// The SystemJS examples spawn an http server and protractor using a hardcoded
|
|
|
|
|
// port. In order to run these tests concurrently under bazel without contention,
|
|
|
|
|
// we need to dynamically acquire a port and overwrite configuration to use that port.
|
|
|
|
|
// This is further complicated by the SystemJS tests using two different http servers
|
|
|
|
|
// (http-server, lite-server) depending on the example (and sometimes both),
|
|
|
|
|
// and the two servers need to be configured differently.
|
|
|
|
|
async function overrideSystemJsExampleToUseRandomPort(exampleConfig, exampleDir) {
|
|
|
|
|
const freePort = await getPort();
|
|
|
|
|
let runArgs = [exampleConfig.run];
|
|
|
|
|
|
|
|
|
|
const isUsingHttpServerLibrary = exampleConfig.run === 'serve:upgrade';
|
|
|
|
|
if (isUsingHttpServerLibrary) {
|
|
|
|
|
// Override the port in http-server by passing as an argument
|
2023-03-02 16:11:07 +00:00
|
|
|
runArgs = [...runArgs, '-p', freePort];
|
2022-08-25 02:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Override the port in any lite-server config files
|
|
|
|
|
const liteServerConfigs = globbySync(['bs-config*.json'], {cwd: exampleDir});
|
|
|
|
|
liteServerConfigs.forEach(configFile => {
|
|
|
|
|
const config = JSON.parse(fs.readFileSync(path.join(exampleDir, configFile), 'utf8'));
|
|
|
|
|
if (config.port) {
|
|
|
|
|
config.port = freePort;
|
|
|
|
|
fs.writeFileSync(path.join(exampleDir, configFile), JSON.stringify(config));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Override hardcoded port in protractor.config.js
|
|
|
|
|
let protractorConfig = fs.readFileSync(path.join(exampleDir, 'protractor.config.js'), 'utf8');
|
2023-03-02 16:11:07 +00:00
|
|
|
protractorConfig =
|
|
|
|
|
protractorConfig.replaceAll('http://localhost:8080', `http://localhost:${freePort}`);
|
2022-08-25 02:35:36 +00:00
|
|
|
fs.writeFileSync(path.join(exampleDir, 'protractor.config.js'), protractorConfig);
|
|
|
|
|
|
|
|
|
|
return runArgs;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-02 16:42:57 +00:00
|
|
|
async function runProtractorSystemJS(exampleName, prepPromise, appDir) {
|
|
|
|
|
await prepPromise;
|
2017-04-13 21:35:13 +00:00
|
|
|
|
2023-03-02 16:42:57 +00:00
|
|
|
// Wait for the app to be running. Then we can start Protractor tests.
|
|
|
|
|
console.log(`\n\n=========== Running aio example tests for: ${exampleName}`);
|
|
|
|
|
await spawnExt(NODE, [VENDORED_YARN, 'protractor'], {cwd: appDir}).promise;
|
2017-04-13 21:35:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Run e2e tests over the AOT build for projects that examples it.
|
2023-03-02 16:42:57 +00:00
|
|
|
async function runProtractorAoT(exampleName, appDir) {
|
2022-07-06 23:16:50 +00:00
|
|
|
const aotBuildSpawnInfo = spawnExt(NODE, [VENDORED_YARN, 'build:aot'], {cwd: appDir});
|
2017-04-13 21:35:13 +00:00
|
|
|
let promise = aotBuildSpawnInfo.promise;
|
|
|
|
|
|
|
|
|
|
const copyFileCmd = 'copy-dist-files.js';
|
|
|
|
|
if (fs.existsSync(appDir + '/' + copyFileCmd)) {
|
2019-02-05 21:20:05 +00:00
|
|
|
promise = promise.then(() => spawnExt('node', [copyFileCmd], {cwd: appDir}).promise);
|
2017-04-13 21:35:13 +00:00
|
|
|
}
|
2023-03-02 16:42:57 +00:00
|
|
|
|
|
|
|
|
// Run the server in the background. Will be killed upon test completion.
|
2022-07-06 23:16:50 +00:00
|
|
|
const aotRunSpawnInfo = spawnExt(NODE, [VENDORED_YARN, 'serve:aot'], {cwd: appDir}, true);
|
2023-03-02 16:42:57 +00:00
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await runProtractorSystemJS(exampleName, promise, appDir);
|
|
|
|
|
} finally {
|
|
|
|
|
treeKill(aotRunSpawnInfo.proc.pid);
|
|
|
|
|
}
|
2022-07-06 23:16:50 +00:00
|
|
|
}
|
|
|
|
|
|
2017-08-22 19:31:15 +00:00
|
|
|
// Start the example in appDir; then run protractor with the specified
|
|
|
|
|
// fileName; then shut down the example.
|
|
|
|
|
// All protractor output is appended to the outputFile.
|
|
|
|
|
// CLI version
|
2023-03-02 16:42:57 +00:00
|
|
|
async function runE2eTestsCLI(exampleName, appDir) {
|
2022-07-06 23:16:50 +00:00
|
|
|
console.log(`\n\n=========== Running aio example tests for: ${exampleName}`);
|
|
|
|
|
|
|
|
|
|
const config = loadExampleConfig(appDir);
|
|
|
|
|
|
2023-03-02 16:11:07 +00:00
|
|
|
// Replace any calls with yarn (which requires yarn to be on the PATH) to instead call our
|
|
|
|
|
// vendored yarn
|
2022-07-06 23:16:50 +00:00
|
|
|
if (config.tests) {
|
|
|
|
|
for (let test of config.tests) {
|
|
|
|
|
if (test.cmd === 'yarn') {
|
|
|
|
|
test.cmd = NODE;
|
|
|
|
|
test.args = [VENDORED_YARN, ...test.args];
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-04 19:33:25 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-11 14:27:29 +00:00
|
|
|
// `--no-webdriver-update` is needed to preserve the ChromeDriver version already installed.
|
2020-03-23 15:31:56 +00:00
|
|
|
const testCommands = config.tests || [{
|
2023-03-02 16:11:07 +00:00
|
|
|
cmd: NODE,
|
2020-05-04 23:27:39 +00:00
|
|
|
args: [
|
2023-03-02 16:11:07 +00:00
|
|
|
VENDORED_YARN,
|
2020-05-04 23:27:39 +00:00
|
|
|
'e2e',
|
2021-07-24 09:03:46 +00:00
|
|
|
'--configuration=production',
|
2022-07-06 23:16:50 +00:00
|
|
|
'--protractor-config=e2e/protractor-bazel.conf.js',
|
2020-05-04 23:27:39 +00:00
|
|
|
'--no-webdriver-update',
|
2022-07-06 23:16:50 +00:00
|
|
|
'--port=0',
|
2020-05-04 23:27:39 +00:00
|
|
|
],
|
|
|
|
|
}];
|
2019-01-10 20:14:04 +00:00
|
|
|
|
2023-03-02 16:42:57 +00:00
|
|
|
|
|
|
|
|
for (const {cmd, args} of testCommands) {
|
|
|
|
|
await spawnExt(cmd, args, {cwd: appDir}, false).promise;
|
|
|
|
|
}
|
2017-04-13 21:35:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Returns both a promise and the spawned process so that it can be killed if needed.
|
2020-05-04 23:27:39 +00:00
|
|
|
function spawnExt(
|
2023-03-02 16:11:07 +00:00
|
|
|
command, args, options, ignoreClose = false,
|
|
|
|
|
printMessageFn = msg => process.stdout.write(msg)) {
|
2021-10-05 17:14:39 +00:00
|
|
|
let proc = null;
|
test(docs-infra): improve debugging when docs example tests fail without exiting (#43683)
When the docs examples tests run with `--cliSpecsConcurrency` greater
than 1 (as happens on CI), the output of each process is [buffered][1]
(to avoid interleaved output from multiple, parallel processes) and is
only printed out once the process exits (either successfully or with an
error). However, in cases where a process did not exit, the buffered
output would be never printed out, thus making debugging the failure
harder. This is the case, for example, if a build error happens during
`ng e2e`. This can be seen in action in [this CI job][2], where the job
fails due to no output, but the error (which is an incompatible TS
version) is never printed out.
To make debugging such situations easier in the future, this commit
updates the `spawnExt()` helper to reject (causing the buffered output
to be printed out) if there is no output from the spawned process for
more than 5 minutes.
[1]: https://github.com/angular/angular/blob/c721135e370b34c840756bcfb22c8119b4c8c452/aio/tools/examples/run-example-e2e.mjs#L293
[2]: https://circleci.com/gh/angular/angular/1061751
PR Close #43683
2021-10-05 17:14:39 +00:00
|
|
|
const promise = new Promise((resolveFn, rejectFn) => {
|
|
|
|
|
let noOutputTimeoutId;
|
|
|
|
|
const failDueToNoOutput = () => {
|
|
|
|
|
treeKill(proc.id);
|
|
|
|
|
reject(`No output after ${MAX_NO_OUTPUT_TIMEOUT}ms.`);
|
|
|
|
|
};
|
|
|
|
|
const printMessage = msg => {
|
|
|
|
|
clearTimeout(noOutputTimeoutId);
|
|
|
|
|
noOutputTimeoutId = setTimeout(failDueToNoOutput, MAX_NO_OUTPUT_TIMEOUT);
|
|
|
|
|
return printMessageFn(msg);
|
|
|
|
|
};
|
|
|
|
|
const resolve = val => {
|
|
|
|
|
clearTimeout(noOutputTimeoutId);
|
|
|
|
|
resolveFn(val);
|
|
|
|
|
};
|
|
|
|
|
const reject = err => {
|
|
|
|
|
clearTimeout(noOutputTimeoutId);
|
|
|
|
|
rejectFn(err);
|
|
|
|
|
};
|
|
|
|
|
|
2017-09-28 16:29:04 +00:00
|
|
|
let descr = command + ' ' + args.join(' ');
|
2019-03-04 19:33:25 +00:00
|
|
|
printMessage(`running: ${descr}\n`);
|
2017-04-13 21:35:13 +00:00
|
|
|
try {
|
2023-03-03 15:05:02 +00:00
|
|
|
proc = spawn(command, args, {
|
|
|
|
|
// All NodeJS scripts executed for running example e2e tests should preserve symlinks.
|
|
|
|
|
// This is important as otherwise test commands like `yarn ng build` would escape from the
|
|
|
|
|
// example sandbox into the `bazel-bin` where ultimately incorrect versions of local
|
|
|
|
|
// framework packages might be resolved. e.g. the `@angular/compiler-cli` version is never
|
|
|
|
|
// the one locally built.
|
|
|
|
|
env: {...process.env, NODE_PRESERVE_SYMLINKS: '1'},
|
|
|
|
|
...options
|
|
|
|
|
});
|
2017-04-13 21:35:13 +00:00
|
|
|
} catch (e) {
|
|
|
|
|
console.log(e);
|
2021-10-05 17:14:39 +00:00
|
|
|
return reject(e);
|
2017-04-13 21:35:13 +00:00
|
|
|
}
|
2019-03-04 19:33:25 +00:00
|
|
|
proc.stdout.on('data', printMessage);
|
|
|
|
|
proc.stderr.on('data', printMessage);
|
|
|
|
|
|
2019-02-05 21:20:05 +00:00
|
|
|
proc.on('close', function(returnCode) {
|
2019-03-04 19:33:25 +00:00
|
|
|
printMessage(`completed: ${descr}\n\n`);
|
2017-04-13 21:35:13 +00:00
|
|
|
// Many tasks (e.g., tsc) complete but are actually errors;
|
|
|
|
|
// Confirm return code is zero.
|
|
|
|
|
returnCode === 0 || ignoreClose ? resolve(0) : reject(returnCode);
|
|
|
|
|
});
|
2019-02-05 21:20:05 +00:00
|
|
|
proc.on('error', function(data) {
|
2019-03-04 19:33:25 +00:00
|
|
|
printMessage(`completed with error: ${descr}\n\n`);
|
|
|
|
|
printMessage(`${data.toString()}\n`);
|
2017-04-13 21:35:13 +00:00
|
|
|
reject(data);
|
|
|
|
|
});
|
|
|
|
|
});
|
2019-02-05 21:20:05 +00:00
|
|
|
return {proc, promise};
|
2017-04-13 21:35:13 +00:00
|
|
|
}
|
|
|
|
|
|
2017-08-22 19:31:15 +00:00
|
|
|
// Load configuration for an example. Used for SystemJS
|
2017-04-13 21:35:13 +00:00
|
|
|
function loadExampleConfig(exampleFolder) {
|
|
|
|
|
// Default config.
|
2019-02-05 21:20:05 +00:00
|
|
|
let config = {build: 'build', run: 'serve:e2e'};
|
2017-04-13 21:35:13 +00:00
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const exampleConfig = fs.readJsonSync(`${exampleFolder}/${EXAMPLE_CONFIG_FILENAME}`);
|
|
|
|
|
Object.assign(config, exampleConfig);
|
2019-02-05 21:20:05 +00:00
|
|
|
} catch (e) {
|
|
|
|
|
}
|
2017-04-13 21:35:13 +00:00
|
|
|
|
|
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-11 19:01:31 +00:00
|
|
|
runE2e(EXAMPLE_PATH);
|