From b562973f395e31ec3a6ccab07546caf956fe3f4a Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Sun, 26 Apr 2015 21:09:43 -0700 Subject: [PATCH] wrap project runner tests in 'it' --- src/harness/projectsRunner.ts | 92 +++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 37 deletions(-) diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 6823bfafac2..af7d0383202 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -328,7 +328,9 @@ class ProjectRunner extends RunnerBase { return Harness.Compiler.getErrorBaseline(inputFiles, diagnostics); } - describe('Compiling project for ' + testCase.scenario + ': testcase ' + testCaseFileName, () => { + var name = 'Compiling project for ' + testCase.scenario + ': testcase ' + testCaseFileName; + + describe(name, () => { function verifyCompilerResults(compilerResult: BatchCompileProjectTestCaseResult) { function getCompilerResolutionInfo() { var resolutionInfo: ProjectRunnerTestCaseResolutionInfo = { @@ -405,51 +407,67 @@ class ProjectRunner extends RunnerBase { } } - // Compile using node - var nodeCompilerResult = batchCompilerProjectTestCase(ts.ModuleKind.CommonJS); - verifyCompilerResults(nodeCompilerResult); + var nodeCompilerResult: BatchCompileProjectTestCaseResult; + var amdCompilerResult: BatchCompileProjectTestCaseResult; - // Compile using amd - var amdCompilerResult = batchCompilerProjectTestCase(ts.ModuleKind.AMD); - verifyCompilerResults(amdCompilerResult); + it(name + ": node", () => { + // Compile using node + nodeCompilerResult = batchCompilerProjectTestCase(ts.ModuleKind.CommonJS); + verifyCompilerResults(nodeCompilerResult); + }); + + + it(name + ": amd", () => { + // Compile using amd + amdCompilerResult = batchCompilerProjectTestCase(ts.ModuleKind.AMD); + verifyCompilerResults(amdCompilerResult); + }); if (testCase.runTest) { - //TODO(ryanca/danquirk): Either support this or remove this option from the interface as well as test case json files - // Node results - assert.isTrue(!nodeCompilerResult.nonSubfolderDiskFiles, "Cant run test case that generates parent folders/absolute path"); - //it("runs without error: (" + moduleNameToString(nodeCompilerResult.moduleKind) + ')', function (done: any) { - // Exec.exec("node.exe", ['"' + baseLineLocalPath(nodeCompilerResult.outputFiles[0].diskRelativeName, nodeCompilerResult.moduleKind) + '"'], function (res) { - // Harness.Assert.equal(res.stdout, ""); - // Harness.Assert.equal(res.stderr, ""); - // done(); - // }) - //}); + it(name + ": runTest", () => { + if (!nodeCompilerResult || !amdCompilerResult) { + return; + } + //TODO(ryanca/danquirk): Either support this or remove this option from the interface as well as test case json files + // Node results + assert.isTrue(!nodeCompilerResult.nonSubfolderDiskFiles, "Cant run test case that generates parent folders/absolute path"); + //it("runs without error: (" + moduleNameToString(nodeCompilerResult.moduleKind) + ')', function (done: any) { + // Exec.exec("node.exe", ['"' + baseLineLocalPath(nodeCompilerResult.outputFiles[0].diskRelativeName, nodeCompilerResult.moduleKind) + '"'], function (res) { + // Harness.Assert.equal(res.stdout, ""); + // Harness.Assert.equal(res.stderr, ""); + // done(); + // }) + //}); - // Amd results - assert.isTrue(!amdCompilerResult.nonSubfolderDiskFiles, "Cant run test case that generates parent folders/absolute path"); - //var amdDriverTemplate = "var requirejs = require('../r.js');\n\n" + - // "requirejs.config({\n" + - // " nodeRequire: require\n" + - // "});\n\n" + - // "requirejs(['{0}'],\n" + - // "function ({0}) {\n" + - // "});"; - //var moduleName = baseLineLocalPath(amdCompilerResult.outputFiles[0].diskRelativeName, amdCompilerResult.moduleKind).replace(/\.js$/, ""); - //sys.writeFile(testCase.projectRoot + '/driver.js', amdDriverTemplate.replace(/\{0}/g, moduleName)); - //it("runs without error (" + moduleNameToString(amdCompilerResult.moduleKind) + ')', function (done: any) { - // Exec.exec("node.exe", ['"' + testCase.projectRoot + '/driver.js"'], function (res) { - // Harness.Assert.equal(res.stdout, ""); - // Harness.Assert.equal(res.stderr, ""); - // done(); - // }) - //}); + // Amd results + assert.isTrue(!amdCompilerResult.nonSubfolderDiskFiles, "Cant run test case that generates parent folders/absolute path"); + //var amdDriverTemplate = "var requirejs = require('../r.js');\n\n" + + // "requirejs.config({\n" + + // " nodeRequire: require\n" + + // "});\n\n" + + // "requirejs(['{0}'],\n" + + // "function ({0}) {\n" + + // "});"; + //var moduleName = baseLineLocalPath(amdCompilerResult.outputFiles[0].diskRelativeName, amdCompilerResult.moduleKind).replace(/\.js$/, ""); + //sys.writeFile(testCase.projectRoot + '/driver.js', amdDriverTemplate.replace(/\{0}/g, moduleName)); + //it("runs without error (" + moduleNameToString(amdCompilerResult.moduleKind) + ')', function (done: any) { + // Exec.exec("node.exe", ['"' + testCase.projectRoot + '/driver.js"'], function (res) { + // Harness.Assert.equal(res.stdout, ""); + // Harness.Assert.equal(res.stderr, ""); + // done(); + // }) + //}); + }); + + after(() => { + nodeCompilerResult = undefined; + amdCompilerResult = undefined; + }); } after(() => { // Mocha holds onto the closure environment of the describe callback even after the test is done. // Therefore we have to clean out large objects after the test is done. - nodeCompilerResult = undefined; - amdCompilerResult = undefined; testCase = undefined; testFileText = undefined; testCaseJustName = undefined;