Skip to content

Commit

Permalink
Post conversion fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
elibarzilay committed Nov 23, 2021
1 parent 809349d commit 9a78868
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 47 deletions.
9 changes: 5 additions & 4 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const { buildProject, cleanProject, watchProject } = require("./scripts/build/pr
const cmdLineOptions = require("./scripts/build/options");

const copyright = "CopyrightNotice.txt";
const testRoot = "built/local/testRunner/Harness.js"
const cleanTasks = [];

const buildScripts = () => buildProject("scripts");
Expand Down Expand Up @@ -442,7 +443,7 @@ preTest.displayName = "preTest";

const postTest = (done) => cmdLineOptions.lint ? lint(done) : done();

const runTests = () => runConsoleTests("built/local/run.js", "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ false);
const runTests = () => runConsoleTests(testRoot, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ false);
task("runtests", series(preBuild, preTest, runTests, postTest));
task("runtests").description = "Runs the tests using the built run.js file.";
task("runtests").flags = {
Expand All @@ -462,7 +463,7 @@ task("runtests").flags = {
" --shardId": "1-based ID of this shard (default: 1)",
};

const runTestsParallel = () => runConsoleTests("built/local/run.js", "min", /*runInParallel*/ cmdLineOptions.workers > 1, /*watchMode*/ false);
const runTestsParallel = () => runConsoleTests(testRoot, "min", /*runInParallel*/ cmdLineOptions.workers > 1, /*watchMode*/ false);
task("runtests-parallel", series(preBuild, preTest, runTestsParallel, postTest));
task("runtests-parallel").description = "Runs all the tests in parallel using the built run.js file.";
task("runtests-parallel").flags = {
Expand Down Expand Up @@ -611,10 +612,10 @@ task("publish-nightly").description = "Runs `npm publish --tag next` to create a
// write some kind of trigger file that indicates build completion that we could listen for instead.
const watchRuntests = () => watch(["built/local/*.js", "tests/cases/**/*.ts", "tests/cases/**/tsconfig.json"], { delay: 5000 }, async () => {
if (cmdLineOptions.tests || cmdLineOptions.failed) {
await runConsoleTests("built/local/run.js", "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ true);
await runConsoleTests(testRoot, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ true);
}
else {
await runConsoleTests("built/local/run.js", "min", /*runInParallel*/ true, /*watchMode*/ true);
await runConsoleTests(testRoot, "min", /*runInParallel*/ true, /*watchMode*/ true);
}
});
task("watch", series(preBuild, preTest, parallel(watchLib, watchDiagnostics, watchServices, watchLssl, watchTests, watchRuntests)));
Expand Down
4 changes: 2 additions & 2 deletions src/harness/fourslashImpl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { TestCaseParser, Compiler, isDefaultLibraryFile, IO, getConfigNameFromFileName, Baseline, virtualFileSystemRoot } from "./Harness";
import { FileSet, File, FileSystem } from "./vfs";
import { ESMap, MultiMap, TextRange, ImplementationLocation, CompilerOptions, ScriptTarget, HostCancellationToken, Debug, OperationCanceledException, DiagnosticMessage, IScriptSnapshot, ScriptSnapshot, LanguageService, FormatCodeSettings, SymbolDisplayPart, forEach, parseConfigFileTextToJson, normalizePath, getDirectoryPath, convertCompilerOptionsFromJson, extend, ParsedCommandLine, parseJsonText, parseJsonSourceFileConfigFileContent, getNormalizedAbsolutePath, FileReference, flatten, getSupportedExtensions, contains, isDeclarationFileName, containsPath, some, testFormatSettings, getAllKeys, isString, forEachEntry, LineAndCharacter, normalizeSlashes, emptyOptions, Diagnostic, emptyArray, flatMap, isAnySupportedFileExtension, getBaseFileName, flattenDiagnosticMessageText, SourceFile, getLineAndCharacterOfPosition, forEachKey, getAllowJSCompilerOption, resolutionExtensionIsTSOrJson, extensionFromPath, DiagnosticCategory, createTextSpanFromRange, isNumber, textSpansEqual, DefinitionInfo, DefinitionInfoAndBoundSpan, isArray, hasProperty, zipWith, comparePaths, Comparison, deduplicate, equateValues, textSpanEnd, sys, OutputFile, InlayHintsOptions, InlayHint, CompletionEntry, Completions, displayPartsToString, Program, TypeChecker, Node, getTouchingPropertyName, Symbol, SymbolFlags, MapLike, getEntries, ReferenceEntry, map, find, ReferencedSymbol, group, sort, textSpanContainsPosition, UserPreferences, GetCompletionsAtPositionOptions, CompletionInfo, CompletionEntryData, CompletionEntryDetails, realizeDiagnostics, RealizedDiagnostic, JSDocTagInfo, RenameLocation, compareStringsCaseSensitive, textSpanIntersectsWithPosition, SignatureHelpTriggerReason, SignatureHelpParameter, RenameInfoOptions, CharacterCodes, computeLineStarts, computeLineAndCharacterOfPosition, padLeft, repeatString, getPreEmitDiagnostics, DiagnosticMessageChain, filter, endsWith, arrayFrom, SelectionRange, isLineBreak, isWhiteSpaceLike, findLastIndex, concatenate, Extension, SignatureHelpItems, createLanguageServiceSourceFile, TextChange, clone, FormatCodeOptions, toEditorSettings, documentSpansEqual, arrayIsEqualTo, createMultiMap, IndentStyle, classifier, ClassifiedSpan, ClassifiedSpan2020, SemanticClassificationFormat, createTextSpan, OutliningSpan, first, mapDefined, formatStringFromArgs, FileTextChanges, textChanges, getOwnKeys, CodeFixAction, equalOwnProperties, createTextRangeFromSpan, textRangeContainsPositionInclusive, firstOrUndefined, codefix, Diagnostics, TextInsertion, DocCommentTemplateOptions, JsxClosingTagInfo, NavigateToItem, ScriptElementKind, combinePaths, length, RefactorTriggerReason, firstDefined, CallHierarchyItem, mapOneOrMany, getPathUpdater, createGetCanonicalFileName, ApplicableRefactorInfo, transpileModule, changeExtension, isRootedDiskPath, append, regExpEscape } from "./ts";
Expand All @@ -10,7 +9,8 @@ import { memoize, assertInvariants, assertDiagnosticsEquals, assertStructuralEqu
import { SessionClient, protocol } from "./ts.server";
import * as FourSlashInterface from "./FourSlashInterface";
import * as ts from "./ts";
import ArrayOrSingle = FourSlashInterface.ArrayOrSingle;

type ArrayOrSingle<T> = FourSlashInterface.ArrayOrSingle<T>;

export const enum FourSlashTestType {
Native,
Expand Down
24 changes: 12 additions & 12 deletions src/harness/harnessIO.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { RunnerBase, TypeWriterWalker, TypeWriterResult } from "./Harness";
import { FileSystemEntries, sys, compareStringsCaseSensitive, compareStringsCaseInsensitive, combinePaths, ScriptTarget, createSourceFile, ESMap, SourceFile, getEntries, CompilerOptions, getEmitScriptTarget, CommandLineOption, Diagnostic, parseListTypeOption, parseCustomTypeOption, CommandLineOptionOfCustomType, cloneCompilerOptions, NewLineKind, map, getNormalizedAbsolutePath, fileExtensionIs, Extension, forEach, getAllowJSCompilerOption, removeFileExtension, getDeclarationEmitExtensionForPath, formatDiagnosticsWithColorAndContext, formatDiagnostics, getErrorSummaryText, getErrorCountForSummary, sort, compareDiagnostics, createGetCanonicalFileName, flattenDiagnosticMessageText, diagnosticCategoryName, formatLocation, identity, DiagnosticWithLocation, comparePaths, Comparison, computeLineStarts, TextSpan, textSpanEnd, countWhere, Program, endsWith, flatMap, getAreDeclarationMapsEnabled, contains, convertToBase64, getBaseFileName, CharacterCodes, ScriptKind, length, normalizeSlashes, toPath, startsWith, findIndex, arrayFrom, orderedRemoveItemAt, ReadonlyESMap, optionDeclarations, equateStringsCaseInsensitive, hasProperty, ParsedCommandLine, ParseConfigHost, parseJsonText, normalizePath, getDirectoryPath, parseJsonSourceFileConfigFileContent, ForegroundColorEscapeSequences, find } from "./ts";
import { FileSystemEntries, sys, compareStringsCaseSensitive, compareStringsCaseInsensitive, combinePaths, ScriptTarget, createSourceFile, Map, ESMap, SourceFile, getEntries, CompilerOptions, getEmitScriptTarget, CommandLineOption, Diagnostic, parseListTypeOption, parseCustomTypeOption, CommandLineOptionOfCustomType, cloneCompilerOptions, NewLineKind, map, getNormalizedAbsolutePath, fileExtensionIs, Extension, forEach, getAllowJSCompilerOption, removeFileExtension, getDeclarationEmitExtensionForPath, formatDiagnosticsWithColorAndContext, formatDiagnostics, getErrorSummaryText, getErrorCountForSummary, sort, compareDiagnostics, createGetCanonicalFileName, flattenDiagnosticMessageText, diagnosticCategoryName, formatLocation, identity, DiagnosticWithLocation, comparePaths, Comparison, computeLineStarts, TextSpan, textSpanEnd, countWhere, Program, endsWith, flatMap, getAreDeclarationMapsEnabled, contains, convertToBase64, getBaseFileName, CharacterCodes, ScriptKind, length, normalizeSlashes, toPath, startsWith, findIndex, arrayFrom, orderedRemoveItemAt, ReadonlyESMap, optionDeclarations, equateStringsCaseInsensitive, hasProperty, ParsedCommandLine, ParseConfigHost, parseJsonText, normalizePath, getDirectoryPath, parseJsonSourceFileConfigFileContent, ForegroundColorEscapeSequences, find } from "./ts";
import { findUpRoot, assertInvariants, removeByteOrderMark, removeTestPathPrefixes, canonicalizeForHarness, splitContentByNewlines, encodeString } from "./Utils";
import { combine, dirname, isDeclaration, isJson, isTypeScript, isJavaScript, addTrailingSeparator } from "./vpath";
import { FileSet, srcFolder, builtFolder, testLibFolder, createFromFileSystem, Symlink } from "./vfs";
import { CompilationResult } from "./compiler";
import { TextDocument } from "./documents";
import { CompilerHost } from "./fakes";
import * as ts from "./ts";
import * as compiler from "./compiler";

export interface IO {
newLine(): string;
getCurrentDirectory(): string;
Expand Down Expand Up @@ -264,7 +264,7 @@ export namespace Compiler {
}

if (!libFileNameSourceFileMap) {
libFileNameSourceFileMap = new ts.Map(getEntries({
libFileNameSourceFileMap = new Map(getEntries({
[defaultLibFileName]: createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + "lib.es5.d.ts")!, /*languageVersion*/ ScriptTarget.Latest)
}));
}
Expand Down Expand Up @@ -307,7 +307,7 @@ export namespace Compiler {
noTypesAndSymbols?: boolean;
}

// Additional options not already in ts.optionDeclarations
// Additional options not already in optionDeclarations
const harnessOptionDeclarations: CommandLineOption[] = [
{ name: "allowNonTsExtensions", type: "boolean", defaultValueDescription: "false" },
{ name: "useCaseSensitiveFileNames", type: "boolean", defaultValueDescription: "false" },
Expand All @@ -329,9 +329,9 @@ export namespace Compiler {
let optionsIndex: ESMap<string, CommandLineOption>;
function getCommandLineOption(name: string): CommandLineOption | undefined {
if (!optionsIndex) {
optionsIndex = new ts.Map<string, CommandLineOption>();
const optionDeclarations = harnessOptionDeclarations.concat(ts.optionDeclarations);
for (const option of optionDeclarations) {
optionsIndex = new Map<string, CommandLineOption>();
const optionDecls = harnessOptionDeclarations.concat(optionDeclarations);
for (const option of optionDecls) {
optionsIndex.set(option.name.toLowerCase(), option);
}
}
Expand Down Expand Up @@ -605,7 +605,7 @@ export namespace Compiler {
errorsReported = 0;

// 'merge' the lines of each input file with any errors associated with it
const dupeCase = new ts.Map<string, number>();
const dupeCase = new Map<string, number>();
for (const inputFile of inputFiles.filter(f => f.content !== undefined)) {
// Filter down to the errors in the file
const fileErrors = diagnostics.filter((e): e is DiagnosticWithLocation => {
Expand Down Expand Up @@ -790,7 +790,7 @@ export namespace Compiler {
if (skipBaseline) {
return;
}
const dupeCase = new ts.Map<string, number>();
const dupeCase = new Map<string, number>();

for (const file of allFiles) {
const { unitName } = file;
Expand Down Expand Up @@ -963,7 +963,7 @@ export namespace Compiler {
// Collect, test, and sort the fileNames
const files = Array.from(outputFiles);
files.slice().sort((a, b) => compareStringsCaseSensitive(cleanName(a.file), cleanName(b.file)));
const dupeCase = new ts.Map<string, number>();
const dupeCase = new Map<string, number>();
// Yield them
for (const outputFile of files) {
yield [checkDuplicatedFileName(outputFile.file, dupeCase), "/*====== " + outputFile.file + " ======*/\r\n" + removeByteOrderMark(outputFile.text)];
Expand Down Expand Up @@ -1099,7 +1099,7 @@ function getVaryByStarSettingValues(varyBy: string): ReadonlyESMap<string, strin
return option.type;
}
if (option.type === "boolean") {
return booleanVaryByStarSettingValues || (booleanVaryByStarSettingValues = new ts.Map(getEntries({
return booleanVaryByStarSettingValues || (booleanVaryByStarSettingValues = new Map(getEntries({
true: 1,
false: 0
})));
Expand Down Expand Up @@ -1449,7 +1449,7 @@ export namespace Baseline {
string
]> | null, opts?: BaselineOptions, referencedExtensions?: string[]): void {
const gen = generateContent();
const writtenFiles = new ts.Map<string, true>();
const writtenFiles = new Map<string, true>();
const errors: Error[] = [];

// eslint-disable-next-line no-null/no-null
Expand Down
20 changes: 10 additions & 10 deletions src/harness/virtualFileSystemWithWatch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Path, combinePaths, getDirectoryPath, ESMap, patchWriteFileEnsuringDirectory, isString, SortedArray, isArray, MultiMap, FileWatcher, forEach, arrayFrom, ReadonlyESMap, arrayToMap, isNumber, identity, PollingInterval, WatchOptions, FileWatcherCallback, FsWatchCallback, FormatDiagnosticsHost, ModuleResolutionHost, createMultiMap, RequireResult, WatchFileKind, HostWatchFile, HostWatchDirectory, createGetCanonicalFileName, toPath, createSystemWatchFunctions, createSingleFileWatcherPerName, getNormalizedAbsolutePath, directorySeparator, Debug, clone, returnFalse, FileWatcherEventKind, getBaseFileName, insertSorted, compareStringsCaseSensitive, filterMutate, FileSystemEntryKind, createFileWatcherCallback, getRelativePathToDirectoryOrUrl, mapDefined, matchFiles, generateDjb2Hash, sys, clear, WatchDirectoryKind, PollingWatchKind } from "./ts";
import { Path, combinePaths, getDirectoryPath, Set, Map, ESMap, patchWriteFileEnsuringDirectory, isString, SortedArray, isArray, MultiMap, FileWatcher, forEach, arrayFrom, ReadonlyESMap, arrayToMap, isNumber, identity, PollingInterval, WatchOptions, FileWatcherCallback, FsWatchCallback, FormatDiagnosticsHost, ModuleResolutionHost, createMultiMap, RequireResult, WatchFileKind, HostWatchFile, HostWatchDirectory, createGetCanonicalFileName, toPath, createSystemWatchFunctions, createSingleFileWatcherPerName, getNormalizedAbsolutePath, directorySeparator, Debug, clone, returnFalse, FileWatcherEventKind, getBaseFileName, insertSorted, compareStringsCaseSensitive, filterMutate, FileSystemEntryKind, createFileWatcherCallback, getRelativePathToDirectoryOrUrl, mapDefined, matchFiles, generateDjb2Hash, sys, clear, WatchDirectoryKind, PollingWatchKind } from "./ts";
import { ServerHost } from "./ts.server";
import { IO } from "./Harness";
import * as ts from "./ts";

export const libFile: File = {
path: "/a/lib/lib.d.ts",
content: `/// <reference no-default-lib="true"/>
Expand Down Expand Up @@ -136,7 +136,7 @@ export function getDiffInKeys<T>(map: ESMap<string, T>, expectedKeys: readonly s
}
const notInActual: string[] = [];
const duplicates: string[] = [];
const seen = new ts.Map<string, true>();
const seen = new Map<string, true>();
forEach(expectedKeys, expectedKey => {
if (seen.has(expectedKey)) {
duplicates.push(expectedKey);
Expand Down Expand Up @@ -237,8 +237,8 @@ export function checkWatchedDirectoriesDetailed(host: TestServerHost, expectedDi
}

export function checkOutputContains(host: TestServerHost, expected: readonly string[]) {
const mapExpected = new ts.Set(expected);
const mapSeen = new ts.Set<string>();
const mapExpected = new Set(expected);
const mapSeen = new Set<string>();
for (const f of host.getOutput()) {
assert.isFalse(mapSeen.has(f), `Already found ${f} in ${JSON.stringify(host.getOutput())}`);
if (mapExpected.has(f)) {
Expand All @@ -250,7 +250,7 @@ export function checkOutputContains(host: TestServerHost, expected: readonly str
}

export function checkOutputDoesNotContain(host: TestServerHost, expectedToBeAbsent: string[] | readonly string[]) {
const mapExpectedToBeAbsent = new ts.Set(expectedToBeAbsent);
const mapExpectedToBeAbsent = new Set(expectedToBeAbsent);
for (const f of host.getOutput()) {
assert.isFalse(mapExpectedToBeAbsent.has(f), `Contains ${f} in ${JSON.stringify(host.getOutput())}`);
}
Expand Down Expand Up @@ -353,7 +353,7 @@ export class TestServerHost implements ServerHost, FormatDiagnosticsHost, Module

private readonly output: string[] = [];

private fs: ESMap<Path, FSEntry> = new ts.Map();
private fs: ESMap<Path, FSEntry> = new Map();
private time = timeIncrements;
getCanonicalFileName: (s: string) => string;
private toPath: (f: string) => Path;
Expand Down Expand Up @@ -1003,7 +1003,7 @@ export class TestServerHost implements ServerHost, FormatDiagnosticsHost, Module
}

snap(): ESMap<Path, FSEntry> {
const result = new ts.Map<Path, FSEntry>();
const result = new Map<Path, FSEntry>();
this.fs.forEach((value, key) => {
const cloneValue = clone(value);
if (isFsFolder(cloneValue)) {
Expand All @@ -1016,7 +1016,7 @@ export class TestServerHost implements ServerHost, FormatDiagnosticsHost, Module
}

writtenFiles?: ESMap<Path, number>;
diff(baseline: string[], base: ESMap<string, FSEntry> = new ts.Map()) {
diff(baseline: string[], base: ESMap<string, FSEntry> = new Map()) {
this.fs.forEach(newFsEntry => {
diffFsEntry(baseline, base.get(newFsEntry.path), newFsEntry, this.writtenFiles);
});
Expand Down Expand Up @@ -1180,7 +1180,7 @@ export type TestServerHostTrackingWrittenFiles = TestServerHost & {
export function changeToHostTrackingWrittenFiles(inputHost: TestServerHost) {
const host = inputHost as TestServerHostTrackingWrittenFiles;
const originalWriteFile = host.writeFile;
host.writtenFiles = new ts.Map<Path, number>();
host.writtenFiles = new Map<Path, number>();
host.writeFile = (fileName, content) => {
originalWriteFile.call(host, fileName, content);
const path = host.toFullPath(fileName);
Expand Down
Loading

0 comments on commit 9a78868

Please sign in to comment.