Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
dfee3de
Add test case for #8229
sheetalkamat Apr 21, 2016
90d347e
Do not report errors during contextual typecheck
sheetalkamat Apr 21, 2016
34f7f2c
Handle the scenario when let [a=undefined]=[]
sheetalkamat Apr 22, 2016
448a480
Don't allow `.ts` to appear in an import
Jul 12, 2016
a8c05a9
Add specific error message for unwanted '.ts' extension
Jul 12, 2016
95e391e
Allow `await` in a simple unary expression
Jul 22, 2016
bc5c7b6
More tests
Jul 22, 2016
275dbc7
Forbid `await await`
Jul 22, 2016
52fd033
Allow `await await`
Jul 25, 2016
2821d98
Merge branch 'master' into no_ts_extension
Aug 2, 2016
0f134ed
Improve error message
Aug 2, 2016
359c8b1
Don't allow ".d.ts" extension in an import either.
Aug 3, 2016
3de8c22
Merge branch 'master' into no_ts_extension
Aug 15, 2016
2eb159e
Rename 'find' functions
Aug 15, 2016
02f908a
Merge branch 'master' into noImplicitAnyDestructuring
sheetalkamat Aug 16, 2016
8fc17af
Move supportedTypescriptExtensionsWithDtsFirst next to supportedTypeS…
Aug 18, 2016
952d2fe
Fix comment
Aug 18, 2016
a621c09
Merge pull request #8241 from Microsoft/noImplicitAnyDestructuring
mhegazy Aug 18, 2016
03dcdda
Treat special property access symbol differently
Aug 19, 2016
297cb50
Merge branch 'master' into no_ts_extension
Aug 19, 2016
b452469
Fix tests
Aug 19, 2016
b482fa5
Merge branch 'master' into cast_of_await
Aug 19, 2016
19cde06
Merge pull request #9890 from Microsoft/cast_of_await
Aug 19, 2016
d2d5d42
Merge pull request #9646 from Microsoft/no_ts_extension
Aug 19, 2016
7f6e36c
Update shim version to be 2.1 (#10424)
yuit Aug 19, 2016
0168ab2
Check return code paths on getters (#10102)
weswigham Aug 19, 2016
da6d951
Remove extraneous arguments from harness's runBaseline (#10419)
weswigham Aug 19, 2016
6c60e5b
Remove needless call to basename
RyanCavanaugh Aug 19, 2016
def29f6
Merge pull request #10439 from RyanCavanaugh/fixJakeBaselineAccept
RyanCavanaugh Aug 19, 2016
8ad2744
Refactor baseliners out of compiler runner (#10440)
weswigham Aug 19, 2016
057357b
CR feedback
Aug 19, 2016
a5bb13f
fix broken tests
Aug 19, 2016
a531b87
Pass in baselineOpts into types baselines so that RWC baselines can b…
yuit Aug 20, 2016
d8ab098
Merge pull request #10426 from zhengbli/9518
zhengbli Aug 20, 2016
5732908
Merge branch 'master' into release-2.0
Aug 20, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove extraneous arguments from harness's runBaseline (#10419)
* Remove extraneous arguments from runBaseline

* Address comments from @yuit
  • Loading branch information
weswigham authored Aug 19, 2016
commit da6d95101fd8adfacbdb5209782dc560cf09c62f
16 changes: 8 additions & 8 deletions src/harness/compilerRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class CompilerBaselineRunner extends RunnerBase {
// check errors
it("Correct errors for " + fileName, () => {
if (this.errors) {
Harness.Baseline.runBaseline("Correct errors for " + fileName, justName.replace(/\.tsx?$/, ".errors.txt"), (): string => {
Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".errors.txt"), (): string => {
if (result.errors.length === 0) return null;
return getErrorBaseline(toBeCompiled, otherFiles, result);
});
Expand All @@ -156,7 +156,7 @@ class CompilerBaselineRunner extends RunnerBase {

it (`Correct module resolution tracing for ${fileName}`, () => {
if (options.traceResolution) {
Harness.Baseline.runBaseline("Correct module resolution tracing for " + fileName, justName.replace(/\.tsx?$/, ".trace.json"), () => {
Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".trace.json"), () => {
return JSON.stringify(result.traceResults || [], undefined, 4);
});
}
Expand All @@ -165,7 +165,7 @@ class CompilerBaselineRunner extends RunnerBase {
// Source maps?
it("Correct sourcemap content for " + fileName, () => {
if (options.sourceMap || options.inlineSourceMap) {
Harness.Baseline.runBaseline("Correct sourcemap content for " + fileName, justName.replace(/\.tsx?$/, ".sourcemap.txt"), () => {
Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".sourcemap.txt"), () => {
const record = result.getSourceMapRecord();
if (options.noEmitOnError && result.errors.length !== 0 && record === undefined) {
// Because of the noEmitOnError option no files are created. We need to return null because baselining isn"t required.
Expand All @@ -183,7 +183,7 @@ class CompilerBaselineRunner extends RunnerBase {
}

// check js output
Harness.Baseline.runBaseline("Correct JS output for " + fileName, justName.replace(/\.tsx?/, ".js"), () => {
Harness.Baseline.runBaseline(justName.replace(/\.tsx?/, ".js"), () => {
let tsCode = "";
const tsSources = otherFiles.concat(toBeCompiled);
if (tsSources.length > 1) {
Expand Down Expand Up @@ -242,7 +242,7 @@ class CompilerBaselineRunner extends RunnerBase {
throw new Error("Number of sourcemap files should be same as js files.");
}

Harness.Baseline.runBaseline("Correct Sourcemap output for " + fileName, justName.replace(/\.tsx?/, ".js.map"), () => {
Harness.Baseline.runBaseline(justName.replace(/\.tsx?/, ".js.map"), () => {
if (options.noEmitOnError && result.errors.length !== 0 && result.sourceMaps.length === 0) {
// We need to return null here or the runBaseLine will actually create a empty file.
// Baselining isn't required here because there is no output.
Expand Down Expand Up @@ -330,11 +330,11 @@ class CompilerBaselineRunner extends RunnerBase {
const pullExtension = isSymbolBaseLine ? ".symbols.pull" : ".types.pull";

if (fullBaseLine !== pullBaseLine) {
Harness.Baseline.runBaseline("Correct full information for " + fileName, justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine);
Harness.Baseline.runBaseline("Correct pull information for " + fileName, justName.replace(/\.tsx?/, pullExtension), () => pullBaseLine);
Harness.Baseline.runBaseline(justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine);
Harness.Baseline.runBaseline(justName.replace(/\.tsx?/, pullExtension), () => pullBaseLine);
}
else {
Harness.Baseline.runBaseline("Correct information for " + fileName, justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine);
Harness.Baseline.runBaseline(justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine);
}
}

Expand Down
12 changes: 3 additions & 9 deletions src/harness/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1132,12 +1132,10 @@ namespace FourSlash {

}
Harness.Baseline.runBaseline(
"Breakpoint Locations for " + this.activeFile.fileName,
baselineFile,
() => {
return this.baselineCurrentFileLocations(pos => this.getBreakpointStatementLocation(pos));
},
true /* run immediately */);
});
}

public baselineGetEmitOutput() {
Expand All @@ -1159,7 +1157,6 @@ namespace FourSlash {
}

Harness.Baseline.runBaseline(
"Generate getEmitOutput baseline : " + emitFiles.join(" "),
this.testData.globalOptions[metadataOptionNames.baselineFile],
() => {
let resultString = "";
Expand All @@ -1185,8 +1182,7 @@ namespace FourSlash {
});

return resultString;
},
true /* run immediately */);
});
}

public printBreakpointLocation(pos: number) {
Expand Down Expand Up @@ -1730,13 +1726,11 @@ namespace FourSlash {

public baselineCurrentFileNameOrDottedNameSpans() {
Harness.Baseline.runBaseline(
"Name OrDottedNameSpans for " + this.activeFile.fileName,
this.testData.globalOptions[metadataOptionNames.baselineFile],
() => {
return this.baselineCurrentFileLocations(pos =>
this.getNameOrDottedNameSpan(pos));
},
true /* run immediately */);
});
}

public printNameOrDottedNameSpans(pos: number) {
Expand Down
84 changes: 34 additions & 50 deletions src/harness/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1604,31 +1604,7 @@ namespace Harness {
}

const fileCache: { [idx: string]: boolean } = {};
function generateActual(actualFileName: string, generateContent: () => string): string {
// For now this is written using TypeScript, because sys is not available when running old test cases.
// But we need to move to sys once we have
// Creates the directory including its parent if not already present
function createDirectoryStructure(dirName: string) {
if (fileCache[dirName] || IO.directoryExists(dirName)) {
fileCache[dirName] = true;
return;
}

const parentDirectory = IO.directoryName(dirName);
if (parentDirectory != "") {
createDirectoryStructure(parentDirectory);
}
IO.createDirectory(dirName);
fileCache[dirName] = true;
}

// Create folders if needed
createDirectoryStructure(Harness.IO.directoryName(actualFileName));

// Delete the actual file in case it fails
if (IO.fileExists(actualFileName)) {
IO.deleteFile(actualFileName);
}
function generateActual(generateContent: () => string): string {

const actual = generateContent();

Expand Down Expand Up @@ -1663,43 +1639,51 @@ namespace Harness {
return { expected, actual };
}

function writeComparison(expected: string, actual: string, relativeFileName: string, actualFileName: string, descriptionForDescribe: string) {
function writeComparison(expected: string, actual: string, relativeFileName: string, actualFileName: string) {
// For now this is written using TypeScript, because sys is not available when running old test cases.
// But we need to move to sys once we have
// Creates the directory including its parent if not already present
function createDirectoryStructure(dirName: string) {
if (fileCache[dirName] || IO.directoryExists(dirName)) {
fileCache[dirName] = true;
return;
}

const parentDirectory = IO.directoryName(dirName);
if (parentDirectory != "") {
createDirectoryStructure(parentDirectory);
}
IO.createDirectory(dirName);
fileCache[dirName] = true;
}

// Create folders if needed
createDirectoryStructure(Harness.IO.directoryName(actualFileName));

// Delete the actual file in case it fails
if (IO.fileExists(actualFileName)) {
IO.deleteFile(actualFileName);
}

const encoded_actual = Utils.encodeString(actual);
if (expected !== encoded_actual) {
if (actual === NoContent) {
IO.writeFile(localPath(relativeFileName + ".delete"), "");
IO.writeFile(actualFileName + ".delete", "");
}
else {
IO.writeFile(localPath(relativeFileName), actual);
IO.writeFile(actualFileName, actual);
}
// Overwrite & issue error
const errMsg = "The baseline file " + relativeFileName + " has changed.";
throw new Error(errMsg);
throw new Error(`The baseline file ${relativeFileName} has changed.`);
}
}

export function runBaseline(relativeFileName: string, generateContent: () => string, opts?: BaselineOptions): void {

export function runBaseline(
descriptionForDescribe: string,
relativeFileName: string,
generateContent: () => string,
runImmediately = false,
opts?: BaselineOptions): void {

let actual = <string>undefined;
const actualFileName = localPath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder);

if (runImmediately) {
actual = generateActual(actualFileName, generateContent);
const comparison = compareToBaseline(actual, relativeFileName, opts);
writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName, descriptionForDescribe);
}
else {
actual = generateActual(actualFileName, generateContent);

const comparison = compareToBaseline(actual, relativeFileName, opts);
writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName, descriptionForDescribe);
}
const actual = generateActual(generateContent);
const comparison = compareToBaseline(actual, relativeFileName, opts);
writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName);
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/harness/projectsRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,15 +459,15 @@ class ProjectRunner extends RunnerBase {
});

it("Resolution information of (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => {
Harness.Baseline.runBaseline("Resolution information of (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".json", () => {
Harness.Baseline.runBaseline(getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".json", () => {
return JSON.stringify(getCompilerResolutionInfo(), undefined, " ");
});
});


it("Errors for (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => {
if (compilerResult.errors.length) {
Harness.Baseline.runBaseline("Errors for (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".errors.txt", () => {
Harness.Baseline.runBaseline(getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".errors.txt", () => {
return getErrorsBaseline(compilerResult);
});
}
Expand All @@ -481,7 +481,7 @@ class ProjectRunner extends RunnerBase {
// There may be multiple files with different baselines. Run all and report at the end, else
// it stops copying the remaining emitted files from 'local/projectOutput' to 'local/project'.
try {
Harness.Baseline.runBaseline("Baseline of emitted result (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => {
Harness.Baseline.runBaseline(getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => {
try {
return Harness.IO.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind));
}
Expand All @@ -503,7 +503,7 @@ class ProjectRunner extends RunnerBase {

it("SourceMapRecord for (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => {
if (compilerResult.sourceMapData) {
Harness.Baseline.runBaseline("SourceMapRecord for (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".sourcemap.txt", () => {
Harness.Baseline.runBaseline(getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".sourcemap.txt", () => {
return Harness.SourceMapRecorder.getSourceMapRecord(compilerResult.sourceMapData, compilerResult.program,
ts.filter(compilerResult.outputFiles, outputFile => Harness.Compiler.isJS(outputFile.emittedFileName)));
});
Expand All @@ -516,7 +516,7 @@ class ProjectRunner extends RunnerBase {
if (!compilerResult.errors.length && testCase.declaration) {
const dTsCompileResult = compileCompileDTsFiles(compilerResult);
if (dTsCompileResult && dTsCompileResult.errors.length) {
Harness.Baseline.runBaseline("Errors in generated Dts files for (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".dts.errors.txt", () => {
Harness.Baseline.runBaseline(getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".dts.errors.txt", () => {
return getErrorsBaseline(dTsCompileResult);
});
}
Expand Down
24 changes: 12 additions & 12 deletions src/harness/rwcRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,56 +158,56 @@ namespace RWC {


it("has the expected emitted code", () => {
Harness.Baseline.runBaseline("has the expected emitted code", baseName + ".output.js", () => {
Harness.Baseline.runBaseline(baseName + ".output.js", () => {
return Harness.Compiler.collateOutputs(compilerResult.files);
}, false, baselineOpts);
}, baselineOpts);
});

it("has the expected declaration file content", () => {
Harness.Baseline.runBaseline("has the expected declaration file content", baseName + ".d.ts", () => {
Harness.Baseline.runBaseline(baseName + ".d.ts", () => {
if (!compilerResult.declFilesCode.length) {
return null;
}

return Harness.Compiler.collateOutputs(compilerResult.declFilesCode);
}, false, baselineOpts);
}, baselineOpts);
});

it("has the expected source maps", () => {
Harness.Baseline.runBaseline("has the expected source maps", baseName + ".map", () => {
Harness.Baseline.runBaseline(baseName + ".map", () => {
if (!compilerResult.sourceMaps.length) {
return null;
}

return Harness.Compiler.collateOutputs(compilerResult.sourceMaps);
}, false, baselineOpts);
}, baselineOpts);
});

/*it("has correct source map record", () => {
if (compilerOptions.sourceMap) {
Harness.Baseline.runBaseline("has correct source map record", baseName + ".sourcemap.txt", () => {
Harness.Baseline.runBaseline(baseName + ".sourcemap.txt", () => {
return compilerResult.getSourceMapRecord();
}, false, baselineOpts);
}, baselineOpts);
}
});*/

it("has the expected errors", () => {
Harness.Baseline.runBaseline("has the expected errors", baseName + ".errors.txt", () => {
Harness.Baseline.runBaseline(baseName + ".errors.txt", () => {
if (compilerResult.errors.length === 0) {
return null;
}
// Do not include the library in the baselines to avoid noise
const baselineFiles = inputFiles.concat(otherFiles).filter(f => !Harness.isDefaultLibraryFile(f.unitName));
const errors = compilerResult.errors.filter(e => !Harness.isDefaultLibraryFile(e.file.fileName));
return Harness.Compiler.getErrorBaseline(baselineFiles, errors);
}, false, baselineOpts);
}, baselineOpts);
});

// Ideally, a generated declaration file will have no errors. But we allow generated
// declaration file errors as part of the baseline.
it("has the expected errors in generated declaration files", () => {
if (compilerOptions.declaration && !compilerResult.errors.length) {
Harness.Baseline.runBaseline("has the expected errors in generated declaration files", baseName + ".dts.errors.txt", () => {
Harness.Baseline.runBaseline(baseName + ".dts.errors.txt", () => {
const declFileCompilationResult = Harness.Compiler.compileDeclarationFiles(
inputFiles, otherFiles, compilerResult, /*harnessSettings*/ undefined, compilerOptions, currentDirectory);

Expand All @@ -218,7 +218,7 @@ namespace RWC {
return Harness.Compiler.minimalDiagnosticsToString(declFileCompilationResult.declResult.errors) +
Harness.IO.newLine() + Harness.IO.newLine() +
Harness.Compiler.getErrorBaseline(declFileCompilationResult.declInputFiles.concat(declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.errors);
}, false, baselineOpts);
}, baselineOpts);
}
});

Expand Down
Loading