Merge pull request #3049 from Microsoft/testPerf
Create "light" test-running mode and a '--noLibCheck' flag
This commit is contained in:
commit
46a842e19b
14
Jakefile.js
14
Jakefile.js
|
@ -505,9 +505,9 @@ function cleanTestDirs() {
|
|||
}
|
||||
|
||||
// used to pass data from jake command line directly to run.js
|
||||
function writeTestConfigFile(tests, testConfigFile) {
|
||||
function writeTestConfigFile(tests, light, testConfigFile) {
|
||||
console.log('Running test(s): ' + tests);
|
||||
var testConfigContents = JSON.stringify({ test: [tests]});
|
||||
var testConfigContents = JSON.stringify({ test: [tests], light: light });
|
||||
fs.writeFileSync('test.config', testConfigContents);
|
||||
}
|
||||
|
||||
|
@ -523,13 +523,14 @@ task("runtests", ["tests", builtLocalDirectory], function() {
|
|||
cleanTestDirs();
|
||||
host = "mocha"
|
||||
tests = process.env.test || process.env.tests || process.env.t;
|
||||
var light = process.env.light || false;
|
||||
var testConfigFile = 'test.config';
|
||||
if(fs.existsSync(testConfigFile)) {
|
||||
fs.unlinkSync(testConfigFile);
|
||||
}
|
||||
|
||||
if(tests) {
|
||||
writeTestConfigFile(tests, testConfigFile);
|
||||
if(tests || light) {
|
||||
writeTestConfigFile(tests, light, testConfigFile);
|
||||
}
|
||||
|
||||
if (tests && tests.toLocaleLowerCase() === "rwc") {
|
||||
|
@ -572,12 +573,13 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory], function(
|
|||
port = process.env.port || process.env.p || '8888';
|
||||
browser = process.env.browser || process.env.b || "IE";
|
||||
tests = process.env.test || process.env.tests || process.env.t;
|
||||
var light = process.env.light || false;
|
||||
var testConfigFile = 'test.config';
|
||||
if(fs.existsSync(testConfigFile)) {
|
||||
fs.unlinkSync(testConfigFile);
|
||||
}
|
||||
if(tests) {
|
||||
writeTestConfigFile(tests, testConfigFile);
|
||||
if(tests || light) {
|
||||
writeTestConfigFile(tests, light, testConfigFile);
|
||||
}
|
||||
|
||||
tests = tests ? tests : '';
|
||||
|
|
|
@ -11609,7 +11609,9 @@ namespace ts {
|
|||
|
||||
function checkSourceFile(node: SourceFile) {
|
||||
let start = new Date().getTime();
|
||||
|
||||
checkSourceFileWorker(node);
|
||||
|
||||
checkTime += new Date().getTime() - start;
|
||||
}
|
||||
|
||||
|
@ -11617,6 +11619,8 @@ namespace ts {
|
|||
function checkSourceFileWorker(node: SourceFile) {
|
||||
let links = getNodeLinks(node);
|
||||
if (!(links.flags & NodeCheckFlags.TypeChecked)) {
|
||||
// Check whether the file has declared it is the default lib,
|
||||
// and whether the user has specifically chosen to avoid checking it.
|
||||
if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -144,21 +144,30 @@ namespace ts {
|
|||
let program: Program;
|
||||
let files: SourceFile[] = [];
|
||||
let diagnostics = createDiagnosticCollection();
|
||||
let skipDefaultLib = options.noLib;
|
||||
|
||||
let commonSourceDirectory: string;
|
||||
let diagnosticsProducingTypeChecker: TypeChecker;
|
||||
let noDiagnosticsTypeChecker: TypeChecker;
|
||||
let classifiableNames: Map<string>;
|
||||
|
||||
let skipDefaultLib = options.noLib;
|
||||
|
||||
let start = new Date().getTime();
|
||||
|
||||
host = host || createCompilerHost(options);
|
||||
|
||||
let filesByName = createFileMap<SourceFile>(fileName => host.getCanonicalFileName(fileName));
|
||||
|
||||
forEach(rootNames, name => processRootFile(name, /*isDefaultLib:*/ false));
|
||||
|
||||
// Do not process the default library if:
|
||||
// - The '--noLib' flag is used.
|
||||
// - A 'no-default-lib' reference comment is encountered in
|
||||
// processing the root files.
|
||||
if (!skipDefaultLib) {
|
||||
processRootFile(host.getDefaultLibFileName(options), /*isDefaultLib:*/ true);
|
||||
}
|
||||
|
||||
verifyCompilerOptions();
|
||||
|
||||
programTime += new Date().getTime() - start;
|
||||
|
|
|
@ -1149,6 +1149,14 @@ namespace ts {
|
|||
moduleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
|
||||
/**
|
||||
* lib.d.ts should have a reference comment like
|
||||
*
|
||||
* /// <reference no-default-lib="true"/>
|
||||
*
|
||||
* If any other file has this comment, it signals not to include lib.d.ts
|
||||
* because this containing file is intended to act as a default library.
|
||||
*/
|
||||
hasNoDefaultLib: boolean;
|
||||
|
||||
languageVersion: ScriptTarget;
|
||||
|
@ -1860,7 +1868,10 @@ namespace ts {
|
|||
experimentalDecorators?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
/* @internal */ stripInternal?: boolean;
|
||||
|
||||
// Skip checking lib.d.ts to help speed up tests.
|
||||
/* @internal */ skipDefaultLibCheck?: boolean;
|
||||
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/// <reference path='harness.ts' />
|
||||
/// <reference path='runnerbase.ts' />
|
||||
/// <reference path='typeWriter.ts' />
|
||||
/// <reference path='syntacticCleaner.ts' />
|
||||
|
||||
const enum CompilerTestType {
|
||||
Conformance,
|
||||
|
@ -18,7 +17,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
|||
|
||||
public options: string;
|
||||
|
||||
constructor(public testType?: CompilerTestType) {
|
||||
constructor(public testType: CompilerTestType) {
|
||||
super();
|
||||
this.errors = true;
|
||||
this.emit = true;
|
||||
|
@ -171,7 +170,6 @@ class CompilerBaselineRunner extends RunnerBase {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
it('Correct JS output for ' + fileName, () => {
|
||||
if (!ts.fileExtensionIs(lastUnit.name, '.d.ts') && this.emit) {
|
||||
if (result.files.length === 0 && result.errors.length === 0) {
|
||||
|
@ -195,8 +193,6 @@ class CompilerBaselineRunner extends RunnerBase {
|
|||
jsCode += '//// [' + Harness.Path.getFileName(result.files[i].fileName) + ']\r\n';
|
||||
jsCode += getByteOrderMarkText(result.files[i]);
|
||||
jsCode += result.files[i].code;
|
||||
// Re-enable this if we want to do another comparison of old vs new compiler baselines
|
||||
// jsCode += SyntacticCleaner.clean(result.files[i].code);
|
||||
}
|
||||
|
||||
if (result.declFilesCode.length > 0) {
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Allows for executing a program with command-line arguments and reading the result
|
||||
interface IExec {
|
||||
exec: (fileName: string, cmdLineArgs: string[], handleResult: (ExecResult: ExecResult) => void) => void;
|
||||
}
|
||||
|
||||
class ExecResult {
|
||||
public stdout = "";
|
||||
public stderr = "";
|
||||
public exitCode: number;
|
||||
}
|
||||
|
||||
class WindowsScriptHostExec implements IExec {
|
||||
public exec(fileName: string, cmdLineArgs: string[], handleResult: (ExecResult: ExecResult) => void) : void {
|
||||
var result = new ExecResult();
|
||||
var shell = new ActiveXObject('WScript.Shell');
|
||||
try {
|
||||
var process = shell.Exec(fileName + ' ' + cmdLineArgs.join(' '));
|
||||
} catch(e) {
|
||||
result.stderr = e.message;
|
||||
result.exitCode = 1;
|
||||
handleResult(result);
|
||||
return;
|
||||
}
|
||||
// Wait for it to finish running
|
||||
while (process.Status != 0) { /* todo: sleep? */ }
|
||||
|
||||
|
||||
result.exitCode = process.ExitCode;
|
||||
if(!process.StdOut.AtEndOfStream) result.stdout = process.StdOut.ReadAll();
|
||||
if(!process.StdErr.AtEndOfStream) result.stderr = process.StdErr.ReadAll();
|
||||
|
||||
handleResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
class NodeExec implements IExec {
|
||||
public exec(fileName: string, cmdLineArgs: string[], handleResult: (ExecResult: ExecResult) => void) : void {
|
||||
var nodeExec = require('child_process').exec;
|
||||
|
||||
var result = new ExecResult();
|
||||
result.exitCode = null;
|
||||
var cmdLine = fileName + ' ' + cmdLineArgs.join(' ');
|
||||
var process = nodeExec(cmdLine, function(error: any, stdout: string, stderr: string) {
|
||||
result.stdout = stdout;
|
||||
result.stderr = stderr;
|
||||
result.exitCode = error ? error.code : 0;
|
||||
handleResult(result);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var Exec: IExec = function() : IExec {
|
||||
var global = <any>Function("return this;").call(null);
|
||||
if(typeof global.ActiveXObject !== "undefined") {
|
||||
return new WindowsScriptHostExec();
|
||||
} else {
|
||||
return new NodeExec();
|
||||
}
|
||||
}();
|
|
@ -343,7 +343,8 @@ module FourSlash {
|
|||
if (!resolvedResult.isLibFile) {
|
||||
this.languageServiceAdapterHost.addScript(Harness.Compiler.defaultLibFileName, Harness.Compiler.defaultLibSourceFile.text);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// resolveReference file-option is not specified then do not resolve any files and include all inputFiles
|
||||
ts.forEachKey(this.inputFiles, fileName => {
|
||||
if (!Harness.isLibraryFile(fileName)) {
|
||||
|
|
|
@ -99,7 +99,7 @@ module Utils {
|
|||
}
|
||||
|
||||
try {
|
||||
var content = ts.sys.readFile(Harness.userSpecifiedroot + path);
|
||||
var content = ts.sys.readFile(Harness.userSpecifiedRoot + path);
|
||||
}
|
||||
catch (err) {
|
||||
return undefined;
|
||||
|
@ -732,7 +732,8 @@ module Harness {
|
|||
}
|
||||
|
||||
// Settings
|
||||
export var userSpecifiedroot = "";
|
||||
export let userSpecifiedRoot = "";
|
||||
export let lightMode = false;
|
||||
|
||||
/** Functionality for compiling TypeScript code */
|
||||
export module Compiler {
|
||||
|
@ -809,17 +810,19 @@ module Harness {
|
|||
}
|
||||
|
||||
export function createSourceFileAndAssertInvariants(
|
||||
fileName: string,
|
||||
sourceText: string,
|
||||
languageVersion: ts.ScriptTarget,
|
||||
assertInvariants: boolean) {
|
||||
|
||||
fileName: string,
|
||||
sourceText: string,
|
||||
languageVersion: ts.ScriptTarget) {
|
||||
// We'll only assert invariants outside of light mode.
|
||||
const shouldAssertInvariants = !Harness.lightMode;
|
||||
|
||||
// Only set the parent nodes if we're asserting invariants. We don't need them otherwise.
|
||||
var result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ assertInvariants);
|
||||
var result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ shouldAssertInvariants);
|
||||
|
||||
if (assertInvariants) {
|
||||
if (shouldAssertInvariants) {
|
||||
Utils.assertInvariants(result, /*parent:*/ undefined);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -827,8 +830,8 @@ module Harness {
|
|||
const lineFeed = "\n";
|
||||
|
||||
export var defaultLibFileName = 'lib.d.ts';
|
||||
export var defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest, /*assertInvariants:*/ true);
|
||||
export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest, /*assertInvariants:*/ true);
|
||||
export var defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
|
||||
export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
|
||||
|
||||
// Cache these between executions so we don't have to re-parse them for every test
|
||||
export var fourslashFileName = 'fourslash.ts';
|
||||
|
@ -859,7 +862,7 @@ module Harness {
|
|||
function register(file: { unitName: string; content: string; }) {
|
||||
if (file.content !== undefined) {
|
||||
var fileName = ts.normalizePath(file.unitName);
|
||||
filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget, /*assertInvariants:*/ true);
|
||||
filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget);
|
||||
}
|
||||
};
|
||||
inputFiles.forEach(register);
|
||||
|
@ -882,7 +885,7 @@ module Harness {
|
|||
}
|
||||
else if (fn === fourslashFileName) {
|
||||
var tsFn = 'tests/cases/fourslash/' + fourslashFileName;
|
||||
fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget, /*assertInvariants:*/ true);
|
||||
fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget);
|
||||
return fourslashSourceFile;
|
||||
}
|
||||
else {
|
||||
|
@ -939,17 +942,19 @@ module Harness {
|
|||
}
|
||||
|
||||
public emitAll(ioHost?: IEmitterIOHost) {
|
||||
this.compileFiles(this.inputFiles, [],(result) => {
|
||||
result.files.forEach(file => {
|
||||
ioHost.writeFile(file.fileName, file.code, false);
|
||||
});
|
||||
result.declFilesCode.forEach(file => {
|
||||
ioHost.writeFile(file.fileName, file.code, false);
|
||||
});
|
||||
result.sourceMaps.forEach(file => {
|
||||
ioHost.writeFile(file.fileName, file.code, false);
|
||||
});
|
||||
},() => { }, this.compileOptions);
|
||||
this.compileFiles(this.inputFiles,
|
||||
/*otherFiles*/ [],
|
||||
/*onComplete*/ result => {
|
||||
result.files.forEach(writeFile);
|
||||
result.declFilesCode.forEach(writeFile);
|
||||
result.sourceMaps.forEach(writeFile);
|
||||
},
|
||||
/*settingsCallback*/ () => { },
|
||||
this.compileOptions);
|
||||
|
||||
function writeFile(file: GeneratedFile) {
|
||||
ioHost.writeFile(file.fileName, file.code, false);
|
||||
}
|
||||
}
|
||||
|
||||
public compileFiles(inputFiles: { unitName: string; content: string }[],
|
||||
|
@ -958,8 +963,7 @@ module Harness {
|
|||
settingsCallback?: (settings: ts.CompilerOptions) => void,
|
||||
options?: ts.CompilerOptions,
|
||||
// Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file
|
||||
currentDirectory?: string,
|
||||
assertInvariants = true) {
|
||||
currentDirectory?: string) {
|
||||
|
||||
options = options || { noResolve: false };
|
||||
options.target = options.target || ts.ScriptTarget.ES3;
|
||||
|
@ -979,7 +983,31 @@ module Harness {
|
|||
var includeBuiltFiles: { unitName: string; content: string }[] = [];
|
||||
|
||||
var useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames;
|
||||
this.settings.forEach(setting => {
|
||||
this.settings.forEach(setCompilerOptionForSetting);
|
||||
|
||||
var fileOutputs: GeneratedFile[] = [];
|
||||
|
||||
var programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName);
|
||||
|
||||
var compilerHost = createCompilerHost(
|
||||
inputFiles.concat(includeBuiltFiles).concat(otherFiles),
|
||||
(fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }),
|
||||
options.target, useCaseSensitiveFileNames, currentDirectory, options.newLine);
|
||||
var program = ts.createProgram(programFiles, options, compilerHost);
|
||||
|
||||
var emitResult = program.emit();
|
||||
|
||||
var errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
this.lastErrors = errors;
|
||||
|
||||
var result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult.sourceMaps);
|
||||
onComplete(result, program);
|
||||
|
||||
// reset what newline means in case the last test changed it
|
||||
ts.sys.newLine = newLine;
|
||||
return options;
|
||||
|
||||
function setCompilerOptionForSetting(setting: Harness.TestCaseParser.CompilerSetting) {
|
||||
switch (setting.flag.toLowerCase()) {
|
||||
// "fileName", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noimplicitany", "noresolve"
|
||||
case "module":
|
||||
|
@ -1133,7 +1161,7 @@ module Harness {
|
|||
case 'inlinesourcemap':
|
||||
options.inlineSourceMap = setting.value === 'true';
|
||||
break;
|
||||
|
||||
|
||||
case 'inlinesources':
|
||||
options.inlineSources = setting.value === 'true';
|
||||
break;
|
||||
|
@ -1141,28 +1169,7 @@ module Harness {
|
|||
default:
|
||||
throw new Error('Unsupported compiler setting ' + setting.flag);
|
||||
}
|
||||
});
|
||||
|
||||
var fileOutputs: GeneratedFile[] = [];
|
||||
|
||||
var programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName);
|
||||
var compilerHost = createCompilerHost(
|
||||
inputFiles.concat(includeBuiltFiles).concat(otherFiles),
|
||||
(fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }),
|
||||
options.target, useCaseSensitiveFileNames, currentDirectory, options.newLine);
|
||||
var program = ts.createProgram(programFiles, options, compilerHost);
|
||||
|
||||
var emitResult = program.emit();
|
||||
|
||||
var errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
this.lastErrors = errors;
|
||||
|
||||
var result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult.sourceMaps);
|
||||
onComplete(result, program);
|
||||
|
||||
// reset what newline means in case the last test changed it
|
||||
ts.sys.newLine = newLine;
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
||||
public compileDeclarationFiles(inputFiles: { unitName: string; content: string; }[],
|
||||
|
@ -1363,29 +1370,30 @@ module Harness {
|
|||
ts.sys.newLine + ts.sys.newLine + outputLines.join('\r\n');
|
||||
}
|
||||
|
||||
export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[], clean?: (s: string) => string) {
|
||||
export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[]): string {
|
||||
// Collect, test, and sort the fileNames
|
||||
function cleanName(fn: string) {
|
||||
var lastSlash = ts.normalizeSlashes(fn).lastIndexOf('/');
|
||||
return fn.substr(lastSlash + 1).toLowerCase();
|
||||
}
|
||||
outputFiles.sort((a, b) => cleanName(a.fileName).localeCompare(cleanName(b.fileName)));
|
||||
|
||||
// Emit them
|
||||
var result = '';
|
||||
ts.forEach(outputFiles, outputFile => {
|
||||
for (let outputFile of outputFiles) {
|
||||
// Some extra spacing if this isn't the first file
|
||||
if (result.length) result = result + '\r\n\r\n';
|
||||
if (result.length) {
|
||||
result += '\r\n\r\n';
|
||||
}
|
||||
|
||||
// FileName header + content
|
||||
result = result + '/*====== ' + outputFile.fileName + ' ======*/\r\n';
|
||||
if (clean) {
|
||||
result = result + clean(outputFile.code);
|
||||
} else {
|
||||
result = result + outputFile.code;
|
||||
}
|
||||
});
|
||||
result += '/*====== ' + outputFile.fileName + ' ======*/\r\n';
|
||||
|
||||
result += outputFile.code;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
function cleanName(fn: string) {
|
||||
var lastSlash = ts.normalizeSlashes(fn).lastIndexOf('/');
|
||||
return fn.substr(lastSlash + 1).toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
/** The harness' compiler instance used when tests are actually run. Reseting or changing settings of this compiler instance must be done within a test case (i.e., describe/it) */
|
||||
|
@ -1487,16 +1495,6 @@ module Harness {
|
|||
// Regex for parsing options in the format "@Alpha: Value of any sort"
|
||||
var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
|
||||
|
||||
// List of allowed metadata names
|
||||
var fileMetadataNames = ["filename", "comments", "declaration", "module",
|
||||
"nolib", "sourcemap", "target", "out", "outdir", "noemithelpers", "noemitonerror",
|
||||
"noimplicitany", "noresolve", "newline", "normalizenewline", "emitbom",
|
||||
"errortruncation", "usecasesensitivefilenames", "preserveconstenums",
|
||||
"includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal",
|
||||
"isolatedmodules", "inlinesourcemap", "maproot", "sourceroot",
|
||||
"inlinesources", "emitdecoratormetadata", "experimentaldecorators",
|
||||
"skipdefaultlibcheck"];
|
||||
|
||||
function extractCompilerSettings(content: string): CompilerSetting[] {
|
||||
|
||||
var opts: CompilerSetting[] = [];
|
||||
|
@ -1530,10 +1528,8 @@ module Harness {
|
|||
if (testMetaData) {
|
||||
// Comment line, check for global/file @options and record them
|
||||
optionRegex.lastIndex = 0;
|
||||
var fileNameIndex = fileMetadataNames.indexOf(testMetaData[1].toLowerCase());
|
||||
if (fileNameIndex === -1) {
|
||||
throw new Error('Unrecognized metadata name "' + testMetaData[1] + '". Available file metadata names are: ' + fileMetadataNames.join(', '));
|
||||
} else if (fileNameIndex === 0) {
|
||||
var metaDataName = testMetaData[1].toLowerCase();
|
||||
if (metaDataName === "filename") {
|
||||
currentFileOptions[testMetaData[1]] = testMetaData[2];
|
||||
} else {
|
||||
continue;
|
||||
|
@ -1619,9 +1615,9 @@ module Harness {
|
|||
|
||||
function baselinePath(fileName: string, type: string, baselineFolder: string, subfolder?: string) {
|
||||
if (subfolder !== undefined) {
|
||||
return Harness.userSpecifiedroot + baselineFolder + '/' + subfolder + '/' + type + '/' + fileName;
|
||||
return Harness.userSpecifiedRoot + baselineFolder + '/' + subfolder + '/' + type + '/' + fileName;
|
||||
} else {
|
||||
return Harness.userSpecifiedroot + baselineFolder + '/' + type + '/' + fileName;
|
||||
return Harness.userSpecifiedRoot + baselineFolder + '/' + type + '/' + fileName;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1730,7 +1726,7 @@ module Harness {
|
|||
}
|
||||
|
||||
export function getDefaultLibraryFile(): { unitName: string, content: string } {
|
||||
var libFile = Harness.userSpecifiedroot + Harness.libFolder + "/" + "lib.d.ts";
|
||||
var libFile = Harness.userSpecifiedRoot + Harness.libFolder + "/" + "lib.d.ts";
|
||||
return {
|
||||
unitName: libFile,
|
||||
content: IO.readFile(libFile)
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
/// <reference path="exec.ts" />
|
||||
/// <reference path="generate.ts" />
|
||||
/// <reference path="harness.ts" />
|
||||
/// <reference path="diff.ts" />
|
|
@ -174,7 +174,7 @@ class ProjectRunner extends RunnerBase {
|
|||
else {
|
||||
var text = getSourceFileText(fileName);
|
||||
if (text !== undefined) {
|
||||
sourceFile = Harness.Compiler.createSourceFileAndAssertInvariants(fileName, text, languageVersion, /*assertInvariants:*/ true);
|
||||
sourceFile = Harness.Compiler.createSourceFileAndAssertInvariants(fileName, text, languageVersion);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
/// <reference path='fourslashRunner.ts' />
|
||||
/// <reference path='projectsRunner.ts' />
|
||||
/// <reference path='rwcRunner.ts' />
|
||||
/// <reference path='harness.ts' />
|
||||
|
||||
function runTests(runners: RunnerBase[]) {
|
||||
for (var i = iterations; i > 0; i--) {
|
||||
|
@ -39,6 +40,9 @@ var testConfigFile =
|
|||
|
||||
if (testConfigFile !== '') {
|
||||
var testConfig = JSON.parse(testConfigFile);
|
||||
if (testConfig.light) {
|
||||
Harness.lightMode = true;
|
||||
}
|
||||
|
||||
if (testConfig.test && testConfig.test.length > 0) {
|
||||
for (let option of testConfig.test) {
|
||||
|
|
|
@ -12,7 +12,7 @@ class RunnerBase {
|
|||
}
|
||||
|
||||
public enumerateFiles(folder: string, regex?: RegExp, options?: { recursive: boolean }): string[] {
|
||||
return Harness.IO.listFiles(Harness.userSpecifiedroot + folder, regex, { recursive: (options ? options.recursive : false) });
|
||||
return Harness.IO.listFiles(Harness.userSpecifiedRoot + folder, regex, { recursive: (options ? options.recursive : false) });
|
||||
}
|
||||
|
||||
/** Setup the runner's tests so that they are ready to be executed by the harness
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/// <reference path='harness.ts'/>
|
||||
/// <reference path='runnerbase.ts' />
|
||||
/// <reference path='syntacticCleaner.ts' />
|
||||
/// <reference path='loggedIO.ts' />
|
||||
/// <reference path='..\compiler\commandLineParser.ts'/>
|
||||
|
||||
|
@ -75,7 +74,7 @@ module RWC {
|
|||
});
|
||||
|
||||
// Add files to compilation
|
||||
for(let fileRead of ioLog.filesRead) {
|
||||
for (let fileRead of ioLog.filesRead) {
|
||||
// Check if the file is already added into the set of input files.
|
||||
var resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path));
|
||||
var inInputList = ts.forEach(inputFiles, inputFile => inputFile.unitName === resolvedPath);
|
||||
|
@ -107,14 +106,14 @@ module RWC {
|
|||
opts.options.noLib = true;
|
||||
|
||||
// Emit the results
|
||||
compilerOptions = harnessCompiler.compileFiles(inputFiles, otherFiles, compileResult => {
|
||||
compilerResult = compileResult;
|
||||
},
|
||||
compilerOptions = harnessCompiler.compileFiles(
|
||||
inputFiles,
|
||||
otherFiles,
|
||||
newCompilerResults => { compilerResult = newCompilerResults; },
|
||||
/*settingsCallback*/ undefined, opts.options,
|
||||
// Since all Rwc json file specified current directory in its json file, we need to pass this information to compilerHost
|
||||
// so that when the host is asked for current directory, it should give the value from json rather than from process
|
||||
currentDirectory,
|
||||
/*assertInvariants:*/ false);
|
||||
// Since each RWC json file specifies its current directory in its json file, we need
|
||||
// to pass this information in explicitly instead of acquiring it from the process.
|
||||
currentDirectory);
|
||||
});
|
||||
|
||||
function getHarnessCompilerInputUnit(fileName: string) {
|
||||
|
@ -132,7 +131,7 @@ module RWC {
|
|||
|
||||
it('has the expected emitted code', () => {
|
||||
Harness.Baseline.runBaseline('has the expected emitted code', baseName + '.output.js', () => {
|
||||
return Harness.Compiler.collateOutputs(compilerResult.files, s => SyntacticCleaner.clean(s));
|
||||
return Harness.Compiler.collateOutputs(compilerResult.files);
|
||||
}, false, baselineOpts);
|
||||
});
|
||||
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
// Use this to get emitter-agnostic baselines
|
||||
|
||||
class SyntacticCleaner {
|
||||
static clean(sourceFileContents: string) {
|
||||
return sourceFileContents;
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: Re-implement or maybe delete
|
||||
class SyntacticCleaner extends TypeScript.SyntaxWalker {
|
||||
private emit: string[] = [];
|
||||
|
||||
public visitToken(token: TypeScript.ISyntaxToken): void {
|
||||
this.emit.push(token.text());
|
||||
if (token.kind() === TypeScript.SyntaxKind.SemicolonToken) {
|
||||
this.emit.push('\r\n');
|
||||
} else {
|
||||
this.emit.push(' ');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static clean(sourceFileContents: string): string {
|
||||
var parsed = TypeScript.Parser.parse('_emitted.ts', TypeScript.SimpleText.fromString(sourceFileContents), TypeScript.LanguageVersion.EcmaScript5, false);
|
||||
var cleaner = new SyntacticCleaner();
|
||||
cleaner.visitSourceUnit(parsed.sourceUnit());
|
||||
return cleaner.emit.join('');
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -1,6 +1,5 @@
|
|||
/// <reference path='harness.ts' />
|
||||
/// <reference path='runnerbase.ts' />
|
||||
/// <reference path='syntacticCleaner.ts' />
|
||||
|
||||
class Test262BaselineRunner extends RunnerBase {
|
||||
private static basePath = 'internal/cases/test262';
|
||||
|
@ -65,7 +64,7 @@ class Test262BaselineRunner extends RunnerBase {
|
|||
it('has the expected emitted code', () => {
|
||||
Harness.Baseline.runBaseline('has the expected emitted code', testState.filename + '.output.js', () => {
|
||||
var files = testState.compilerResult.files.filter(f=> f.fileName !== Test262BaselineRunner.helpersFilePath);
|
||||
return Harness.Compiler.collateOutputs(files, s => SyntacticCleaner.clean(s));
|
||||
return Harness.Compiler.collateOutputs(files);
|
||||
}, false, Test262BaselineRunner.baselineOptions);
|
||||
});
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ error TS2318: Cannot find global type 'String'.
|
|||
!!! error TS2318: Cannot find global type 'String'.
|
||||
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509698.ts (0 errors) ====
|
||||
/// <style requireSemi="on" />
|
||||
/// <reference no-default-lib="true"/>
|
||||
declare function foo(): void;
|
||||
declare function bar(): void;
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
//// [parser509698.ts]
|
||||
/// <style requireSemi="on" />
|
||||
/// <reference no-default-lib="true"/>
|
||||
declare function foo(): void;
|
||||
declare function bar(): void;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @noLib: true
|
||||
/// <style requireSemi="on" />
|
||||
/// <reference no-default-lib="true"/>
|
||||
declare function foo(): void;
|
||||
declare function bar(): void;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/// <reference path="..\..\..\src\harness\harness.ts" />
|
||||
/// <reference path="..\..\..\src\harness\harness.ts" />
|
||||
|
||||
module ts {
|
||||
describe('convertToBase64', () => {
|
||||
|
@ -8,25 +8,25 @@ module ts {
|
|||
assert.equal(actual, expected, "Encoded string using convertToBase64 does not match buffer.toString('base64')");
|
||||
}
|
||||
|
||||
it("Converts ASCII charaters correctelly", () => {
|
||||
it("Converts ASCII charaters correctly", () => {
|
||||
runTest(" !\"#$ %&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
|
||||
});
|
||||
|
||||
it("Converts escape sequences correctelly", () => {
|
||||
it("Converts escape sequences correctly", () => {
|
||||
runTest("\t\n\r\\\"\'\u0062");
|
||||
});
|
||||
|
||||
it("Converts simple unicode characters correctelly", () => {
|
||||
it("Converts simple unicode characters correctly", () => {
|
||||
runTest("ΠΣ ٵپ औठ ⺐⺠");
|
||||
});
|
||||
|
||||
it("Converts simple code snippit correctelly", () => {
|
||||
it("Converts simple code snippet correctly", () => {
|
||||
runTest(`/// <reference path="file.ts" />
|
||||
var x: string = "string";
|
||||
console.log(x);`);
|
||||
});
|
||||
|
||||
it("Converts simple code snippit with unicode characters correctelly", () => {
|
||||
it("Converts simple code snippet with unicode characters correctly", () => {
|
||||
runTest(`var Π = 3.1415; console.log(Π);`);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/// <reference path="..\..\..\src\harness\harness.ts" />
|
||||
/// <reference path="..\..\..\src\harness\harness.ts" />
|
||||
|
||||
module ts {
|
||||
describe("Transpile", () => {
|
||||
|
|
Loading…
Reference in a new issue