Skip to content

Commit

Permalink
chore(e2e): chdir back to the previous dir at the end of a test.
Browse files Browse the repository at this point in the history
  • Loading branch information
hansl committed Nov 25, 2016
1 parent bf9c8f1 commit f810c35
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,8 +92,10 @@ 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(() => {
Expand All @@ -103,6 +105,13 @@ testsToRun.reduce((previous, relativeName) => {
return gitClean();
}
})
.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(() => printFooter(currentFileName, start),
(err) => {
printFooter(currentFileName, start);
Expand Down

0 comments on commit f810c35

Please sign in to comment.