mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-10 21:07:52 -05:00
Support to tests for absolute paths, add common src dir edgecase tests
This commit is contained in:
@@ -45,14 +45,10 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
// Mocha holds onto the closure environment of the describe callback even after the test is done.
|
||||
// Everything declared here should be cleared out in the "after" callback.
|
||||
let justName: string;
|
||||
let content: string;
|
||||
let testCaseContent: { settings: Harness.TestCaseParser.CompilerSettings; testUnitData: Harness.TestCaseParser.TestUnitData[]; };
|
||||
|
||||
let units: Harness.TestCaseParser.TestUnitData[];
|
||||
let tcSettings: Harness.TestCaseParser.CompilerSettings;
|
||||
|
||||
let lastUnit: Harness.TestCaseParser.TestUnitData;
|
||||
let rootDir: string;
|
||||
|
||||
let result: Harness.Compiler.CompilerResult;
|
||||
let program: ts.Program;
|
||||
@@ -65,12 +61,12 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
|
||||
before(() => {
|
||||
justName = fileName.replace(/^.*[\\\/]/, ""); // strips the fileName from the path.
|
||||
content = Harness.IO.readFile(fileName);
|
||||
testCaseContent = Harness.TestCaseParser.makeUnitsFromTest(content, fileName);
|
||||
units = testCaseContent.testUnitData;
|
||||
const content = Harness.IO.readFile(fileName);
|
||||
const testCaseContent = Harness.TestCaseParser.makeUnitsFromTest(content, fileName);
|
||||
const units = testCaseContent.testUnitData;
|
||||
tcSettings = testCaseContent.settings;
|
||||
lastUnit = units[units.length - 1];
|
||||
rootDir = lastUnit.originalFilePath.indexOf("conformance") === -1 ? "tests/cases/compiler/" : lastUnit.originalFilePath.substring(0, lastUnit.originalFilePath.lastIndexOf("/")) + "/";
|
||||
const rootDir = lastUnit.originalFilePath.indexOf("conformance") === -1 ? "tests/cases/compiler/" : lastUnit.originalFilePath.substring(0, lastUnit.originalFilePath.lastIndexOf("/")) + "/";
|
||||
harnessCompiler = Harness.Compiler.getCompiler();
|
||||
// We need to assemble the list of input files for the compiler and other related files on the 'filesystem' (ie in a multi-file test)
|
||||
// If the last file in a test uses require or a triple slash reference we'll assume all other files will be brought in via references,
|
||||
@@ -78,16 +74,16 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
toBeCompiled = [];
|
||||
otherFiles = [];
|
||||
if (/require\(/.test(lastUnit.content) || /reference\spath/.test(lastUnit.content)) {
|
||||
toBeCompiled.push({ unitName: rootDir + lastUnit.name, content: lastUnit.content });
|
||||
toBeCompiled.push({ unitName: ts.isRootedDiskPath(lastUnit.name) ? lastUnit.name : rootDir + lastUnit.name, content: lastUnit.content });
|
||||
units.forEach(unit => {
|
||||
if (unit.name !== lastUnit.name) {
|
||||
otherFiles.push({ unitName: rootDir + unit.name, content: unit.content });
|
||||
otherFiles.push({ unitName: ts.isRootedDiskPath(unit.name) ? unit.name : rootDir + unit.name, content: unit.content });
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
toBeCompiled = units.map(unit => {
|
||||
return { unitName: rootDir + unit.name, content: unit.content };
|
||||
return { unitName: ts.isRootedDiskPath(unit.name) ? unit.name : rootDir + unit.name, content: unit.content };
|
||||
});
|
||||
}
|
||||
|
||||
@@ -104,12 +100,8 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
// 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.
|
||||
justName = undefined;
|
||||
content = undefined;
|
||||
testCaseContent = undefined;
|
||||
units = undefined;
|
||||
tcSettings = undefined;
|
||||
lastUnit = undefined;
|
||||
rootDir = undefined;
|
||||
result = undefined;
|
||||
program = undefined;
|
||||
options = undefined;
|
||||
|
||||
13
tests/baselines/reference/commonSourceDir1.js
Normal file
13
tests/baselines/reference/commonSourceDir1.js
Normal file
@@ -0,0 +1,13 @@
|
||||
//// [tests/cases/compiler/commonSourceDir1.ts] ////
|
||||
|
||||
//// [bar.ts]
|
||||
var x: number;
|
||||
|
||||
//// [baz.ts]
|
||||
var y: number;
|
||||
|
||||
|
||||
//// [bar.js]
|
||||
var x;
|
||||
//// [baz.js]
|
||||
var y;
|
||||
8
tests/baselines/reference/commonSourceDir1.symbols
Normal file
8
tests/baselines/reference/commonSourceDir1.symbols
Normal file
@@ -0,0 +1,8 @@
|
||||
=== A:/foo/bar.ts ===
|
||||
var x: number;
|
||||
>x : Symbol(x, Decl(bar.ts, 0, 3))
|
||||
|
||||
=== A:/foo/baz.ts ===
|
||||
var y: number;
|
||||
>y : Symbol(y, Decl(baz.ts, 0, 3))
|
||||
|
||||
8
tests/baselines/reference/commonSourceDir1.types
Normal file
8
tests/baselines/reference/commonSourceDir1.types
Normal file
@@ -0,0 +1,8 @@
|
||||
=== A:/foo/bar.ts ===
|
||||
var x: number;
|
||||
>x : number
|
||||
|
||||
=== A:/foo/baz.ts ===
|
||||
var y: number;
|
||||
>y : number
|
||||
|
||||
9
tests/baselines/reference/commonSourceDir2.errors.txt
Normal file
9
tests/baselines/reference/commonSourceDir2.errors.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
error TS5009: Cannot find the common subdirectory path for the input files.
|
||||
|
||||
|
||||
!!! error TS5009: Cannot find the common subdirectory path for the input files.
|
||||
==== A:/foo/bar.ts (0 errors) ====
|
||||
var x: number;
|
||||
|
||||
==== B:/foo/baz.ts (0 errors) ====
|
||||
var y: number;
|
||||
12
tests/baselines/reference/commonSourceDir2.js
Normal file
12
tests/baselines/reference/commonSourceDir2.js
Normal file
@@ -0,0 +1,12 @@
|
||||
//// [tests/cases/compiler/commonSourceDir2.ts] ////
|
||||
|
||||
//// [bar.ts]
|
||||
var x: number;
|
||||
|
||||
//// [baz.ts]
|
||||
var y: number;
|
||||
|
||||
//// [bar.js]
|
||||
var x;
|
||||
//// [baz.js]
|
||||
var y;
|
||||
12
tests/baselines/reference/commonSourceDir3.js
Normal file
12
tests/baselines/reference/commonSourceDir3.js
Normal file
@@ -0,0 +1,12 @@
|
||||
//// [tests/cases/compiler/commonSourceDir3.ts] ////
|
||||
|
||||
//// [bar.ts]
|
||||
var x: number;
|
||||
|
||||
//// [baz.ts]
|
||||
var y: number;
|
||||
|
||||
//// [bar.js]
|
||||
var x;
|
||||
//// [baz.js]
|
||||
var y;
|
||||
8
tests/baselines/reference/commonSourceDir3.symbols
Normal file
8
tests/baselines/reference/commonSourceDir3.symbols
Normal file
@@ -0,0 +1,8 @@
|
||||
=== A:/foo/bar.ts ===
|
||||
var x: number;
|
||||
>x : Symbol(x, Decl(bar.ts, 0, 3))
|
||||
|
||||
=== a:/foo/baz.ts ===
|
||||
var y: number;
|
||||
>y : Symbol(y, Decl(baz.ts, 0, 3))
|
||||
|
||||
8
tests/baselines/reference/commonSourceDir3.types
Normal file
8
tests/baselines/reference/commonSourceDir3.types
Normal file
@@ -0,0 +1,8 @@
|
||||
=== A:/foo/bar.ts ===
|
||||
var x: number;
|
||||
>x : number
|
||||
|
||||
=== a:/foo/baz.ts ===
|
||||
var y: number;
|
||||
>y : number
|
||||
|
||||
9
tests/baselines/reference/commonSourceDir4.errors.txt
Normal file
9
tests/baselines/reference/commonSourceDir4.errors.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
error TS5009: Cannot find the common subdirectory path for the input files.
|
||||
|
||||
|
||||
!!! error TS5009: Cannot find the common subdirectory path for the input files.
|
||||
==== A:/foo/bar.ts (0 errors) ====
|
||||
var x: number;
|
||||
|
||||
==== a:/foo/baz.ts (0 errors) ====
|
||||
var y: number;
|
||||
12
tests/baselines/reference/commonSourceDir4.js
Normal file
12
tests/baselines/reference/commonSourceDir4.js
Normal file
@@ -0,0 +1,12 @@
|
||||
//// [tests/cases/compiler/commonSourceDir4.ts] ////
|
||||
|
||||
//// [bar.ts]
|
||||
var x: number;
|
||||
|
||||
//// [baz.ts]
|
||||
var y: number;
|
||||
|
||||
//// [bar.js]
|
||||
var x;
|
||||
//// [baz.js]
|
||||
var y;
|
||||
6
tests/cases/compiler/commonSourceDir1.ts
Normal file
6
tests/cases/compiler/commonSourceDir1.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
// @outDir: A:/
|
||||
// @Filename: A:/foo/bar.ts
|
||||
var x: number;
|
||||
|
||||
// @Filename: A:/foo/baz.ts
|
||||
var y: number;
|
||||
6
tests/cases/compiler/commonSourceDir2.ts
Normal file
6
tests/cases/compiler/commonSourceDir2.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
// @outDir: A:/
|
||||
// @Filename: A:/foo/bar.ts
|
||||
var x: number;
|
||||
|
||||
// @Filename: B:/foo/baz.ts
|
||||
var y: number;
|
||||
6
tests/cases/compiler/commonSourceDir3.ts
Normal file
6
tests/cases/compiler/commonSourceDir3.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
// @outDir: A:/
|
||||
// @Filename: A:/foo/bar.ts
|
||||
var x: number;
|
||||
|
||||
// @Filename: a:/foo/baz.ts
|
||||
var y: number;
|
||||
7
tests/cases/compiler/commonSourceDir4.ts
Normal file
7
tests/cases/compiler/commonSourceDir4.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
// @useCaseSensitiveFileNames: true
|
||||
// @outDir: A:/
|
||||
// @Filename: A:/foo/bar.ts
|
||||
var x: number;
|
||||
|
||||
// @Filename: a:/foo/baz.ts
|
||||
var y: number;
|
||||
Reference in New Issue
Block a user