test: revert local test project file changes on test completion

This commit is contained in:
Jason Bedard 2022-07-25 16:10:09 -07:00 committed by Alan Agius
parent 96d39f8f3a
commit 2e4925b6d6
2 changed files with 17 additions and 13 deletions

View File

@ -24,12 +24,14 @@ export default async function () {
// Major should succeed, but we don't need to test it here since it's tested everywhere else.
// Major+1 and -1 should fail architect commands, but allow other commands.
await fakeCoreVersion(cliMajor + 1);
await expectToFail(() => ng('build'), 'Should fail Major+1');
await ng('version');
await fakeCoreVersion(cliMajor - 1);
await ng('version');
// Restore the original core package.json.
await writeFile(angularCorePkgPath, originalAngularCorePkgJson);
try {
await fakeCoreVersion(cliMajor + 1);
await expectToFail(() => ng('build'), 'Should fail Major+1');
await ng('version');
await fakeCoreVersion(cliMajor - 1);
await ng('version');
} finally {
// Restore the original core package.json.
await writeFile(angularCorePkgPath, originalAngularCorePkgJson);
}
}

View File

@ -242,13 +242,15 @@ async function runInitializer(absoluteName: string) {
async function runTest(absoluteName: string) {
process.chdir(join(getGlobalVariable('projects-root'), 'test-project'));
await launchTestProcess(absoluteName);
logStack.push(new logging.NullLogger());
try {
await gitClean();
await launchTestProcess(absoluteName);
} finally {
logStack.pop();
logStack.push(new logging.NullLogger());
try {
await gitClean();
} finally {
logStack.pop();
}
}
}