Merge branch 'master' into inlineSourceMaps

This commit is contained in:
Mohamed Hegazy
2015-04-27 10:11:43 -07:00
259 changed files with 18613 additions and 1243 deletions

View File

@@ -97,7 +97,7 @@ class CompilerBaselineRunner extends RunnerBase {
program = _program;
}, function (settings) {
harnessCompiler.setCompilerSettings(tcSettings);
});
});
});
beforeEach(() => {
@@ -258,7 +258,7 @@ class CompilerBaselineRunner extends RunnerBase {
}
});
it('Correct type baselines for ' + fileName, () => {
it('Correct type/symbol baselines for ' + fileName, () => {
if (fileName.indexOf("APISample") >= 0) {
return;
}
@@ -295,8 +295,26 @@ class CompilerBaselineRunner extends RunnerBase {
// Produce baselines. The first gives the types for all expressions.
// The second gives symbols for all identifiers.
checkBaseLines(/*isSymbolBaseLine:*/ false);
checkBaseLines(/*isSymbolBaseLine:*/ true);
var e1: Error, e2: Error;
try {
checkBaseLines(/*isSymbolBaseLine:*/ false);
}
catch (e) {
e1 = e;
}
try {
checkBaseLines(/*isSymbolBaseLine:*/ true);
}
catch (e) {
e2 = e;
}
if (e1 || e2) {
throw e1 || e2;
}
return;
function checkBaseLines(isSymbolBaseLine: boolean) {
let fullBaseLine = generateBaseLine(fullResults, isSymbolBaseLine);

View File

@@ -957,8 +957,12 @@ module Harness {
if (typeof setting.value === 'string') {
if (setting.value.toLowerCase() === 'amd') {
options.module = ts.ModuleKind.AMD;
} else if (setting.value.toLowerCase() === 'umd') {
options.module = ts.ModuleKind.UMD;
} else if (setting.value.toLowerCase() === 'commonjs') {
options.module = ts.ModuleKind.CommonJS;
} else if (setting.value.toLowerCase() === 'system') {
options.module = ts.ModuleKind.System;
} else if (setting.value.toLowerCase() === 'unspecified') {
options.module = ts.ModuleKind.None;
} else {

View File

@@ -186,6 +186,7 @@ module Harness.LanguageService {
var script = this.getScriptInfo(fileName);
return script ? script.version.toString() : undefined;
}
log(s: string): void { }
trace(s: string): void { }
error(s: string): void { }
@@ -203,7 +204,7 @@ module Harness.LanguageService {
}
/// Shim adapter
class ShimLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceShimHost {
class ShimLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceShimHost, ts.CoreServicesShimHost {
private nativeHost: NativeLanguageServiceHost;
constructor(cancellationToken?: ts.CancellationToken, options?: ts.CompilerOptions) {
super(cancellationToken, options);
@@ -227,6 +228,11 @@ module Harness.LanguageService {
}
getScriptVersion(fileName: string): string { return this.nativeHost.getScriptVersion(fileName); }
getLocalizedDiagnosticMessages(): string { return JSON.stringify({}); }
readDirectory(rootDir: string, extension: string): string {
throw new Error("NYI");
}
log(s: string): void { this.nativeHost.log(s); }
trace(s: string): void { this.nativeHost.trace(s); }
error(s: string): void { this.nativeHost.error(s); }

View File

@@ -18,6 +18,7 @@ interface ProjectRunnerTestCase {
runTest?: boolean; // Run the resulting test
bug?: string; // If there is any bug associated with this test case
noResolve?: boolean;
rootDir?: string; // --rootDir
}
interface ProjectRunnerTestCaseResolutionInfo extends ProjectRunnerTestCase {
@@ -160,7 +161,8 @@ class ProjectRunner extends RunnerBase {
mapRoot: testCase.resolveMapRoot && testCase.mapRoot ? ts.sys.resolvePath(testCase.mapRoot) : testCase.mapRoot,
sourceRoot: testCase.resolveSourceRoot && testCase.sourceRoot ? ts.sys.resolvePath(testCase.sourceRoot) : testCase.sourceRoot,
module: moduleKind,
noResolve: testCase.noResolve
noResolve: testCase.noResolve,
rootDir: testCase.rootDir
};
}
@@ -326,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 = {
@@ -344,6 +348,7 @@ class ProjectRunner extends RunnerBase {
baselineCheck: testCase.baselineCheck,
runTest: testCase.runTest,
bug: testCase.bug,
rootDir: testCase.rootDir,
resolvedInputFiles: ts.map(compilerResult.program.getSourceFiles(), inputFile => inputFile.fileName),
emittedFiles: ts.map(compilerResult.outputFiles, outputFile => outputFile.emittedFileName)
};
@@ -402,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;