Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
weswigham committed Dec 17, 2019
1 parent 00130a1 commit 1c39443
Show file tree
Hide file tree
Showing 26 changed files with 327 additions and 320 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"bdd",
"--no-timeouts",
"--colors",
"built/local/run.js",
"built/local/testRunner/Harness.js",
"-f",
// You can change this to be the name of a specific test file (without the file extension)
// to consistently launch the same test
Expand All @@ -46,7 +46,7 @@
"preLaunchTask": "tests",
"console": "integratedTerminal",
"outFiles": [
"${workspaceRoot}/built/local/run.js"
"${workspaceRoot}/built/local/testRunner/Harness.js"
]
},
{
Expand Down
337 changes: 169 additions & 168 deletions Gulpfile.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/compiler/sys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ export let sys: System = (() => {
}
},
getExecutingFilePath() {
return __filename;
return _path.join(_path.dirname(__filename), "..", _path.basename(__filename)); // COMPAT: return path in root of our dir, rather than direct location of sys impl
},
getCurrentDirectory() {
return process.cwd();
Expand Down
2 changes: 2 additions & 0 deletions src/harness/Harness.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import "../services/services"; // ensure services setup code is called
import "./harnessGlobals";
export * from "./runnerbase";
export * from "./harnessIO";
export * from "./typeWriter";
Expand Down
4 changes: 2 additions & 2 deletions src/harness/fakesHosts.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { FileSystem } from "./vfs";
import { removeByteOrderMark, addUTF8ByteOrderMark, assertInvariants } from "./Utils";
import { dirname, combine, resolve } from "./vpath";
import { matchFiles, FileSystemEntries, notImplemented, generateDjb2Hash, SourceFile, getDefaultCompilerOptions, getNewLineCharacter, CompilerOptions, getDefaultLibFileName, createSourceFile, DiagnosticMessage, Diagnostic, getLocaleSpecificMessage, formatStringFromArgs, isArray, DiagnosticMessageChain, DiagnosticRelatedInformation, ProgramBuildInfoDiagnostic, compareStringsCaseSensitive, isString, BuildInfo, MapLike, getOwnKeys, BuilderProgram, isBuildInfoFile, getBuildInfo, Debug, getBuildInfoText, CreateProgram, createEmitAndSemanticDiagnosticsBuilderProgram, createDiagnosticReporter, sys } from "./ts";
import { matchFiles, FileSystemEntries, notImplemented, generateDjb2Hash, SourceFile, getDefaultCompilerOptions, getNewLineCharacter, CompilerOptions, getDefaultLibFileName, createSourceFile, DiagnosticMessage, Diagnostic, getLocaleSpecificMessage, formatStringFromArgs, isArray, DiagnosticMessageChain, DiagnosticRelatedInformation, ProgramBuildInfoDiagnostic, compareStringsCaseSensitive, isString, BuildInfo, MapLike, getOwnKeys, BuilderProgram, isBuildInfoFile, getBuildInfo, Debug, getBuildInfoText, CreateProgram, createEmitAndSemanticDiagnosticsBuilderProgram, createDiagnosticReporter, sys } from "../compiler/ts";
import { TextDocument } from "./documents";
import { SortedMap } from "./collections";
import { lightMode } from "./Harness";
import * as ts from "./ts";
import * as ts from "../compiler/ts";
/**
* Fake implementations of various compiler dependencies.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/harness/harnessIO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function createNodeIO(): IO {
log: s => console.log(s),
args: () => sys.args,
getExecutingFilePath: () => sys.getExecutingFilePath(),
getWorkspaceRoot: () => resolve(__dirname, "../.."),
getWorkspaceRoot: () => resolve(__dirname, "../../.."),
exit: exitCode => sys.exit(exitCode),
readDirectory: (path, extension, exclude, include, depth) => sys.readDirectory(path, extension, exclude, include, depth),
getAccessibleFileSystemEntries,
Expand Down
3 changes: 2 additions & 1 deletion src/server/session.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { HostCancellationToken, CompilerOptions, getEmitDeclarations, Diagnostic, flattenDiagnosticMessageText, diagnosticCategoryName, map, DiagnosticRelatedInformation, getLineAndCharacterOfPosition, LineAndCharacter, TextChange, textSpanEnd, Debug, OperationCanceledException, MultiMap, Path, flatMapToMutable, isArray, flatMap, deduplicate, equateValues, DocumentPosition, contains, UserPreferences, RenameLocation, documentSpansEqual, firstOrUndefined, ReferencedSymbol, ReferencedSymbolDefinitionInfo, createTextSpan, find, createMap, Push, DocumentSpan, TextSpan, PossibleProgramFileInfo, getSnapshotText, perfLogger, WithMetadata, arrayFrom, filter, concatenate, DefinitionInfo, EmitOutput, ImplementationLocation, TextInsertion, DocumentHighlights, RenameInfo, identity, displayPartsToString, ScriptKind, QuickInfo, createTextSpanFromBounds, formatting, mapDefined, startsWith, compareStringsCaseSensitiveUI, fileExtensionIs, Extension, singleIterator, normalizePath, NavigationBarItem, NavigationTree, NavigateToItem, getSupportedCodeFixes, TextRange, RefactorEditInfo, FileTextChanges, CodeActionCommand, toArray, CodeAction, stringContains, SelectionRange, createMapFromTemplate, version, mapIterator, arrayIterator, mapDefinedIterator, arrayReverseIterator, FormatCodeSettings, first, computeLineAndCharacterOfPosition, computeLineStarts } from "./ts";
import { Project, NormalizedPath, isInferredProject, isExternalProject, protocol, Logger, LogLevel, indent, ServerHost, ProjectService, emptyArray, toNormalizedPath, isConfiguredProject, ITypingsInstaller, ProjectServiceEventHandler, GcTimer, ProjectServiceOptions, ProjectServiceEvent, ProjectsUpdatedInBackgroundEvent, ProjectLoadingStartEvent, ProjectLoadingFinishEvent, LargeFileReferencedEvent, ConfigFileDiagEvent, ProjectLanguageServiceStateEvent, ProjectInfoTelemetryEvent, ProjectKind, Msg, updateProjectIfDirty, ScriptInfo, Errors, convertFormatOptions, convertUserPreferences, convertScriptKindName, stringifyIndented, ScriptInfoOrConfig, isConfigFile } from "./ts.server";
import { Project, NormalizedPath, isInferredProject, isExternalProject, Logger, LogLevel, indent, ServerHost, ProjectService, emptyArray, toNormalizedPath, isConfiguredProject, ITypingsInstaller, ProjectServiceEventHandler, GcTimer, ProjectServiceOptions, ProjectServiceEvent, ProjectsUpdatedInBackgroundEvent, ProjectLoadingStartEvent, ProjectLoadingFinishEvent, LargeFileReferencedEvent, ConfigFileDiagEvent, ProjectLanguageServiceStateEvent, ProjectInfoTelemetryEvent, ProjectKind, Msg, updateProjectIfDirty, ScriptInfo, Errors, convertFormatOptions, convertUserPreferences, convertScriptKindName, stringifyIndented, ScriptInfoOrConfig, isConfigFile } from "./ts.server";
import { Location, DiagnosticWithFileName, CommandTypes, Message, RequestCompletedEventBody, ProjectLoadingStartEventBody, ProjectLoadingFinishEventBody, LargeFileReferencedEventBody, ConfigFileDiagnosticEventBody, ProjectLanguageServiceStateEventName, ProjectLanguageServiceStateEventBody, TelemetryEventName, TelemetryEventBody, ProjectsUpdatedInBackgroundEventBody, FileRequestArgs, Response, DiagnosticEventKind, DiagnosticEventBody, EncodedSyntacticClassificationsRequestArgs, EncodedSemanticClassificationsRequestArgs, DiagnosticWithLinePosition, CompilerOptionsDiagnosticsRequestArgs, FileLocationRequestArgs, FileSpanWithContext, DefinitionInfoAndBoundSpan, FileSpan, OccurrencesResponseItem, SyntacticDiagnosticsSyncRequestArgs, SemanticDiagnosticsSyncRequestArgs, SuggestionDiagnosticsSyncRequestArgs, JsxClosingTagRequestArgs, DocumentHighlightsRequestArgs, DocumentHighlightsItem, SetCompilerOptionsForInferredProjectsArgs, ProjectInfoRequestArgs, ProjectInfo, RenameRequestArgs, RenameResponseBody, RenameInfoSuccess, SpanGroup, ReferencesResponseBody, ReferencesResponseItem, OutliningSpan, TodoCommentRequestArgs, SpanOfEnclosingCommentRequestArgs, IndentationRequestArgs, BraceCompletionRequestArgs, QuickInfoResponseBody, FormatRequestArgs, CodeEdit, FormatOnKeyRequestArgs, CompletionsRequestArgs, CompletionEntry, CompletionInfo, CompletionDetailsRequestArgs, CompletionEntryDetails, CompileOnSaveAffectedFileListSingleProject, CompileOnSaveEmitFileRequestArgs, SignatureHelpRequestArgs, SignatureHelpItems, ChangeRequestArgs, ReloadRequestArgs, NavtoRequestArgs, NavtoItem, FileLocationOrRangeRequestArgs, GetApplicableRefactorsRequestArgs, ApplicableRefactorInfo, GetEditsForRefactorRequestArgs, OrganizeImportsRequestArgs, FileCodeEdits, GetEditsForFileRenameRequestArgs, CodeFixRequestArgs, CodeFixAction, GetCombinedCodeFixRequestArgs, CombinedCodeActions, ApplyCodeActionCommandRequestArgs, FileRangeRequestArgs, ConfigurePluginRequestArguments, SelectionRangeRequestArgs, Request, StatusResponseBody, OpenExternalProjectRequest, OpenExternalProjectsRequest, CloseExternalProjectRequest, SynchronizeProjectListRequest, UpdateOpenRequest, ApplyChangedToOpenFilesRequest, DefinitionRequest, EmitOutputRequest, FileLocationRequest, RenameRequest, RenameFullRequest, OpenRequest, QuickInfoRequest, FileRequest, TodoCommentRequest, IndentationRequest, BraceCompletionRequest, DocCommentTemplateRequest, SpanOfEnclosingCommentRequest, FormatRequest, FormatOnKeyRequest, CompletionsRequest, CompletionDetailsRequest, CompileOnSaveAffectedFileListRequest, CompileOnSaveEmitFileRequest, SignatureHelpRequest, CompilerOptionsDiagnosticsRequest, EncodedSyntacticClassificationsRequest, EncodedSemanticClassificationsRequest, SemanticDiagnosticsSyncRequest, SyntacticDiagnosticsSyncRequest, SuggestionDiagnosticsSyncRequest, GeterrRequest, GeterrForProjectRequest, ChangeRequest, ConfigureRequest, ReloadRequest, SavetoRequestArgs, NavtoRequest, DocumentHighlightsRequest, SetCompilerOptionsForInferredProjectsRequest, ProjectInfoRequest, JsxClosingTagRequest, CodeFixRequest, GetCombinedCodeFixRequest, ApplyCodeActionCommandRequest, GetApplicableRefactorsRequest, GetEditsForRefactorRequest, OrganizeImportsRequest, GetEditsForFileRenameRequest, ConfigurePluginRequest, SelectionRangeRequest, TextSpanWithContext } from "./ts.server.protocol";
import * as ts from "./ts";
import * as protocol from "./ts.server.protocol";
interface StackTraceError extends Error {
stack?: string;
}
Expand Down
5 changes: 3 additions & 2 deletions src/testRunner/Harness.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as Parallel from "./Harness.Parallel";
export { Parallel };
export * from "../harness/Harness";
export * from "./fourslashRunner";
export * from "./compilerRunner";
export * from "./externalCompileRunner";
export * from "./test262Runner";
export * from "./runner";
import * as Parallel from "./Harness.Parallel";
export { Parallel };
import "./ts"; // include all the unit tests
2 changes: 1 addition & 1 deletion src/testRunner/compilerRunner.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FileBasedTest, RunnerBase, TestRunnerKind, IO, getFileBasedTestConfigurationDescription, FileBasedTestConfiguration, TestCaseParser, Compiler, getFileBasedTestConfigurations, Baseline } from "./Harness";
import { normalizeSeparators, basename } from "./vpath";
import { some, getDirectoryPath, CompilerOptions, cloneCompilerOptions, combinePaths, isRootedDiskPath, getNormalizedAbsolutePath, fileExtensionIs, Extension, length, toPath, identity } from "./ts";
import { some, getDirectoryPath, CompilerOptions, cloneCompilerOptions, combinePaths, isRootedDiskPath, getNormalizedAbsolutePath, fileExtensionIs, Extension, length, toPath, identity } from "../services/ts";
import { CompilationResult } from "./compiler";
import { sanitizeTraceResolutionLogEntry, removeTestPathPrefixes } from "./Utils";
import * as vpath from "./vpath";
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/externalCompileRunner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RunnerBase, IO, isWorker, Baseline, TestRunnerKind } from "./Harness";
import { Debug, flatten, comparePathsCaseSensitive, compareValues, compareStringsCaseSensitive, stringContains } from "./ts";
import { Debug, flatten, comparePathsCaseSensitive, compareValues, compareStringsCaseSensitive, stringContains } from "../compiler/ts";
const fs: typeof import("fs") = require("fs");
const path: typeof import("path") = require("path");
const del: typeof import("del") = require("del");
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/fourslashRunner.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RunnerBase, TestRunnerKind, IO } from "./Harness";
import { FourSlashTestType, runFourSlashTest } from "./FourSlash";
import { Debug, normalizeSlashes } from "./ts";
import { Debug, normalizeSlashes } from "../compiler/ts";
export class FourSlashRunner extends RunnerBase {
protected basePath: string;
protected testSuiteName: TestRunnerKind;
Expand Down
8 changes: 4 additions & 4 deletions src/testRunner/parallel/host.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { configOption, IO, TestRunnerKind, runners, workerCount, noColors, TestConfig, lightMode, runUnitTests, stackTraceLimit, globalTimeout, taskConfigsFolder, keepFailed } from "../Harness";
import { Task, ErrorInfo, TestInfo, TaskTimeout, ParallelClientMessage, ParallelHostMessage, shimNoopTestInterface } from "../Harness.Parallel";
import { createMap, combinePaths, Debug } from "../ts";
import { createMap, combinePaths, Debug } from "../../compiler/ts";
export function start() {
const Mocha = require("mocha") as typeof import("mocha");
const Base = Mocha.reporters.Base;
Expand All @@ -14,8 +14,8 @@ export function start() {
const path = require("path") as typeof import("path");
const { fork } = require("child_process") as typeof import("child_process");
const { statSync } = require("fs") as typeof import("fs");
// NOTE: paths for module and types for FailedTestReporter _do not_ line up due to our use of --outFile for run.js
const FailedTestReporter = require(path.resolve(__dirname, "../../scripts/failed-tests")) as typeof import("../../../scripts/failed-tests");
// NOTE: paths for module and types for FailedTestReporter _do not_ line up due to our use of --outDir for results
const FailedTestReporter = require(path.resolve(__dirname, "../../../../scripts/failed-tests")) as typeof import("../../../scripts/failed-tests");
const perfdataFileNameFragment = ".parallelperf";
const perfData = readSavedPerfData(configOption);
const newTasks: Task[] = [];
Expand Down Expand Up @@ -586,4 +586,4 @@ export function start() {
}
// eslint-disable-next-line no-restricted-globals
setTimeout(() => startDelayed(perfData, totalCost), 0); // Do real startup on next tick, so all unit tests have been collected
}
}
2 changes: 1 addition & 1 deletion src/testRunner/parallel/shared.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TestRunnerKind } from "../Harness";
import { noop } from "../ts";
import { noop } from "../../compiler/ts";
export interface RunnerTask {
runner: TestRunnerKind;
file: string;
Expand Down
4 changes: 2 additions & 2 deletions src/testRunner/parallel/worker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Task, TaskResult, UnitTestTask, RunnerTask, ErrorInfo, TestInfo, ParallelHostMessage, ParallelClientMessage, shimNoopTestInterface } from "../Harness.Parallel";
import { createMap } from "../ts";
import { createMap } from "../../compiler/ts";
import { globalTimeout, createRunner, RunnerBase, runUnitTests } from "../Harness";
import * as ts from "../ts";
import * as ts from "../../compiler/ts";
export function start() {
function hookUncaughtExceptions() {
if (!exceptionsHooked) {
Expand Down
4 changes: 2 additions & 2 deletions src/testRunner/projectsRunner.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { SourceFile, ModuleKind, Program, CompilerOptions, Diagnostic, SourceMapEmitResult, normalizePath, combinePaths, findConfigFile, readJsonConfigFile, parseJsonSourceFileConfigFileContent, getDirectoryPath, concatenate, normalizeSlashes, CharacterCodes, createProgram, getPreEmitDiagnostics, forEach, getNormalizedAbsolutePath, removeFileExtension, Extension, contains, isRootedDiskPath, ModuleResolutionKind, NewLineKind, arrayToMap, optionDeclarations, isString } from "./ts";
import { SourceFile, ModuleKind, Program, CompilerOptions, Diagnostic, SourceMapEmitResult, normalizePath, combinePaths, findConfigFile, readJsonConfigFile, parseJsonSourceFileConfigFileContent, getDirectoryPath, concatenate, normalizeSlashes, CharacterCodes, createProgram, getPreEmitDiagnostics, forEach, getNormalizedAbsolutePath, removeFileExtension, Extension, contains, isRootedDiskPath, ModuleResolutionKind, NewLineKind, arrayToMap, optionDeclarations, isString } from "../compiler/ts";
import { TextDocument } from "./documents";
import { RunnerBase, shards, shardId, TestRunnerKind, IO, Baseline, isDefaultLibraryFile, Compiler } from "./Harness";
import { CompilerHost, System, ParseConfigHost } from "./fakes";
import { FileSystem, srcFolder, createFromFileSystem, createResolver, builtFolder, testLibFolder } from "./vfs";
import { resolve, relative, combine, beneath, isAbsolute, extname, isDefaultLibrary } from "./vpath";
import { removeTestPathPrefixes } from "./Utils";
import * as ts from "./ts";
import * as ts from "../compiler/ts";
// Test case is json of below type in tests/cases/project/
interface ProjectRunnerTestCase {
scenario: string;
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/runner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RunnerBase, TestRunnerKind, CompilerBaselineRunner, CompilerTestType, FourSlashRunner, Test262BaselineRunner, UserCodeRunner, DefinitelyTypedRunner, DockerfileRunner, IO, setLightMode, setShardId, setShards, GeneratedFourslashRunner } from "./Harness";
import { forEach, Debug, getUILocale, setUILocale, noop } from "./ts";
import { forEach, Debug, getUILocale, setUILocale, noop } from "../compiler/ts";
import { FourSlashTestType } from "./FourSlash";
import { ProjectRunner } from "./project";
import { RWCRunner } from "./RWC";
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/rwcRunner.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IoLog, wrapIO, newStyleLogIntoOldStyleLog } from "./Playback";
import { IO, setHarnessIO, Compiler, Baseline, isDefaultLibraryFile, RunnerBase, TestRunnerKind } from "./Harness";
import { CompilationResult } from "./compiler";
import { CompilerOptions, getBaseFileName, ParsedCommandLine, parseCommandLine, forEach, parseJsonText, ParseConfigHost, parseJsonSourceFileConfigFileContent, getDirectoryPath, extend, setConfigFileInOptions, createMap, normalizeSlashes } from "./ts";
import { CompilerOptions, getBaseFileName, ParsedCommandLine, parseCommandLine, forEach, parseJsonText, ParseConfigHost, parseJsonSourceFileConfigFileContent, getDirectoryPath, extend, setConfigFileInOptions, createMap, normalizeSlashes } from "../compiler/ts";
import { isTsConfigFile } from "./vpath";
// In harness baselines, null is different than undefined. See `generateActual` in `harness.ts`.
function runWithIOLog(ioLog: IoLog, fn: (oldIO: IO) => void) {
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/test262Runner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RunnerBase, Compiler, IO, Baseline, TestCaseParser, TestRunnerKind } from "./Harness";
import { CompilerOptions, ScriptTarget, ModuleKind, removeFileExtension, map, normalizePath } from "./ts";
import { CompilerOptions, ScriptTarget, ModuleKind, removeFileExtension, map, normalizePath } from "../compiler/ts";
import { CompilationResult } from "./compiler";
import { assertInvariants, sourceFileToJSON } from "./Utils";
// In harness baselines, null is different than undefined. See `generateActual` in `harness.ts`.
Expand Down
Loading

0 comments on commit 1c39443

Please sign in to comment.