Skip to content

Commit ddb2155

Browse files
committed
Additional PR feedback and cleanup
1 parent d409155 commit ddb2155

8 files changed

Lines changed: 21 additions & 44 deletions

File tree

Jakefile.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,6 @@ var buildProtocolTs = path.join(scriptsDirectory, "buildProtocol.ts");
487487
var buildProtocolJs = path.join(scriptsDirectory, "buildProtocol.js");
488488
var buildProtocolDts = path.join(builtLocalDirectory, "protocol.d.ts");
489489
var typescriptServicesDts = path.join(builtLocalDirectory, "typescriptServices.d.ts");
490-
var typesMapJson = path.join(builtLocalDirectory, "typesMap.json");
491490

492491
file(buildProtocolTs);
493492

@@ -652,7 +651,7 @@ var serverFile = path.join(builtLocalDirectory, "tsserver.js");
652651
compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true, lib: "es6" });
653652
var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
654653
var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts");
655-
file(typesMapOutputPath, undefined, function() {
654+
file(typesMapOutputPath, /** @type {*} */(function() {
656655
var content = fs.readFileSync(path.join(serverDirectory, 'typesMap.json'));
657656
// Validate that it's valid JSON
658657
try {
@@ -661,7 +660,7 @@ file(typesMapOutputPath, undefined, function() {
661660
console.log("Parse error in typesMap.json: " + e);
662661
}
663662
fs.writeFileSync(typesMapOutputPath, content);
664-
});
663+
}));
665664
compileFile(
666665
tsserverLibraryFile,
667666
languageServiceLibrarySources,

src/harness/compilerRunner.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,14 @@ class CompilerTest {
164164
tsConfigOptions.configFile.fileName = tsConfigOptions.configFilePath;
165165
}
166166

167-
const output = Harness.Compiler.compileFiles(
167+
this.result = Harness.Compiler.compileFiles(
168168
this.toBeCompiled,
169169
this.otherFiles,
170170
this.harnessSettings,
171171
/*options*/ tsConfigOptions,
172172
/*currentDirectory*/ this.harnessSettings.currentDirectory);
173173

174-
this.options = output.options;
175-
this.result = output.result;
174+
this.options = this.result.options;
176175
}
177176

178177
public static getConfigurations(fileName: string) {

src/harness/harness.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,18 +1198,13 @@ namespace Harness {
11981198
fileOptions?: any;
11991199
}
12001200

1201-
export interface CompilationOutput {
1202-
result: compiler.CompilationResult;
1203-
options: ts.CompilerOptions & HarnessOptions;
1204-
}
1205-
12061201
export function compileFiles(
12071202
inputFiles: TestFile[],
12081203
otherFiles: TestFile[],
12091204
harnessSettings: TestCaseParser.CompilerSettings,
12101205
compilerOptions: ts.CompilerOptions,
12111206
// Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file
1212-
currentDirectory: string): CompilationOutput {
1207+
currentDirectory: string): compiler.CompilationResult {
12131208
const options: ts.CompilerOptions & HarnessOptions = compilerOptions ? ts.cloneCompilerOptions(compilerOptions) : { noResolve: false };
12141209
options.target = options.target || ts.ScriptTarget.ES3;
12151210
options.newLine = options.newLine || ts.NewLineKind.CarriageReturnLineFeed;
@@ -1244,7 +1239,7 @@ namespace Harness {
12441239
}
12451240
}
12461241

1247-
const result = compiler.compileFiles(
1242+
return compiler.compileFiles(
12481243
new compiler.CompilerHost(
12491244
vfs.VirtualFileSystem.createFromDocuments(
12501245
useCaseSensitiveFileNames,
@@ -1255,14 +1250,6 @@ namespace Harness {
12551250
),
12561251
programFileNames,
12571252
options);
1258-
1259-
// const fileOutputs = compilation.outputs.map(output => output.asGeneratedFile());
1260-
// const traceResults = compilation.traces && compilation.traces.slice();
1261-
// const program = compilation.program;
1262-
// const emitResult = compilation.result;
1263-
// const errors = compilation.diagnostics;
1264-
// const result = new CompilerResult(fileOutputs, errors, program, compilation.vfs.currentDirectory, emitResult.sourceMaps, traceResults);
1265-
return { result, options };
12661253
}
12671254

12681255
export interface DeclarationCompilationContext {
@@ -1343,7 +1330,7 @@ namespace Harness {
13431330
}
13441331
const { declInputFiles, declOtherFiles, harnessSettings, options, currentDirectory } = context;
13451332
const output = compileFiles(declInputFiles, declOtherFiles, harnessSettings, options, currentDirectory);
1346-
return { declInputFiles, declOtherFiles, declResult: output.result };
1333+
return { declInputFiles, declOtherFiles, declResult: output };
13471334
}
13481335

13491336
export function minimalDiagnosticsToString(diagnostics: ReadonlyArray<ts.Diagnostic>, pretty?: boolean) {

src/harness/rwcRunner.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,15 @@ namespace RWC {
142142
opts.options.noLib = true;
143143

144144
// Emit the results
145-
compilerOptions = undefined;
146-
const output = Harness.Compiler.compileFiles(
145+
compilerResult = Harness.Compiler.compileFiles(
147146
inputFiles,
148147
otherFiles,
149148
/* harnessOptions */ undefined,
150149
opts.options,
151150
// Since each RWC json file specifies its current directory in its json file, we need
152151
// to pass this information in explicitly instead of acquiring it from the process.
153152
currentDirectory);
154-
155-
compilerOptions = output.options;
156-
compilerResult = output.result;
153+
compilerOptions = compilerResult.options;
157154
});
158155

159156
function getHarnessCompilerInputUnit(fileName: string): Harness.Compiler.TestFile {

src/harness/test262Runner.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,12 @@ class Test262BaselineRunner extends RunnerBase {
5252
compilerResult: undefined,
5353
};
5454

55-
const output = Harness.Compiler.compileFiles(
55+
testState.compilerResult = Harness.Compiler.compileFiles(
5656
[Test262BaselineRunner.helperFile].concat(inputFiles),
5757
/*otherFiles*/ [],
5858
/* harnessOptions */ undefined,
5959
Test262BaselineRunner.options,
60-
/* currentDirectory */ undefined
61-
);
62-
testState.compilerResult = output.result;
60+
/* currentDirectory */ undefined);
6361
});
6462

6563
after(() => {

src/harness/unittests/publicApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ describe("Public APIs", () => {
1919
content: fileContent
2020
};
2121
const inputFiles = [testFile];
22-
const output = Harness.Compiler.compileFiles(inputFiles, [], /*harnessSettings*/ undefined, /*options*/ {}, /*currentDirectory*/ undefined);
23-
assert(!output.result.diagnostics || !output.result.diagnostics.length, Harness.Compiler.minimalDiagnosticsToString(output.result.diagnostics, /*pretty*/ true));
22+
const result = Harness.Compiler.compileFiles(inputFiles, [], /*harnessSettings*/ undefined, /*options*/ {}, /*currentDirectory*/ undefined);
23+
assert(!result.diagnostics || !result.diagnostics.length, Harness.Compiler.minimalDiagnosticsToString(result.diagnostics, /*pretty*/ true));
2424
});
2525
}
2626

src/harness/unittests/symbolWalker.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@ namespace ts {
44
describe("Symbol Walker", () => {
55
function test(description: string, source: string, verifier: (file: SourceFile, checker: TypeChecker) => void) {
66
it(description, () => {
7-
let {result} = Harness.Compiler.compileFiles([{
7+
const result = Harness.Compiler.compileFiles([{
88
unitName: "main.ts",
99
content: source
1010
}], [], {}, {}, "/");
11-
let file = result.program.getSourceFile("main.ts");
12-
let checker = result.program.getTypeChecker();
11+
const file = result.program.getSourceFile("main.ts");
12+
const checker = result.program.getTypeChecker();
1313
verifier(file, checker);
14-
15-
result = undefined;
16-
file = undefined;
17-
checker = undefined;
1814
});
1915
}
2016

src/harness/vfs.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
// support the eventual conversion of harness into a modular system.
1010

1111
namespace vfs {
12-
const S_IFMT = 0xf000;
13-
const S_IFLNK = 0xa000;
14-
const S_IFREG = 0x8000;
15-
const S_IFDIR = 0x4000;
12+
// file mode flags used for computing Stats
13+
const S_IFMT = 0xf000; // file type flags mask
14+
const S_IFLNK = 0xa000; // symbolic link
15+
const S_IFREG = 0x8000; // regular file
16+
const S_IFDIR = 0x4000; // regular directory
1617

1718
export interface PathMappings {
1819
[path: string]: string;

0 commit comments

Comments
 (0)