@ -179,7 +179,8 @@ class TestRunner {
|
||||
if (args.length > 0) {
|
||||
packageJsonFile = args[0];
|
||||
}
|
||||
log(`running test command ${this.successful+1} of ${this.config.commands.length}: patching '${packageJsonFile}' in '${this.testRoot}'`);
|
||||
log(`running test command ${this.successful + 1} of ${
|
||||
this.config.commands.length}: patching '${packageJsonFile}' in '${this.testRoot}'`);
|
||||
this._patchPackageJson(packageJsonFile);
|
||||
} break;
|
||||
|
||||
@ -189,14 +190,16 @@ class TestRunner {
|
||||
}
|
||||
const runfilesBinary = runfiles.resolveWorkspaceRelative(binary);
|
||||
binary = fs.existsSync(runfilesBinary) ? runfilesBinary : binary;
|
||||
log(`running test command ${this.successful+1} of ${this.config.commands.length}: '${binary} ${args.join(' ')}' in '${this.testRoot}'`);
|
||||
log(`running test command ${this.successful + 1} of ${this.config.commands.length}: '${
|
||||
binary} ${args.join(' ')}' in '${this.testRoot}'`);
|
||||
const spawnedProcess = spawnSync(binary, args, {cwd: this.testRoot, stdio: 'inherit'});
|
||||
if (spawnedProcess.error) {
|
||||
fail(
|
||||
`test command ${testRunner.successful+1} '${binary} ${args.join(' ')}' failed with ${spawnedProcess.error.code}`);
|
||||
fail(`test command ${testRunner.successful + 1} '${binary} ${
|
||||
args.join(' ')}' failed with ${spawnedProcess.error.code}`);
|
||||
}
|
||||
if (spawnedProcess.status) {
|
||||
log(`test command ${testRunner.successful+1} '${binary} ${args.join(' ')}' failed with status code ${spawnedProcess.status}`);
|
||||
log(`test command ${testRunner.successful + 1} '${binary} ${
|
||||
args.join(' ')}' failed with status code ${spawnedProcess.status}`);
|
||||
return spawnedProcess.status;
|
||||
}
|
||||
}
|
||||
@ -225,17 +228,20 @@ class TestRunner {
|
||||
if (contents.dependencies && contents.dependencies[key]) {
|
||||
replacements++;
|
||||
contents.dependencies[key] = replacement;
|
||||
log(`overriding dependencies['${key}'] npm package with 'file:${path}' in package.json file`);
|
||||
log(`overriding dependencies['${key}'] npm package with 'file:${
|
||||
path}' in package.json file`);
|
||||
}
|
||||
if (contents.devDependencies && contents.devDependencies[key]) {
|
||||
replacements++;
|
||||
contents.devDependencies[key] = replacement;
|
||||
log(`overriding devDependencies['${key}'] npm package with 'file:${path}' in package.json file`);
|
||||
log(`overriding devDependencies['${key}'] npm package with 'file:${
|
||||
path}' in package.json file`);
|
||||
}
|
||||
if (contents.resolutions && contents.resolutions[key]) {
|
||||
replacements++;
|
||||
contents.resolutions[key] = replacement;
|
||||
log(`overriding resolutions['${key}'] npm package with 'file:${path}' in package.json file`);
|
||||
log(`overriding resolutions['${key}'] npm package with 'file:${
|
||||
path}' in package.json file`);
|
||||
}
|
||||
// TODO: handle other formats for resolutions such as `some-package/${key}` or
|
||||
// `some-package/**/${key}`
|
||||
@ -243,7 +249,8 @@ class TestRunner {
|
||||
if (contents.resolutions && contents.resolutions[altKey]) {
|
||||
replacements++;
|
||||
contents.resolutions[altKey] = replacement;
|
||||
log(`overriding resolutions['${altKey}'] npm package with 'file:${path}' in package.json file`);
|
||||
log(`overriding resolutions['${altKey}'] npm package with 'file:${
|
||||
path}' in package.json file`);
|
||||
}
|
||||
}
|
||||
// check packages that must be replaced
|
||||
@ -263,8 +270,8 @@ class TestRunner {
|
||||
const contentsEncoded = JSON.stringify(contents, null, 2);
|
||||
log(`package.json file:\n${contentsEncoded}`);
|
||||
if (failedPackages.length) {
|
||||
fail(
|
||||
`expected replacements of npm packages ${JSON.stringify(failedPackages)} not found; add these to the npm_packages attribute`);
|
||||
fail(`expected replacements of npm packages ${
|
||||
JSON.stringify(failedPackages)} not found; add these to the npm_packages attribute`);
|
||||
}
|
||||
if (replacements) {
|
||||
fs.writeFileSync(packageJson, contentsEncoded);
|
||||
@ -314,7 +321,8 @@ class TestRunner {
|
||||
log(`configuring test in-place under ${this.testRoot}`);
|
||||
} else {
|
||||
this.testRoot = copyToTmp(this.config.testFiles);
|
||||
log(`test files from '${rootDirectory(this.config.testFiles)}' copied to tmp folder ${this.testRoot}`);
|
||||
log(`test files from '${rootDirectory(this.config.testFiles)}' copied to tmp folder ${
|
||||
this.testRoot}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user