Skip to content

Commit

Permalink
chore(e2e): chdir back to the previous dir at the end of a test. (ang…
Browse files Browse the repository at this point in the history
  • Loading branch information
hansl authored and MRHarrison committed Feb 9, 2017
1 parent 11da9b7 commit c2caf46
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 1 addition & 3 deletions tests/e2e/tests/commands/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import {silentNg} from '../../utils/process';


export default function() {
const projectDir = process.cwd();
return Promise.resolve()
.then(() => silentNg('help'))
.then(() => process.chdir('/'))
.then(() => silentNg('help'))
.then(() => process.chdir(projectDir));
.then(() => silentNg('help'));
}
3 changes: 0 additions & 3 deletions tests/e2e/tests/packages/webpack/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import {expectFileSizeToBeUnder} from '../../../utils/fs';


export default function(argv: any, skipCleaning: () => void) {
const currentDir = process.cwd();

if (process.platform.startsWith('win')) {
// Disable the test on Windows.
return Promise.resolve();
Expand All @@ -24,6 +22,5 @@ export default function(argv: any, skipCleaning: () => void) {
.then(() => exec('node_modules/.bin/webpack', '-p'))
.then(() => expectFileSizeToBeUnder('dist/app.main.js', 400000))
.then(() => expectFileSizeToBeUnder('dist/0.app.main.js', 40000))
.then(() => process.chdir(currentDir))
.then(() => skipCleaning());
}
9 changes: 9 additions & 0 deletions tests/e2e_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,19 @@ testsToRun.reduce((previous, relativeName) => {
};

let clean = true;
let previousDir = null;
return Promise.resolve()
.then(() => printHeader(currentFileName))
.then(() => previousDir = process.cwd())
.then(() => fn(argv, () => clean = false))
.then(() => console.log(' ----'))
.then(() => {
// If we're not in a setup, change the directory back to where it was before the test.
// This allows tests to chdir without worrying about keeping the original directory.
if (allSetups.indexOf(relativeName) == -1 && previousDir) {
process.chdir(previousDir);
}
})
.then(() => {
// Only clean after a real test, not a setup step. Also skip cleaning if the test
// requested an exception.
Expand Down

0 comments on commit c2caf46

Please sign in to comment.