Skip to content

Commit 3b19cbb

Browse files
authored
Fail fast if expectedOutput does not exist (#293)
* Fail fast if expectedOutput does not exist rather than garbage collection error which is totally misleading * Fix up mistakes * made the message little clearer * Clarify error message
1 parent eccfce7 commit 3b19cbb

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

test/run.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ fs.readdirSync(__dirname).forEach(function(test) {
4848
}
4949
});
5050

51+
function fileExists(path) {
52+
var fileExists = true;
53+
try {
54+
fs.accessSync(path, fs.F_OK);
55+
} catch (e) {
56+
fileExists = false;
57+
}
58+
return fileExists;
59+
}
60+
5161
function createTest(test, testPath, options) {
5262
return function(done) {
5363
this.timeout(60000); // sometimes it just takes awhile
@@ -59,6 +69,8 @@ function createTest(test, testPath, options) {
5969
webpackOutput = path.join(testStagingPath, '.output'),
6070
originalExpectedOutput = path.join(testPath, 'expectedOutput-'+typescriptVersion);
6171

72+
assert.ok(fileExists(originalExpectedOutput), 'The expected output does not exist; there is nothing to compare against! Has the expected output been created?\nCould not find: ' + originalExpectedOutput)
73+
6274
if (saveOutputMode) {
6375
savedOutputs[test] = savedOutputs[test] || {};
6476
var regularSavedOutput = savedOutputs[test].regular = savedOutputs[test].regular || {};
@@ -258,4 +270,4 @@ function createTest(test, testPath, options) {
258270
}
259271
});
260272
};
261-
}
273+
}

0 commit comments

Comments
 (0)