Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
22 changes: 10 additions & 12 deletions src/harness/harnessIO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ export namespace Compiler {
compilerOptions: ts.CompilerOptions | undefined,
// Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file
currentDirectory: string | undefined,
rootDir?: string,
symlinks?: vfs.FileSet
): compiler.CompilationResult {
const options: ts.CompilerOptions & HarnessOptions = compilerOptions ? ts.cloneCompilerOptions(compilerOptions) : { noResolve: false };
Expand Down Expand Up @@ -451,7 +450,7 @@ export namespace Compiler {
fs.apply(symlinks);
}

ts.assign(options, ts.convertToOptionsWithAbsolutePaths(options, path => ts.getNormalizedAbsolutePath(ts.getNormalizedAbsolutePath(path, rootDir), currentDirectory)));
ts.assign(options, ts.convertToOptionsWithAbsolutePaths(options, path => ts.getNormalizedAbsolutePath(path, currentDirectory)));
const host = new fakes.CompilerHost(fs, options);
const result = compiler.compileFiles(host, programFileNames, options, typeScriptVersion);
result.symlinks = symlinks;
Expand Down Expand Up @@ -545,7 +544,7 @@ export namespace Compiler {
return;
}
const { declInputFiles, declOtherFiles, harnessSettings, options, currentDirectory } = context;
const output = compileFiles(declInputFiles, declOtherFiles, harnessSettings, options, currentDirectory, /*rootDir*/ undefined, symlinks);
const output = compileFiles(declInputFiles, declOtherFiles, harnessSettings, options, currentDirectory, symlinks);
return { declInputFiles, declOtherFiles, declResult: output };
}

Expand Down Expand Up @@ -735,7 +734,7 @@ export namespace Compiler {
!errors || (errors.length === 0) ? null : getErrorBaseline(inputFiles, errors, pretty)); // eslint-disable-line no-null/no-null
}

export function doTypeAndSymbolBaseline(baselinePath: string, program: ts.Program, allFiles: {unitName: string, content: string}[], opts?: Baseline.BaselineOptions, multifile?: boolean, skipTypeBaselines?: boolean, skipSymbolBaselines?: boolean, hasErrorBaseline?: boolean) {
export function doTypeAndSymbolBaseline(baselinePath: string, header: string, program: ts.Program, allFiles: {unitName: string, content: string}[], opts?: Baseline.BaselineOptions, multifile?: boolean, skipTypeBaselines?: boolean, skipSymbolBaselines?: boolean, hasErrorBaseline?: boolean) {
// The full walker simulates the types that you would get from doing a full
// compile. The pull walker simulates the types you get when you just do
// a type query for a random node (like how the LS would do it). Most of the
Expand Down Expand Up @@ -810,7 +809,7 @@ export namespace Compiler {
const [, content] = value;
result += content;
}
return result || null; // eslint-disable-line no-null/no-null
return result ? (`//// [${header}] ////\r\n\r\n` + result) : null; // eslint-disable-line no-null/no-null
}

function *iterateBaseLine(isSymbolBaseline: boolean, skipBaseline?: boolean): IterableIterator<[string, string]> {
Expand Down Expand Up @@ -911,9 +910,8 @@ export namespace Compiler {
// check js output
let tsCode = "";
const tsSources = otherFiles.concat(toBeCompiled);
if (tsSources.length > 1) {
tsCode += "//// [" + header + "] ////\r\n\r\n";
}
tsCode += "//// [" + header + "] ////\r\n\r\n";

for (let i = 0; i < tsSources.length; i++) {
tsCode += "//// [" + ts.getBaseFileName(tsSources[i].unitName) + "]\r\n";
tsCode += tsSources[i].content + (i < (tsSources.length - 1) ? "\r\n" : "");
Expand Down Expand Up @@ -1208,7 +1206,7 @@ export namespace TestCaseParser {
}

/** Given a test file containing // @FileName directives, return an array of named units of code to be added to an existing compiler instance */
export function makeUnitsFromTest(code: string, fileName: string, rootDir: string, settings = extractCompilerSettings(code)): TestCaseContent {
export function makeUnitsFromTest(code: string, fileName: string, settings = extractCompilerSettings(code)): TestCaseContent {
// List of all the subfiles we've parsed out
const testUnitData: TestUnitData[] = [];

Expand All @@ -1223,7 +1221,7 @@ export namespace TestCaseParser {

for (const line of lines) {
let testMetaData: RegExpExecArray | null;
const possiblySymlinks = parseSymlinkFromTest(line, symlinks, ts.getNormalizedAbsolutePath(rootDir, vfs.srcFolder));
const possiblySymlinks = parseSymlinkFromTest(line, symlinks, vfs.srcFolder);
if (possiblySymlinks) {
symlinks = possiblySymlinks;
}
Expand Down Expand Up @@ -1294,7 +1292,7 @@ export namespace TestCaseParser {
const files: string[] = [];
const directories = new Set<string>();
for (const unit of testUnitData) {
const fileName = ts.getNormalizedAbsolutePath(ts.getNormalizedAbsolutePath(unit.name, rootDir), vfs.srcFolder);
const fileName = ts.getNormalizedAbsolutePath(unit.name, vfs.srcFolder);
if (fileName.toLowerCase().startsWith(dir.toLowerCase())) {
let path = fileName.substring(dir.length);
if (path.startsWith("/")) {
Expand Down Expand Up @@ -1325,7 +1323,7 @@ export namespace TestCaseParser {
if (getConfigNameFromFileName(data.name)) {
const configJson = ts.parseJsonText(data.name, data.content);
assert.isTrue(configJson.endOfFileToken !== undefined);
const configFileName = ts.getNormalizedAbsolutePath(ts.getNormalizedAbsolutePath(data.name, rootDir), vfs.srcFolder);
const configFileName = ts.getNormalizedAbsolutePath(data.name, vfs.srcFolder);
const configDir = ts.getDirectoryPath(configFileName);
tsConfig = ts.parseJsonSourceFileConfigFileContent(configJson, parseConfigHost, configDir, /*existingOptions*/ undefined, configFileName);
tsConfigFileUnitData = data;
Expand Down
16 changes: 7 additions & 9 deletions src/testRunner/compilerRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,10 @@ export class CompilerBaselineRunner extends RunnerBase {
let compilerTest!: CompilerTest;
before(() => {
let payload;
let rootDir = fileName.indexOf("conformance") === -1 ? "tests/cases/compiler/" : ts.getDirectoryPath(fileName) + "/";
if (test && test.content) {
rootDir = test.file.indexOf("conformance") === -1 ? "tests/cases/compiler/" : ts.getDirectoryPath(test.file) + "/";
payload = TestCaseParser.makeUnitsFromTest(test.content, test.file, rootDir);
payload = TestCaseParser.makeUnitsFromTest(test.content, test.file);
}
compilerTest = new CompilerTest(fileName, rootDir, payload, configuration);
compilerTest = new CompilerTest(fileName, payload, configuration);
});
it(`Correct errors for ${fileName}`, () => compilerTest.verifyDiagnostics());
it(`Correct module resolution tracing for ${fileName}`, () => compilerTest.verifyModuleResolution());
Expand Down Expand Up @@ -179,8 +177,8 @@ class CompilerTest {
// equivalent to other files on the file system not directly passed to the compiler (ie things that are referenced by other files)
private otherFiles: Compiler.TestFile[];

constructor(fileName: string, private rootDir: string, testCaseContent?: TestCaseParser.TestCaseContent, configurationOverrides?: TestCaseParser.CompilerSettings) {
const absoluteRootDir = ts.getNormalizedAbsolutePath(rootDir, vfs.srcFolder);
constructor(fileName: string, testCaseContent?: TestCaseParser.TestCaseContent, configurationOverrides?: TestCaseParser.CompilerSettings) {
const absoluteRootDir = vfs.srcFolder;
this.fileName = fileName;
this.justName = vpath.basename(fileName);
this.configuredName = this.justName;
Expand All @@ -203,7 +201,7 @@ class CompilerTest {
}

if (testCaseContent === undefined) {
testCaseContent = TestCaseParser.makeUnitsFromTest(IO.readFile(fileName)!, fileName, rootDir);
testCaseContent = TestCaseParser.makeUnitsFromTest(IO.readFile(fileName)!, fileName);
}

if (configurationOverrides) {
Expand Down Expand Up @@ -265,7 +263,6 @@ class CompilerTest {
this.harnessSettings,
/*options*/ tsConfigOptions,
/*currentDirectory*/ this.harnessSettings.currentDirectory,
this.rootDir,
testCaseContent.symlinks
);

Expand Down Expand Up @@ -343,6 +340,7 @@ class CompilerTest {

Compiler.doTypeAndSymbolBaseline(
this.configuredName,
this.fileName,
this.result.program!,
this.toBeCompiled.concat(this.otherFiles).filter(file => !!this.result.program!.getSourceFile(file.unitName)),
/*opts*/ undefined,
Expand All @@ -355,7 +353,7 @@ class CompilerTest {

private createHarnessTestFile(unit: TestCaseParser.TestUnitData): Compiler.TestFile {
return {
unitName: ts.getNormalizedAbsolutePath(unit.name, this.rootDir),
unitName: unit.name,
content: unit.content,
fileOptions: unit.fileOptions
};
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/1.0lib-noErrors.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//// [tests/cases/conformance/decorators/1.0lib-noErrors.ts] ////

//// [1.0lib-noErrors.ts]
/* *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Expand Down
4 changes: 3 additions & 1 deletion tests/baselines/reference/1.0lib-noErrors.symbols
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
=== tests/cases/conformance/decorators/1.0lib-noErrors.ts ===
//// [tests/cases/conformance/decorators/1.0lib-noErrors.ts] ////

=== 1.0lib-noErrors.ts ===
/* *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
Expand Down
4 changes: 3 additions & 1 deletion tests/baselines/reference/1.0lib-noErrors.types
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
=== tests/cases/conformance/decorators/1.0lib-noErrors.ts ===
//// [tests/cases/conformance/decorators/1.0lib-noErrors.ts] ////

=== 1.0lib-noErrors.ts ===
/* *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/2dArrays.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//// [tests/cases/compiler/2dArrays.ts] ////

//// [2dArrays.ts]
class Cell {
}
Expand Down
4 changes: 3 additions & 1 deletion tests/baselines/reference/2dArrays.symbols
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
=== tests/cases/compiler/2dArrays.ts ===
//// [tests/cases/compiler/2dArrays.ts] ////

=== 2dArrays.ts ===
class Cell {
>Cell : Symbol(Cell, Decl(2dArrays.ts, 0, 0))
}
Expand Down
4 changes: 3 additions & 1 deletion tests/baselines/reference/2dArrays.types
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
=== tests/cases/compiler/2dArrays.ts ===
//// [tests/cases/compiler/2dArrays.ts] ////

=== 2dArrays.ts ===
class Cell {
>Cell : Cell
}
Expand Down
4 changes: 3 additions & 1 deletion tests/baselines/reference/APILibCheck.symbols
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
=== tests/cases/compiler/index.ts ===
//// [tests/cases/compiler/APILibCheck.ts] ////

=== index.ts ===
import ts = require("typescript");
>ts : Symbol(ts, Decl(index.ts, 0, 0))

Expand Down
4 changes: 3 additions & 1 deletion tests/baselines/reference/APILibCheck.types
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
=== tests/cases/compiler/index.ts ===
//// [tests/cases/compiler/APILibCheck.ts] ////

=== index.ts ===
import ts = require("typescript");
>ts : typeof ts

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
//// [tests/cases/conformance/internalModules/DeclarationMerging/AmbientModuleAndAmbientFunctionWithTheSameNameAndCommonRoot.ts] ////

=== module.d.ts ===
declare module Point {
>Point : Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.d.ts, 0, 0))

Expand All @@ -8,13 +10,13 @@ declare module Point {
>y : Symbol(y, Decl(module.d.ts, 1, 35))
}

=== tests/cases/conformance/internalModules/DeclarationMerging/function.d.ts ===
=== function.d.ts ===
declare function Point(): { x: number; y: number; }
>Point : Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.d.ts, 0, 0))
>x : Symbol(x, Decl(function.d.ts, 0, 27))
>y : Symbol(y, Decl(function.d.ts, 0, 38))

=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===
=== test.ts ===
var cl: { x: number; y: number; }
>cl : Symbol(cl, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
>x : Symbol(x, Decl(test.ts, 0, 9))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
//// [tests/cases/conformance/internalModules/DeclarationMerging/AmbientModuleAndAmbientFunctionWithTheSameNameAndCommonRoot.ts] ////

=== module.d.ts ===
declare module Point {
>Point : typeof Point

Expand All @@ -8,13 +10,13 @@ declare module Point {
>y : number
}

=== tests/cases/conformance/internalModules/DeclarationMerging/function.d.ts ===
=== function.d.ts ===
declare function Point(): { x: number; y: number; }
>Point : typeof Point
>x : number
>y : number

=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===
=== test.ts ===
var cl: { x: number; y: number; }
>cl : { x: number; y: number; }
>x : number
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
//// [tests/cases/conformance/internalModules/DeclarationMerging/AmbientModuleAndAmbientWithSameNameAndCommonRoot.ts] ////

=== module.d.ts ===
declare module A {
>A : Symbol(A, Decl(module.d.ts, 0, 0), Decl(class.d.ts, 0, 0))

Expand All @@ -17,7 +19,7 @@ declare module A {
}
}

=== tests/cases/conformance/internalModules/DeclarationMerging/class.d.ts ===
=== class.d.ts ===
declare module A {
>A : Symbol(A, Decl(module.d.ts, 0, 0), Decl(class.d.ts, 0, 0))

Expand All @@ -36,7 +38,7 @@ declare module A {
}
}

=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===
=== test.ts ===
var p: { x: number; y: number; }
>p : Symbol(p, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
>x : Symbol(x, Decl(test.ts, 0, 8))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
//// [tests/cases/conformance/internalModules/DeclarationMerging/AmbientModuleAndAmbientWithSameNameAndCommonRoot.ts] ////

=== module.d.ts ===
declare module A {
>A : typeof A

Expand All @@ -17,7 +19,7 @@ declare module A {
}
}

=== tests/cases/conformance/internalModules/DeclarationMerging/class.d.ts ===
=== class.d.ts ===
declare module A {
>A : typeof A

Expand All @@ -36,7 +38,7 @@ declare module A {
}
}

=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===
=== test.ts ===
var p: { x: number; y: number; }
>p : { x: number; y: number; }
>x : number
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
//// [tests/cases/conformance/internalModules/DeclarationMerging/AmbientModuleAndNonAmbientClassWithSameNameAndCommonRoot.ts] ////

=== module.d.ts ===
declare module A {
>A : Symbol(A, Decl(module.d.ts, 0, 0), Decl(classPoint.ts, 0, 0))

Expand All @@ -17,7 +19,7 @@ declare module A {
}
}

=== tests/cases/conformance/internalModules/DeclarationMerging/classPoint.ts ===
=== classPoint.ts ===
module A {
>A : Symbol(A, Decl(module.d.ts, 0, 0), Decl(classPoint.ts, 0, 0))

Expand All @@ -30,7 +32,7 @@ module A {
}
}

=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===
=== test.ts ===
var p: { x: number; y: number; }
>p : Symbol(p, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
>x : Symbol(x, Decl(test.ts, 0, 8))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
//// [tests/cases/conformance/internalModules/DeclarationMerging/AmbientModuleAndNonAmbientClassWithSameNameAndCommonRoot.ts] ////

=== module.d.ts ===
declare module A {
>A : typeof A

Expand All @@ -17,7 +19,7 @@ declare module A {
}
}

=== tests/cases/conformance/internalModules/DeclarationMerging/classPoint.ts ===
=== classPoint.ts ===
module A {
>A : typeof A

Expand All @@ -30,7 +32,7 @@ module A {
}
}

=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===
=== test.ts ===
var p: { x: number; y: number; }
>p : { x: number; y: number; }
>x : number
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
//// [tests/cases/conformance/internalModules/DeclarationMerging/AmbientModuleAndNonAmbientFunctionWithTheSameNameAndCommonRoot.ts] ////

=== module.d.ts ===
declare module Point {
>Point : Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.ts, 0, 0))

Expand All @@ -8,7 +10,7 @@ declare module Point {
>y : Symbol(y, Decl(module.d.ts, 1, 35))
}

=== tests/cases/conformance/internalModules/DeclarationMerging/function.ts ===
=== function.ts ===
function Point() {
>Point : Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.ts, 0, 0))

Expand All @@ -17,7 +19,7 @@ function Point() {
>y : Symbol(y, Decl(function.ts, 1, 18))
}

=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===
=== test.ts ===
var cl: { x: number; y: number; }
>cl : Symbol(cl, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
>x : Symbol(x, Decl(test.ts, 0, 9))
Expand Down
Loading