Skip to content

Commit e76439b

Browse files
committed
Run all checks in it blocks
1 parent cde3ed0 commit e76439b

File tree

1 file changed

+36
-76
lines changed

1 file changed

+36
-76
lines changed

src/harness/projectsRunner.ts

Lines changed: 36 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ class ProjectRunner extends RunnerBase {
331331
var name = 'Compiling project for ' + testCase.scenario + ': testcase ' + testCaseFileName;
332332

333333
describe(name, () => {
334-
function verifyCompilerResults(compilerResult: BatchCompileProjectTestCaseResult) {
334+
function verifyCompilerResults(moduleKind: ts.ModuleKind) {
335335
function getCompilerResolutionInfo() {
336336
var resolutionInfo: ProjectRunnerTestCaseResolutionInfo = {
337337
scenario: testCase.scenario,
@@ -356,23 +356,33 @@ class ProjectRunner extends RunnerBase {
356356
return resolutionInfo;
357357
}
358358

359-
it('Resolution information of (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, () => {
359+
var compilerResult: BatchCompileProjectTestCaseResult;
360+
361+
it(name + ": " + moduleNameToString(moduleKind) , () => {
362+
// Compile using node
363+
compilerResult = batchCompilerProjectTestCase(moduleKind);
364+
});
365+
366+
it('Resolution information of (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => {
360367
Harness.Baseline.runBaseline('Resolution information of (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.json', () => {
361368
return JSON.stringify(getCompilerResolutionInfo(), undefined, " ");
362369
});
363370
});
364371

365-
if (compilerResult.errors.length) {
366-
it('Errors for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, () => {
372+
373+
it('Errors for (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => {
374+
if (compilerResult.errors.length) {
367375
Harness.Baseline.runBaseline('Errors for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.errors.txt', () => {
368376
return getErrorsBaseline(compilerResult);
369377
});
370-
});
371-
}
378+
}
379+
});
380+
381+
382+
it('Baseline of emitted result (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => {
383+
if (testCase.baselineCheck) {
384+
ts.forEach(compilerResult.outputFiles, outputFile => {
372385

373-
if (testCase.baselineCheck) {
374-
ts.forEach(compilerResult.outputFiles, outputFile => {
375-
it('Baseline of emitted result (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, () => {
376386
Harness.Baseline.runBaseline('Baseline of emitted result (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => {
377387
try {
378388
return ts.sys.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind));
@@ -382,89 +392,39 @@ class ProjectRunner extends RunnerBase {
382392
}
383393
});
384394
});
385-
});
395+
}
396+
});
397+
386398

399+
it('SourceMapRecord for (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => {
387400
if (compilerResult.sourceMapData) {
388-
it('SourceMapRecord for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, () => {
389-
Harness.Baseline.runBaseline('SourceMapRecord for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.sourcemap.txt', () => {
390-
return Harness.SourceMapRecoder.getSourceMapRecord(compilerResult.sourceMapData, compilerResult.program,
391-
ts.filter(compilerResult.outputFiles, outputFile => Harness.Compiler.isJS(outputFile.emittedFileName)));
392-
});
401+
Harness.Baseline.runBaseline('SourceMapRecord for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.sourcemap.txt', () => {
402+
return Harness.SourceMapRecoder.getSourceMapRecord(compilerResult.sourceMapData, compilerResult.program,
403+
ts.filter(compilerResult.outputFiles, outputFile => Harness.Compiler.isJS(outputFile.emittedFileName)));
393404
});
394405
}
406+
});
395407

396-
// Verify that all the generated .d.ts files compile
408+
// Verify that all the generated .d.ts files compile
409+
410+
it('Errors in generated Dts files for (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => {
397411
if (!compilerResult.errors.length && testCase.declaration) {
398412
var dTsCompileResult = compileCompileDTsFiles(compilerResult);
399413
if (dTsCompileResult.errors.length) {
400-
it('Errors in generated Dts files for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, () => {
401-
Harness.Baseline.runBaseline('Errors in generated Dts files for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.dts.errors.txt', () => {
402-
return getErrorsBaseline(dTsCompileResult);
403-
});
414+
Harness.Baseline.runBaseline('Errors in generated Dts files for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.dts.errors.txt', () => {
415+
return getErrorsBaseline(dTsCompileResult);
404416
});
405417
}
406418
}
407-
}
408-
}
409-
410-
var nodeCompilerResult: BatchCompileProjectTestCaseResult;
411-
var amdCompilerResult: BatchCompileProjectTestCaseResult;
412-
413-
it(name + ": node", () => {
414-
// Compile using node
415-
nodeCompilerResult = batchCompilerProjectTestCase(ts.ModuleKind.CommonJS);
416-
verifyCompilerResults(nodeCompilerResult);
417-
});
418-
419-
420-
it(name + ": amd", () => {
421-
// Compile using amd
422-
amdCompilerResult = batchCompilerProjectTestCase(ts.ModuleKind.AMD);
423-
verifyCompilerResults(amdCompilerResult);
424-
});
425-
426-
if (testCase.runTest) {
427-
it(name + ": runTest", () => {
428-
if (!nodeCompilerResult || !amdCompilerResult) {
429-
return;
430-
}
431-
//TODO(ryanca/danquirk): Either support this or remove this option from the interface as well as test case json files
432-
// Node results
433-
assert.isTrue(!nodeCompilerResult.nonSubfolderDiskFiles, "Cant run test case that generates parent folders/absolute path");
434-
//it("runs without error: (" + moduleNameToString(nodeCompilerResult.moduleKind) + ')', function (done: any) {
435-
// Exec.exec("node.exe", ['"' + baseLineLocalPath(nodeCompilerResult.outputFiles[0].diskRelativeName, nodeCompilerResult.moduleKind) + '"'], function (res) {
436-
// Harness.Assert.equal(res.stdout, "");
437-
// Harness.Assert.equal(res.stderr, "");
438-
// done();
439-
// })
440-
//});
441-
442-
// Amd results
443-
assert.isTrue(!amdCompilerResult.nonSubfolderDiskFiles, "Cant run test case that generates parent folders/absolute path");
444-
//var amdDriverTemplate = "var requirejs = require('../r.js');\n\n" +
445-
// "requirejs.config({\n" +
446-
// " nodeRequire: require\n" +
447-
// "});\n\n" +
448-
// "requirejs(['{0}'],\n" +
449-
// "function ({0}) {\n" +
450-
// "});";
451-
//var moduleName = baseLineLocalPath(amdCompilerResult.outputFiles[0].diskRelativeName, amdCompilerResult.moduleKind).replace(/\.js$/, "");
452-
//sys.writeFile(testCase.projectRoot + '/driver.js', amdDriverTemplate.replace(/\{0}/g, moduleName));
453-
//it("runs without error (" + moduleNameToString(amdCompilerResult.moduleKind) + ')', function (done: any) {
454-
// Exec.exec("node.exe", ['"' + testCase.projectRoot + '/driver.js"'], function (res) {
455-
// Harness.Assert.equal(res.stdout, "");
456-
// Harness.Assert.equal(res.stderr, "");
457-
// done();
458-
// })
459-
//});
460419
});
461-
462420
after(() => {
463-
nodeCompilerResult = undefined;
464-
amdCompilerResult = undefined;
421+
compilerResult = undefined;
465422
});
466423
}
467424

425+
verifyCompilerResults(ts.ModuleKind.CommonJS);
426+
verifyCompilerResults(ts.ModuleKind.AMD);
427+
468428
after(() => {
469429
// Mocha holds onto the closure environment of the describe callback even after the test is done.
470430
// Therefore we have to clean out large objects after the test is done.

0 commit comments

Comments
 (0)