mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 02:15:10 -05:00
Additional PR feedback and cleanup
This commit is contained in:
@@ -164,15 +164,14 @@ class CompilerTest {
|
||||
tsConfigOptions.configFile.fileName = tsConfigOptions.configFilePath;
|
||||
}
|
||||
|
||||
const output = Harness.Compiler.compileFiles(
|
||||
this.result = Harness.Compiler.compileFiles(
|
||||
this.toBeCompiled,
|
||||
this.otherFiles,
|
||||
this.harnessSettings,
|
||||
/*options*/ tsConfigOptions,
|
||||
/*currentDirectory*/ this.harnessSettings.currentDirectory);
|
||||
|
||||
this.options = output.options;
|
||||
this.result = output.result;
|
||||
this.options = this.result.options;
|
||||
}
|
||||
|
||||
public static getConfigurations(fileName: string) {
|
||||
|
||||
@@ -1198,18 +1198,13 @@ namespace Harness {
|
||||
fileOptions?: any;
|
||||
}
|
||||
|
||||
export interface CompilationOutput {
|
||||
result: compiler.CompilationResult;
|
||||
options: ts.CompilerOptions & HarnessOptions;
|
||||
}
|
||||
|
||||
export function compileFiles(
|
||||
inputFiles: TestFile[],
|
||||
otherFiles: TestFile[],
|
||||
harnessSettings: TestCaseParser.CompilerSettings,
|
||||
compilerOptions: ts.CompilerOptions,
|
||||
// Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file
|
||||
currentDirectory: string): CompilationOutput {
|
||||
currentDirectory: string): compiler.CompilationResult {
|
||||
const options: ts.CompilerOptions & HarnessOptions = compilerOptions ? ts.cloneCompilerOptions(compilerOptions) : { noResolve: false };
|
||||
options.target = options.target || ts.ScriptTarget.ES3;
|
||||
options.newLine = options.newLine || ts.NewLineKind.CarriageReturnLineFeed;
|
||||
@@ -1244,7 +1239,7 @@ namespace Harness {
|
||||
}
|
||||
}
|
||||
|
||||
const result = compiler.compileFiles(
|
||||
return compiler.compileFiles(
|
||||
new compiler.CompilerHost(
|
||||
vfs.VirtualFileSystem.createFromDocuments(
|
||||
useCaseSensitiveFileNames,
|
||||
@@ -1255,14 +1250,6 @@ namespace Harness {
|
||||
),
|
||||
programFileNames,
|
||||
options);
|
||||
|
||||
// const fileOutputs = compilation.outputs.map(output => output.asGeneratedFile());
|
||||
// const traceResults = compilation.traces && compilation.traces.slice();
|
||||
// const program = compilation.program;
|
||||
// const emitResult = compilation.result;
|
||||
// const errors = compilation.diagnostics;
|
||||
// const result = new CompilerResult(fileOutputs, errors, program, compilation.vfs.currentDirectory, emitResult.sourceMaps, traceResults);
|
||||
return { result, options };
|
||||
}
|
||||
|
||||
export interface DeclarationCompilationContext {
|
||||
@@ -1343,7 +1330,7 @@ namespace Harness {
|
||||
}
|
||||
const { declInputFiles, declOtherFiles, harnessSettings, options, currentDirectory } = context;
|
||||
const output = compileFiles(declInputFiles, declOtherFiles, harnessSettings, options, currentDirectory);
|
||||
return { declInputFiles, declOtherFiles, declResult: output.result };
|
||||
return { declInputFiles, declOtherFiles, declResult: output };
|
||||
}
|
||||
|
||||
export function minimalDiagnosticsToString(diagnostics: ReadonlyArray<ts.Diagnostic>, pretty?: boolean) {
|
||||
|
||||
@@ -142,8 +142,7 @@ namespace RWC {
|
||||
opts.options.noLib = true;
|
||||
|
||||
// Emit the results
|
||||
compilerOptions = undefined;
|
||||
const output = Harness.Compiler.compileFiles(
|
||||
compilerResult = Harness.Compiler.compileFiles(
|
||||
inputFiles,
|
||||
otherFiles,
|
||||
/* harnessOptions */ undefined,
|
||||
@@ -151,9 +150,7 @@ namespace RWC {
|
||||
// Since each RWC json file specifies its current directory in its json file, we need
|
||||
// to pass this information in explicitly instead of acquiring it from the process.
|
||||
currentDirectory);
|
||||
|
||||
compilerOptions = output.options;
|
||||
compilerResult = output.result;
|
||||
compilerOptions = compilerResult.options;
|
||||
});
|
||||
|
||||
function getHarnessCompilerInputUnit(fileName: string): Harness.Compiler.TestFile {
|
||||
|
||||
@@ -52,14 +52,12 @@ class Test262BaselineRunner extends RunnerBase {
|
||||
compilerResult: undefined,
|
||||
};
|
||||
|
||||
const output = Harness.Compiler.compileFiles(
|
||||
testState.compilerResult = Harness.Compiler.compileFiles(
|
||||
[Test262BaselineRunner.helperFile].concat(inputFiles),
|
||||
/*otherFiles*/ [],
|
||||
/* harnessOptions */ undefined,
|
||||
Test262BaselineRunner.options,
|
||||
/* currentDirectory */ undefined
|
||||
);
|
||||
testState.compilerResult = output.result;
|
||||
/* currentDirectory */ undefined);
|
||||
});
|
||||
|
||||
after(() => {
|
||||
|
||||
@@ -19,8 +19,8 @@ describe("Public APIs", () => {
|
||||
content: fileContent
|
||||
};
|
||||
const inputFiles = [testFile];
|
||||
const output = Harness.Compiler.compileFiles(inputFiles, [], /*harnessSettings*/ undefined, /*options*/ {}, /*currentDirectory*/ undefined);
|
||||
assert(!output.result.diagnostics || !output.result.diagnostics.length, Harness.Compiler.minimalDiagnosticsToString(output.result.diagnostics, /*pretty*/ true));
|
||||
const result = Harness.Compiler.compileFiles(inputFiles, [], /*harnessSettings*/ undefined, /*options*/ {}, /*currentDirectory*/ undefined);
|
||||
assert(!result.diagnostics || !result.diagnostics.length, Harness.Compiler.minimalDiagnosticsToString(result.diagnostics, /*pretty*/ true));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -4,17 +4,13 @@ namespace ts {
|
||||
describe("Symbol Walker", () => {
|
||||
function test(description: string, source: string, verifier: (file: SourceFile, checker: TypeChecker) => void) {
|
||||
it(description, () => {
|
||||
let {result} = Harness.Compiler.compileFiles([{
|
||||
const result = Harness.Compiler.compileFiles([{
|
||||
unitName: "main.ts",
|
||||
content: source
|
||||
}], [], {}, {}, "/");
|
||||
let file = result.program.getSourceFile("main.ts");
|
||||
let checker = result.program.getTypeChecker();
|
||||
const file = result.program.getSourceFile("main.ts");
|
||||
const checker = result.program.getTypeChecker();
|
||||
verifier(file, checker);
|
||||
|
||||
result = undefined;
|
||||
file = undefined;
|
||||
checker = undefined;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
// support the eventual conversion of harness into a modular system.
|
||||
|
||||
namespace vfs {
|
||||
const S_IFMT = 0xf000;
|
||||
const S_IFLNK = 0xa000;
|
||||
const S_IFREG = 0x8000;
|
||||
const S_IFDIR = 0x4000;
|
||||
// file mode flags used for computing Stats
|
||||
const S_IFMT = 0xf000; // file type flags mask
|
||||
const S_IFLNK = 0xa000; // symbolic link
|
||||
const S_IFREG = 0x8000; // regular file
|
||||
const S_IFDIR = 0x4000; // regular directory
|
||||
|
||||
export interface PathMappings {
|
||||
[path: string]: string;
|
||||
|
||||
Reference in New Issue
Block a user