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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,7 @@ const lintTargets = [
"src/server/**/*.ts",
"scripts/tslint/**/*.ts",
"src/services/**/*.ts",
"tests/*.ts", "tests/webhost/*.ts" // Note: does *not* descend recursively
];


Expand Down
3 changes: 2 additions & 1 deletion Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,8 @@ var lintTargets = compilerSources
.concat(serverCoreSources)
.concat(tslintRulesFiles)
.concat(servicesSources)
.concat(["Gulpfile.ts"]);
.concat(["Gulpfile.ts"])
.concat([nodeServerInFile, perftscPath, "tests/perfsys.ts", webhostPath]);


desc("Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex");
Expand Down
53 changes: 26 additions & 27 deletions tests/perfsys.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/// <reference path="..\src\compiler\sys.ts"/>
/// <reference path="..\src\compiler\types.ts"/>

module perftest {

namespace perftest {
interface IOLog {
resolvePath: ts.Map<string>;
fileNames: string[];
Expand All @@ -12,20 +11,20 @@ module perftest {
getOut(): string;
}

export var readFile = ts.sys.readFile;
var writeFile = ts.sys.writeFile;
export var write = ts.sys.write;
var resolvePath = ts.sys.resolvePath;
export var getExecutingFilePath = ts.sys.getExecutingFilePath;
export var getCurrentDirectory = ts.sys.getCurrentDirectory;
var exit = ts.sys.exit;
export const readFile = ts.sys.readFile;
const writeFile = ts.sys.writeFile;
export const write = ts.sys.write;
const resolvePath = ts.sys.resolvePath;
export const getExecutingFilePath = ts.sys.getExecutingFilePath;
export const getCurrentDirectory = ts.sys.getCurrentDirectory;
// const exit = ts.sys.exit;

var args = ts.sys.args;
const args = ts.sys.args;

// augment sys so first ts.executeCommandLine call will be finish silently
ts.sys.write = (s: string) => { };
ts.sys.exit = (code: number) => { };
ts.sys.args = []
ts.sys.args = [];

export function restoreSys() {
ts.sys.args = args;
Expand All @@ -44,19 +43,19 @@ module perftest {
return args.slice(1);
}

var resolvePathLog: ts.Map<string> = {};
const resolvePathLog: ts.Map<string> = {};

export function interceptIO() {
ts.sys.resolvePath = (s) => {
var result = resolvePath(s);
const result = resolvePath(s);
resolvePathLog[s] = result;
return result;
};
}

export function writeIOLog(fileNames: string[]) {
var path = args[1];
var log: IOLog = {
const path = args[1];
const log: IOLog = {
fileNames: fileNames,
resolvePath: resolvePathLog
};
Expand All @@ -65,36 +64,36 @@ module perftest {
}

export function prepare(): IO {
var log = <IOLog>JSON.parse(readFile(args[0]));
const log = <IOLog>JSON.parse(readFile(args[0]));

const files: ts.Map<string> = {};
log.fileNames.forEach(f => { files[f] = readFile(f); });

var files: ts.Map<string> = {};
log.fileNames.forEach(f => { files[f] = readFile(f); })

ts.sys.createDirectory = (s: string) => { };
ts.sys.directoryExists = (s: string) => true;
ts.sys.fileExists = (s: string) => true;

var currentDirectory = ts.sys.getCurrentDirectory();
const currentDirectory = ts.sys.getCurrentDirectory();
ts.sys.getCurrentDirectory = () => currentDirectory;

var executingFilePath = ts.sys.getExecutingFilePath();
const executingFilePath = ts.sys.getExecutingFilePath();
ts.sys.getExecutingFilePath = () => executingFilePath;

ts.sys.readFile = (s: string) => {
return files[s];
}
};

ts.sys.resolvePath = (s: string) => {
var path = log.resolvePath[s];
const path = log.resolvePath[s];
if (!path) {
throw new Error("Unexpected path '" + s + "'");
}
return path
}
return path;
};

ts.sys.writeFile = (path: string, data: string) => { };

var out: string = "";
let out = "";

ts.sys.write = (s: string) => { out += s; };

Expand Down
12 changes: 6 additions & 6 deletions tests/perftsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
if (perftest.hasLogIOFlag()) {
perftest.interceptIO();

var compilerHost: ts.CompilerHost = {
const compilerHost: ts.CompilerHost = {
getSourceFile: (s, v) => {
var content = perftest.readFile(s);
const content = perftest.readFile(s);
return content !== undefined ? ts.createSourceFile(s, content, v) : undefined;
},
getDefaultLibFileName: () => ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(perftest.getExecutingFilePath())), "lib.d.ts"),
Expand All @@ -18,13 +18,13 @@ if (perftest.hasLogIOFlag()) {
getNewLine: () => ts.sys.newLine
};

var commandLine = ts.parseCommandLine(perftest.getArgsWithoutLogIOFlag());
var program = ts.createProgram(commandLine.fileNames, commandLine.options, compilerHost);
var fileNames = program.getSourceFiles().map(f => f.fileName);
const commandLine = ts.parseCommandLine(perftest.getArgsWithoutLogIOFlag());
const program = ts.createProgram(commandLine.fileNames, commandLine.options, compilerHost);
const fileNames = program.getSourceFiles().map(f => f.fileName);
perftest.writeIOLog(fileNames);
}
else {
var io = perftest.prepare();
const io = perftest.prepare();
ts.executeCommandLine(perftest.getArgsWithoutIOLogFile());
perftest.write(io.getOut());
}
Loading