Fix realPathMap in test harness: Must be used in directoryExists

This commit is contained in:
Andy Hanson 2016-10-31 08:23:02 -07:00
parent 44ce59d1d8
commit 03ce7b0145
7 changed files with 96 additions and 96 deletions

View file

@ -1029,7 +1029,7 @@ namespace Harness {
},
realpath: realPathMap && ((f: string) => {
const path = ts.toPath(f, currentDirectory, getCanonicalFileName);
return realPathMap.contains(path) ? realPathMap.get(path) : path;
return realPathMap.get(path) || path;
}),
directoryExists: dir => {
let path = ts.toPath(dir, currentDirectory, getCanonicalFileName);
@ -1037,12 +1037,20 @@ namespace Harness {
if (path[path.length - 1] === "/") {
path = <ts.Path>path.substr(0, path.length - 1);
}
let exists = false;
fileMap.forEachValue(key => {
if (key.indexOf(path) === 0 && key[path.length] === "/") {
fileMap.forEachValue(fileName => {
if (!exists && pathStartsWithDirectory(fileName, path)) {
exists = true;
}
});
if (!exists && realPathMap) {
realPathMap.forEachValue(fileName => {
if (!exists && pathStartsWithDirectory(fileName, path)) {
exists = true;
}
});
}
return exists;
},
getDirectories: d => {
@ -1064,6 +1072,10 @@ namespace Harness {
};
}
function pathStartsWithDirectory(fileName: string, directory: string) {
return ts.startsWith(fileName, directory) && fileName[directory.length] === "/";
}
interface HarnessOptions {
useCaseSensitiveFileNames?: boolean;
includeBuiltFile?: string;

View file

@ -1,21 +0,0 @@
/src/library-b/index.ts(1,23): error TS2307: Cannot find module 'library-a'.
==== /src/app.ts (0 errors) ====
import { MyClass } from "./library-a";
import { MyClass2 } from "./library-b";
let x: MyClass;
let y: MyClass2;
x = y;
y = x;
==== /src/library-a/index.ts (0 errors) ====
export class MyClass{}
==== /src/library-b/index.ts (1 errors) ====
import {MyClass} from "library-a";
~~~~~~~~~~~
!!! error TS2307: Cannot find module 'library-a'.
export { MyClass as MyClass2 }

View file

@ -2,7 +2,7 @@
//// [index.ts]
export class MyClass{}
export class MyClass { private x: number; }
//// [index.ts]
import {MyClass} from "library-a";

View file

@ -0,0 +1,37 @@
=== /src/app.ts ===
import { MyClass } from "./library-a";
>MyClass : Symbol(MyClass, Decl(app.ts, 0, 8))
import { MyClass2 } from "./library-b";
>MyClass2 : Symbol(MyClass2, Decl(app.ts, 1, 8))
let x: MyClass;
>x : Symbol(x, Decl(app.ts, 3, 3))
>MyClass : Symbol(MyClass, Decl(app.ts, 0, 8))
let y: MyClass2;
>y : Symbol(y, Decl(app.ts, 4, 3))
>MyClass2 : Symbol(MyClass2, Decl(app.ts, 1, 8))
x = y;
>x : Symbol(x, Decl(app.ts, 3, 3))
>y : Symbol(y, Decl(app.ts, 4, 3))
y = x;
>y : Symbol(y, Decl(app.ts, 4, 3))
>x : Symbol(x, Decl(app.ts, 3, 3))
=== /src/library-a/index.ts ===
export class MyClass { private x: number; }
>MyClass : Symbol(MyClass, Decl(index.ts, 0, 0))
>x : Symbol(MyClass.x, Decl(index.ts, 1, 22))
=== /src/library-b/index.ts ===
import {MyClass} from "library-a";
>MyClass : Symbol(MyClass, Decl(index.ts, 0, 8))
export { MyClass as MyClass2 }
>MyClass : Symbol(MyClass2, Decl(index.ts, 1, 8))
>MyClass2 : Symbol(MyClass2, Decl(index.ts, 1, 8))

View file

@ -26,74 +26,7 @@
"File '/src/library-b/node_modules/library-a.tsx' does not exist.",
"File '/src/library-b/node_modules/library-a.d.ts' does not exist.",
"File '/src/library-b/node_modules/library-a/package.json' does not exist.",
"File '/src/library-b/node_modules/library-a/index.ts' does not exist.",
"File '/src/library-b/node_modules/library-a/index.tsx' does not exist.",
"File '/src/library-b/node_modules/library-a/index.d.ts' does not exist.",
"File '/src/library-b/node_modules/@types/library-a.ts' does not exist.",
"File '/src/library-b/node_modules/@types/library-a.tsx' does not exist.",
"File '/src/library-b/node_modules/@types/library-a.d.ts' does not exist.",
"File '/src/library-b/node_modules/@types/library-a/package.json' does not exist.",
"File '/src/library-b/node_modules/@types/library-a/index.ts' does not exist.",
"File '/src/library-b/node_modules/@types/library-a/index.tsx' does not exist.",
"File '/src/library-b/node_modules/@types/library-a/index.d.ts' does not exist.",
"File '/src/node_modules/library-a.ts' does not exist.",
"File '/src/node_modules/library-a.tsx' does not exist.",
"File '/src/node_modules/library-a.d.ts' does not exist.",
"File '/src/node_modules/library-a/package.json' does not exist.",
"File '/src/node_modules/library-a/index.ts' does not exist.",
"File '/src/node_modules/library-a/index.tsx' does not exist.",
"File '/src/node_modules/library-a/index.d.ts' does not exist.",
"File '/src/node_modules/@types/library-a.ts' does not exist.",
"File '/src/node_modules/@types/library-a.tsx' does not exist.",
"File '/src/node_modules/@types/library-a.d.ts' does not exist.",
"File '/src/node_modules/@types/library-a/package.json' does not exist.",
"File '/src/node_modules/@types/library-a/index.ts' does not exist.",
"File '/src/node_modules/@types/library-a/index.tsx' does not exist.",
"File '/src/node_modules/@types/library-a/index.d.ts' does not exist.",
"File '/node_modules/library-a.ts' does not exist.",
"File '/node_modules/library-a.tsx' does not exist.",
"File '/node_modules/library-a.d.ts' does not exist.",
"File '/node_modules/library-a/package.json' does not exist.",
"File '/node_modules/library-a/index.ts' does not exist.",
"File '/node_modules/library-a/index.tsx' does not exist.",
"File '/node_modules/library-a/index.d.ts' does not exist.",
"File '/node_modules/@types/library-a.ts' does not exist.",
"File '/node_modules/@types/library-a.tsx' does not exist.",
"File '/node_modules/@types/library-a.d.ts' does not exist.",
"File '/node_modules/@types/library-a/package.json' does not exist.",
"File '/node_modules/@types/library-a/index.ts' does not exist.",
"File '/node_modules/@types/library-a/index.tsx' does not exist.",
"File '/node_modules/@types/library-a/index.d.ts' does not exist.",
"Loading module 'library-a' from 'node_modules' folder.",
"File '/src/library-b/node_modules/library-a.js' does not exist.",
"File '/src/library-b/node_modules/library-a.jsx' does not exist.",
"File '/src/library-b/node_modules/library-a/package.json' does not exist.",
"File '/src/library-b/node_modules/library-a/index.js' does not exist.",
"File '/src/library-b/node_modules/library-a/index.jsx' does not exist.",
"File '/src/library-b/node_modules/@types/library-a.js' does not exist.",
"File '/src/library-b/node_modules/@types/library-a.jsx' does not exist.",
"File '/src/library-b/node_modules/@types/library-a/package.json' does not exist.",
"File '/src/library-b/node_modules/@types/library-a/index.js' does not exist.",
"File '/src/library-b/node_modules/@types/library-a/index.jsx' does not exist.",
"File '/src/node_modules/library-a.js' does not exist.",
"File '/src/node_modules/library-a.jsx' does not exist.",
"File '/src/node_modules/library-a/package.json' does not exist.",
"File '/src/node_modules/library-a/index.js' does not exist.",
"File '/src/node_modules/library-a/index.jsx' does not exist.",
"File '/src/node_modules/@types/library-a.js' does not exist.",
"File '/src/node_modules/@types/library-a.jsx' does not exist.",
"File '/src/node_modules/@types/library-a/package.json' does not exist.",
"File '/src/node_modules/@types/library-a/index.js' does not exist.",
"File '/src/node_modules/@types/library-a/index.jsx' does not exist.",
"File '/node_modules/library-a.js' does not exist.",
"File '/node_modules/library-a.jsx' does not exist.",
"File '/node_modules/library-a/package.json' does not exist.",
"File '/node_modules/library-a/index.js' does not exist.",
"File '/node_modules/library-a/index.jsx' does not exist.",
"File '/node_modules/@types/library-a.js' does not exist.",
"File '/node_modules/@types/library-a.jsx' does not exist.",
"File '/node_modules/@types/library-a/package.json' does not exist.",
"File '/node_modules/@types/library-a/index.js' does not exist.",
"File '/node_modules/@types/library-a/index.jsx' does not exist.",
"======== Module name 'library-a' was not resolved. ========"
"File '/src/library-b/node_modules/library-a/index.ts' exist - use it as a name resolution result.",
"Resolving real path for '/src/library-b/node_modules/library-a/index.ts', result '/src/library-a/index.ts'",
"======== Module name 'library-a' was successfully resolved to '/src/library-a/index.ts'. ========"
]

View file

@ -0,0 +1,39 @@
=== /src/app.ts ===
import { MyClass } from "./library-a";
>MyClass : typeof MyClass
import { MyClass2 } from "./library-b";
>MyClass2 : typeof MyClass
let x: MyClass;
>x : MyClass
>MyClass : MyClass
let y: MyClass2;
>y : MyClass
>MyClass2 : MyClass
x = y;
>x = y : MyClass
>x : MyClass
>y : MyClass
y = x;
>y = x : MyClass
>y : MyClass
>x : MyClass
=== /src/library-a/index.ts ===
export class MyClass { private x: number; }
>MyClass : MyClass
>x : number
=== /src/library-b/index.ts ===
import {MyClass} from "library-a";
>MyClass : typeof MyClass
export { MyClass as MyClass2 }
>MyClass : typeof MyClass
>MyClass2 : typeof MyClass

View file

@ -4,7 +4,7 @@
// @filename: /src/library-a/index.ts
// @symlink: /src/library-b/node_modules/library-a/index.ts
export class MyClass{}
export class MyClass { private x: number; }
// @filename: /src/library-b/index.ts
import {MyClass} from "library-a";