Skip to content

Commit

Permalink
Convert symlink scenarios to virtual FS where its symlinks are correc…
Browse files Browse the repository at this point in the history
…tly maintained

Adds test for #36866
  • Loading branch information
sheetalkamat committed Mar 17, 2020
1 parent 9120497 commit eb34d7c
Show file tree
Hide file tree
Showing 11 changed files with 1,458 additions and 204 deletions.
4 changes: 2 additions & 2 deletions src/harness/virtualFileSystemWithWatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ interface Array<T> { length: number; [n: number]: T; }`
}

export type FileOrFolderOrSymLink = File | Folder | SymLink;
function isFile(fileOrFolderOrSymLink: FileOrFolderOrSymLink): fileOrFolderOrSymLink is File {
export function isFile(fileOrFolderOrSymLink: FileOrFolderOrSymLink): fileOrFolderOrSymLink is File {
return isString((<File>fileOrFolderOrSymLink).content);
}

function isSymLink(fileOrFolderOrSymLink: FileOrFolderOrSymLink): fileOrFolderOrSymLink is SymLink {
export function isSymLink(fileOrFolderOrSymLink: FileOrFolderOrSymLink): fileOrFolderOrSymLink is SymLink {
return isString((<SymLink>fileOrFolderOrSymLink).symLink);
}

Expand Down
344 changes: 229 additions & 115 deletions src/testRunner/unittests/tsc/declarationEmit.ts

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion src/testRunner/unittests/tscWatch/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ namespace ts.tscWatch {
baselineSourceMap
} = input;

if (!isWatch(commandLineArgs)) sys.exit = exitCode => sys.exitCode = exitCode;
const { cb, getPrograms } = commandLineCallbacks(sys);
const watchOrSolution = executeCommandLine(
sys,
Expand Down Expand Up @@ -352,7 +353,17 @@ namespace ts.tscWatch {
baselineSourceMap
});
}
Harness.Baseline.runBaseline(`${isBuild(commandLineArgs) ? "tsbuild/watchMode" : "tscWatch"}/${scenario}/${subScenario.split(" ").join("-")}.js`, baseline.join("\r\n"));
Harness.Baseline.runBaseline(`${isBuild(commandLineArgs) ?
isWatch(commandLineArgs) ? "tsbuild/watchMode" : "tsbuild" :
isWatch(commandLineArgs) ? "tscWatch" : "tsc"}/${scenario}/${subScenario.split(" ").join("-")}.js`, baseline.join("\r\n"));
}

function isWatch(commandLineArgs: readonly string[]) {
return forEach(commandLineArgs, arg => {
if (arg.charCodeAt(0) !== CharacterCodes.minus) return false;
const option = arg.slice(arg.charCodeAt(1) === CharacterCodes.minus ? 2 : 1).toLowerCase();
return option === "watch" || option === "w";
});
}

export interface WatchBaseline extends TscWatchCheckOptions {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/a/lib/tsc.js -p pkg3 --listFiles
//// [/user/username/projects/myProject/pkg1/dist/index.d.ts]
export * from './types';

//// [/user/username/projects/myProject/pkg1/dist/types.d.ts]
export declare type A = {
id: string;
};
export declare type B = {
id: number;
};
export declare type IdType = A | B;
export declare class MetadataAccessor<T, D extends IdType = IdType> {
readonly key: string;
private constructor();
toString(): string;
static create<T, D extends IdType = IdType>(key: string): MetadataAccessor<T, D>;
}

//// [/user/username/projects/myProject/pkg1/package.json]
{"name":"@raymondfeng/pkg1","version":"1.0.0","main":"dist/index.js","typings":"dist/index.d.ts"}

//// [/user/username/projects/myproject/pkg2/dist/index.d.ts]
export * from './types';

//// [/user/username/projects/myproject/pkg2/dist/types.d.ts]
export {MetadataAccessor} from '@raymondfeng/pkg1';

//// [/user/username/projects/myproject/pkg2/package.json]
{"name":"@raymondfeng/pkg2","version":"1.0.0","main":"dist/index.js","typings":"dist/index.d.ts"}

//// [/user/username/projects/myproject/pkg3/src/index.ts]
export * from './keys';

//// [/user/username/projects/myproject/pkg3/src/keys.ts]
import {MetadataAccessor} from "@raymondfeng/pkg2";
export const ADMIN = MetadataAccessor.create<boolean>('1');

//// [/user/username/projects/myproject/pkg3/tsconfig.json]
{"compilerOptions":{"outDir":"dist","rootDir":"src","target":"es5","module":"commonjs","strict":true,"esModuleInterop":true,"declaration":true}}

//// [/user/username/projects/myProject/pkg2/node_modules/@raymondfeng/pkg1] symlink(/user/username/projects/myProject/pkg1)
//// [/user/username/projects/myproject/pkg3/node_modules/@raymondfeng/pkg2] symlink(/user/username/projects/myproject/pkg2)
//// [/a/lib/lib.d.ts]
/// <reference no-default-lib="true"/>
interface Boolean {}
interface Function {}
interface CallableFunction {}
interface NewableFunction {}
interface IArguments {}
interface Number { toExponential: any; }
interface Object {}
interface RegExp {}
interface String { charAt: any; }
interface Array<T> { length: number; [n: number]: T; }

//// [/user/username/projects/myproject/pkg3/dist/keys.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ADMIN = void 0;
var pkg2_1 = require("@raymondfeng/pkg2");
exports.ADMIN = pkg2_1.MetadataAccessor.create('1');


//// [/user/username/projects/myproject/pkg3/dist/keys.d.ts]
import { MetadataAccessor } from "@raymondfeng/pkg2";
export declare const ADMIN: MetadataAccessor<boolean, import("../../pkg1/dist").IdType>;


//// [/user/username/projects/myproject/pkg3/dist/index.js]
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./keys"), exports);


//// [/user/username/projects/myproject/pkg3/dist/index.d.ts]
export * from './keys';



Output::
/a/lib/lib.d.ts

/user/username/projects/myProject/pkg1/dist/types.d.ts

/user/username/projects/myProject/pkg1/dist/index.d.ts

/user/username/projects/myproject/pkg2/dist/types.d.ts

/user/username/projects/myproject/pkg2/dist/index.d.ts

/user/username/projects/myproject/pkg3/src/keys.ts

/user/username/projects/myproject/pkg3/src/index.ts



Program root files: ["/user/username/projects/myproject/pkg3/src/index.ts","/user/username/projects/myproject/pkg3/src/keys.ts"]
Program options: {"outDir":"/user/username/projects/myproject/pkg3/dist","rootDir":"/user/username/projects/myproject/pkg3/src","target":1,"module":1,"strict":true,"esModuleInterop":true,"declaration":true,"project":"/user/username/projects/myproject/pkg3","listFiles":true,"configFilePath":"/user/username/projects/myproject/pkg3/tsconfig.json"}
Program files::
/a/lib/lib.d.ts
/user/username/projects/myProject/pkg1/dist/types.d.ts
/user/username/projects/myProject/pkg1/dist/index.d.ts
/user/username/projects/myproject/pkg2/dist/types.d.ts
/user/username/projects/myproject/pkg2/dist/index.d.ts
/user/username/projects/myproject/pkg3/src/keys.ts
/user/username/projects/myproject/pkg3/src/index.ts

WatchedFiles::

FsWatches::

FsWatchesRecursive::

exitCode:: ExitStatus.Success
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/a/lib/tsc.js -p pkg3 --listFiles
//// [/user/username/projects/myproject/pkg1/dist/index.d.ts]
export * from './types';

//// [/user/username/projects/myproject/pkg1/dist/types.d.ts]
export declare type A = {
id: string;
};
export declare type B = {
id: number;
};
export declare type IdType = A | B;
export declare class MetadataAccessor<T, D extends IdType = IdType> {
readonly key: string;
private constructor();
toString(): string;
static create<T, D extends IdType = IdType>(key: string): MetadataAccessor<T, D>;
}

//// [/user/username/projects/myproject/pkg1/package.json]
{"name":"@raymondfeng/pkg1","version":"1.0.0","main":"dist/index.js","typings":"dist/index.d.ts"}

//// [/user/username/projects/myproject/pkg2/dist/index.d.ts]
export * from './types';

//// [/user/username/projects/myproject/pkg2/dist/types.d.ts]
export {MetadataAccessor} from '@raymondfeng/pkg1';

//// [/user/username/projects/myproject/pkg2/package.json]
{"name":"@raymondfeng/pkg2","version":"1.0.0","main":"dist/index.js","typings":"dist/index.d.ts"}

//// [/user/username/projects/myproject/pkg3/src/index.ts]
export * from './keys';

//// [/user/username/projects/myproject/pkg3/src/keys.ts]
import {MetadataAccessor} from "@raymondfeng/pkg2";
export const ADMIN = MetadataAccessor.create<boolean>('1');

//// [/user/username/projects/myproject/pkg3/tsconfig.json]
{"compilerOptions":{"outDir":"dist","rootDir":"src","target":"es5","module":"commonjs","strict":true,"esModuleInterop":true,"declaration":true}}

//// [/user/username/projects/myproject/pkg2/node_modules/@raymondfeng/pkg1] symlink(/user/username/projects/myproject/pkg1)
//// [/user/username/projects/myproject/pkg3/node_modules/@raymondfeng/pkg2] symlink(/user/username/projects/myproject/pkg2)
//// [/a/lib/lib.d.ts]
/// <reference no-default-lib="true"/>
interface Boolean {}
interface Function {}
interface CallableFunction {}
interface NewableFunction {}
interface IArguments {}
interface Number { toExponential: any; }
interface Object {}
interface RegExp {}
interface String { charAt: any; }
interface Array<T> { length: number; [n: number]: T; }

//// [/user/username/projects/myproject/pkg3/dist/keys.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ADMIN = void 0;
var pkg2_1 = require("@raymondfeng/pkg2");
exports.ADMIN = pkg2_1.MetadataAccessor.create('1');


//// [/user/username/projects/myproject/pkg3/dist/keys.d.ts]
import { MetadataAccessor } from "@raymondfeng/pkg2";
export declare const ADMIN: MetadataAccessor<boolean, import("../../pkg1/dist").IdType>;


//// [/user/username/projects/myproject/pkg3/dist/index.js]
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p);
}
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./keys"), exports);


//// [/user/username/projects/myproject/pkg3/dist/index.d.ts]
export * from './keys';



Output::
/a/lib/lib.d.ts

/user/username/projects/myproject/pkg1/dist/types.d.ts

/user/username/projects/myproject/pkg1/dist/index.d.ts

/user/username/projects/myproject/pkg2/dist/types.d.ts

/user/username/projects/myproject/pkg2/dist/index.d.ts

/user/username/projects/myproject/pkg3/src/keys.ts

/user/username/projects/myproject/pkg3/src/index.ts



Program root files: ["/user/username/projects/myproject/pkg3/src/index.ts","/user/username/projects/myproject/pkg3/src/keys.ts"]
Program options: {"outDir":"/user/username/projects/myproject/pkg3/dist","rootDir":"/user/username/projects/myproject/pkg3/src","target":1,"module":1,"strict":true,"esModuleInterop":true,"declaration":true,"project":"/user/username/projects/myproject/pkg3","listFiles":true,"configFilePath":"/user/username/projects/myproject/pkg3/tsconfig.json"}
Program files::
/a/lib/lib.d.ts
/user/username/projects/myproject/pkg1/dist/types.d.ts
/user/username/projects/myproject/pkg1/dist/index.d.ts
/user/username/projects/myproject/pkg2/dist/types.d.ts
/user/username/projects/myproject/pkg2/dist/index.d.ts
/user/username/projects/myproject/pkg3/src/keys.ts
/user/username/projects/myproject/pkg3/src/index.ts

WatchedFiles::

FsWatches::

FsWatchesRecursive::

exitCode:: ExitStatus.Success
Loading

0 comments on commit eb34d7c

Please sign in to comment.