tstyche 7.2.5 → 8.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/api.d.ts +16 -761
- package/dist/api.js +16 -6204
- package/dist/bin.js +2 -3
- package/dist/checker/BaseCheckerAdapter.d.ts +15 -0
- package/dist/checker/BaseCheckerAdapter.js +32 -0
- package/dist/checker/CompatCheckerAdapter.d.ts +70 -0
- package/dist/checker/CompatCheckerAdapter.js +221 -0
- package/dist/checker/NativeCheckerAdapter.d.ts +70 -0
- package/dist/checker/NativeCheckerAdapter.js +200 -0
- package/dist/checker/index.d.ts +3 -0
- package/dist/checker/index.js +2 -0
- package/dist/checker/types.d.ts +9 -0
- package/dist/checker/types.js +1 -0
- package/dist/cli/Cli.d.ts +5 -0
- package/dist/cli/Cli.js +144 -0
- package/dist/cli/CliDIagnosticText.d.ts +3 -0
- package/dist/cli/CliDIagnosticText.js +9 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1 -0
- package/dist/collect/CollectDiagnosticText.d.ts +3 -0
- package/dist/collect/CollectDiagnosticText.js +5 -0
- package/dist/collect/CollectService.d.ts +9 -0
- package/dist/collect/CollectService.js +150 -0
- package/dist/collect/ExpectNode.d.ts +16 -0
- package/dist/collect/ExpectNode.js +30 -0
- package/dist/collect/IdentifierLookup.d.ts +18 -0
- package/dist/collect/IdentifierLookup.js +90 -0
- package/dist/collect/TestTree.d.ts +16 -0
- package/dist/collect/TestTree.js +15 -0
- package/dist/collect/TestTreeNode.d.ts +15 -0
- package/dist/collect/TestTreeNode.js +27 -0
- package/dist/collect/TestTreeNodeBrand.enum.d.ts +6 -0
- package/dist/collect/TestTreeNodeBrand.enum.js +7 -0
- package/dist/collect/TestTreeNodeFlags.enum.d.ts +6 -0
- package/dist/collect/TestTreeNodeFlags.enum.js +7 -0
- package/dist/collect/index.d.ts +6 -0
- package/dist/collect/index.js +6 -0
- package/dist/config/CommandParser.d.ts +7 -0
- package/dist/config/CommandParser.js +107 -0
- package/dist/config/Config.d.ts +18 -0
- package/dist/config/Config.js +59 -0
- package/dist/config/ConfigDiagnosticText.d.ts +19 -0
- package/dist/config/ConfigDiagnosticText.js +57 -0
- package/dist/config/ConfigParser.d.ts +10 -0
- package/dist/config/ConfigParser.js +165 -0
- package/dist/config/Directive.d.ts +9 -0
- package/dist/config/Directive.js +119 -0
- package/dist/config/DirectiveDiagnosticText.d.ts +5 -0
- package/dist/config/DirectiveDiagnosticText.js +11 -0
- package/dist/config/OptionBrand.enum.d.ts +8 -0
- package/dist/config/OptionBrand.enum.js +9 -0
- package/dist/config/OptionGroup.enum.d.ts +5 -0
- package/dist/config/OptionGroup.enum.js +6 -0
- package/dist/config/Options.d.ts +29 -0
- package/dist/config/Options.js +290 -0
- package/dist/config/Target.d.ts +7 -0
- package/dist/config/Target.js +47 -0
- package/dist/config/defaultOptions.d.ts +2 -0
- package/dist/config/defaultOptions.js +14 -0
- package/dist/config/index.d.ts +8 -0
- package/dist/config/index.js +7 -0
- package/dist/config/types.d.ts +55 -0
- package/dist/config/types.js +1 -0
- package/dist/diagnostic/Diagnostic.d.ts +19 -0
- package/dist/diagnostic/Diagnostic.js +51 -0
- package/dist/diagnostic/DiagnosticCategory.enum.d.ts +4 -0
- package/dist/diagnostic/DiagnosticCategory.enum.js +5 -0
- package/dist/diagnostic/DiagnosticOrigin.d.ts +13 -0
- package/dist/diagnostic/DiagnosticOrigin.js +27 -0
- package/dist/diagnostic/helpers.d.ts +6 -0
- package/dist/diagnostic/helpers.js +74 -0
- package/dist/diagnostic/index.d.ts +5 -0
- package/dist/diagnostic/index.js +4 -0
- package/dist/diagnostic/types.d.ts +2 -0
- package/dist/diagnostic/types.js +1 -0
- package/dist/editor/TextEditor.d.ts +15 -0
- package/dist/editor/TextEditor.js +88 -0
- package/dist/editor/index.d.ts +2 -0
- package/dist/editor/index.js +1 -0
- package/dist/editor/types.d.ts +4 -0
- package/dist/editor/types.js +1 -0
- package/dist/environment/Environment.d.ts +5 -0
- package/dist/environment/Environment.js +89 -0
- package/dist/environment/environmentOptions.d.ts +1 -0
- package/dist/environment/environmentOptions.js +2 -0
- package/dist/environment/index.d.ts +2 -0
- package/dist/environment/index.js +1 -0
- package/dist/environment/types.d.ts +10 -0
- package/dist/environment/types.js +1 -0
- package/dist/events/EventEmitter.d.ts +14 -0
- package/dist/events/EventEmitter.js +42 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.js +1 -0
- package/dist/events/types.d.ts +88 -0
- package/dist/events/types.js +1 -0
- package/dist/expect/AbilityMatcherBase.d.ts +16 -0
- package/dist/expect/AbilityMatcherBase.js +52 -0
- package/dist/expect/Ensure.d.ts +10 -0
- package/dist/expect/Ensure.js +51 -0
- package/dist/expect/ExpectDiagnosticText.d.ts +29 -0
- package/dist/expect/ExpectDiagnosticText.js +87 -0
- package/dist/expect/ExpectService.d.ts +21 -0
- package/dist/expect/ExpectService.js +90 -0
- package/dist/expect/RelationMatcherBase.d.ts +12 -0
- package/dist/expect/RelationMatcherBase.js +16 -0
- package/dist/expect/ToAcceptProps.d.ts +10 -0
- package/dist/expect/ToAcceptProps.js +52 -0
- package/dist/expect/ToBe.d.ts +13 -0
- package/dist/expect/ToBe.js +18 -0
- package/dist/expect/ToBeApplicable.d.ts +10 -0
- package/dist/expect/ToBeApplicable.js +72 -0
- package/dist/expect/ToBeAssignableFrom.d.ts +9 -0
- package/dist/expect/ToBeAssignableFrom.js +12 -0
- package/dist/expect/ToBeAssignableTo.d.ts +9 -0
- package/dist/expect/ToBeAssignableTo.js +12 -0
- package/dist/expect/ToBeCallableWith.d.ts +11 -0
- package/dist/expect/ToBeCallableWith.js +29 -0
- package/dist/expect/ToBeConstructableWith.d.ts +11 -0
- package/dist/expect/ToBeConstructableWith.js +29 -0
- package/dist/expect/ToBeInstantiableWith.d.ts +10 -0
- package/dist/expect/ToBeInstantiableWith.js +31 -0
- package/dist/expect/ToHaveProperty.d.ts +10 -0
- package/dist/expect/ToHaveProperty.js +59 -0
- package/dist/expect/ToRaiseError.d.ts +9 -0
- package/dist/expect/ToRaiseError.js +82 -0
- package/dist/expect/index.d.ts +2 -0
- package/dist/expect/index.js +1 -0
- package/dist/expect/types.d.ts +7 -0
- package/dist/expect/types.js +1 -0
- package/dist/file/FilePosition.d.ts +7 -0
- package/dist/file/FilePosition.js +16 -0
- package/dist/file/index.d.ts +1 -0
- package/dist/file/index.js +1 -0
- package/dist/glob/Braces.d.ts +4 -0
- package/dist/glob/Braces.js +56 -0
- package/dist/glob/Glob.d.ts +4 -0
- package/dist/glob/Glob.js +49 -0
- package/dist/glob/index.d.ts +1 -0
- package/dist/glob/index.js +1 -0
- package/dist/handlers/CancellationHandler.d.ts +7 -0
- package/dist/handlers/CancellationHandler.js +15 -0
- package/dist/handlers/ExitCodeHandler.d.ts +7 -0
- package/dist/handlers/ExitCodeHandler.js +20 -0
- package/dist/handlers/ResultHandler.d.ts +5 -0
- package/dist/handlers/ResultHandler.js +206 -0
- package/dist/handlers/index.d.ts +3 -0
- package/dist/handlers/index.js +3 -0
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +40 -45
- package/dist/index.d.ts +40 -45
- package/dist/index.js +1 -2
- package/dist/input/InputService.d.ts +6 -0
- package/dist/input/InputService.js +16 -0
- package/dist/input/index.d.ts +1 -0
- package/dist/input/index.js +1 -0
- package/dist/json/JsonNode.d.ts +11 -0
- package/dist/json/JsonNode.js +28 -0
- package/dist/json/JsonScanner.d.ts +14 -0
- package/dist/json/JsonScanner.js +105 -0
- package/dist/json/index.d.ts +3 -0
- package/dist/json/index.js +2 -0
- package/dist/json/types.d.ts +1 -0
- package/dist/json/types.js +1 -0
- package/dist/layers/AbilityLayer.d.ts +10 -0
- package/dist/layers/AbilityLayer.js +186 -0
- package/dist/layers/Layers.d.ts +11 -0
- package/dist/layers/Layers.js +47 -0
- package/dist/layers/SuppressedLayer.d.ts +11 -0
- package/dist/layers/SuppressedLayer.js +93 -0
- package/dist/layers/index.d.ts +2 -0
- package/dist/layers/index.js +1 -0
- package/dist/layers/types.d.ts +8 -0
- package/dist/layers/types.js +1 -0
- package/dist/output/CodeFrameText.d.ts +10 -0
- package/dist/output/CodeFrameText.js +71 -0
- package/dist/output/OutputService.d.ts +13 -0
- package/dist/output/OutputService.js +38 -0
- package/dist/output/StreamController.d.ts +10 -0
- package/dist/output/StreamController.js +16 -0
- package/dist/output/addsText.d.ts +4 -0
- package/dist/output/addsText.js +8 -0
- package/dist/output/describeNameText.d.ts +2 -0
- package/dist/output/describeNameText.js +5 -0
- package/dist/output/diagnosticText.d.ts +4 -0
- package/dist/output/diagnosticText.js +23 -0
- package/dist/output/dotText.d.ts +3 -0
- package/dist/output/dotText.js +11 -0
- package/dist/output/fileStatusText.d.ts +4 -0
- package/dist/output/fileStatusText.js +26 -0
- package/dist/output/formattedText.d.ts +2 -0
- package/dist/output/formattedText.js +19 -0
- package/dist/output/helpText.d.ts +3 -0
- package/dist/output/helpText.js +52 -0
- package/dist/output/helpers.d.ts +5 -0
- package/dist/output/helpers.js +23 -0
- package/dist/output/index.d.ts +16 -0
- package/dist/output/index.js +15 -0
- package/dist/output/prologueText.d.ts +2 -0
- package/dist/output/prologueText.js +5 -0
- package/dist/output/summaryText.d.ts +12 -0
- package/dist/output/summaryText.js +31 -0
- package/dist/output/testNameText.d.ts +3 -0
- package/dist/output/testNameText.js +24 -0
- package/dist/output/types.d.ts +5 -0
- package/dist/output/types.js +1 -0
- package/dist/output/usesText.d.ts +5 -0
- package/dist/output/usesText.js +22 -0
- package/dist/output/waitingForFileChangesText.d.ts +2 -0
- package/dist/output/waitingForFileChangesText.js +5 -0
- package/dist/output/watchUsageText.d.ts +2 -0
- package/dist/output/watchUsageText.js +12 -0
- package/dist/path/Path.d.ts +7 -0
- package/dist/path/Path.js +28 -0
- package/dist/path/index.d.ts +1 -0
- package/dist/path/index.js +1 -0
- package/dist/project/CompatMappedDiagnostic.d.ts +12 -0
- package/dist/project/CompatMappedDiagnostic.js +25 -0
- package/dist/project/CompatProjectService.d.ts +19 -0
- package/dist/project/CompatProjectService.js +188 -0
- package/dist/project/FileMapService.d.ts +6 -0
- package/dist/project/FileMapService.js +14 -0
- package/dist/project/NativeMappedDiagnostic.d.ts +14 -0
- package/dist/project/NativeMappedDiagnostic.js +29 -0
- package/dist/project/NativeProjectService.d.ts +21 -0
- package/dist/project/NativeProjectService.js +216 -0
- package/dist/project/ProjectConfigService.d.ts +8 -0
- package/dist/project/ProjectConfigService.js +73 -0
- package/dist/project/index.d.ts +3 -0
- package/dist/project/index.js +2 -0
- package/dist/project/types.d.ts +7 -0
- package/dist/project/types.js +1 -0
- package/dist/reject/Reject.d.ts +9 -0
- package/dist/reject/Reject.js +43 -0
- package/dist/reject/RejectDiagnosticText.d.ts +5 -0
- package/dist/reject/RejectDiagnosticText.js +16 -0
- package/dist/reject/helpers.d.ts +1 -0
- package/dist/reject/helpers.js +3 -0
- package/dist/reject/index.d.ts +1 -0
- package/dist/reject/index.js +1 -0
- package/dist/reporters/BaseReporter.d.ts +7 -0
- package/dist/reporters/BaseReporter.js +6 -0
- package/dist/reporters/DotReporter.d.ts +6 -0
- package/dist/reporters/DotReporter.js +51 -0
- package/dist/reporters/FileView.d.ts +13 -0
- package/dist/reporters/FileView.js +33 -0
- package/dist/reporters/ListReporter.d.ts +6 -0
- package/dist/reporters/ListReporter.js +125 -0
- package/dist/reporters/SetupReporter.d.ts +4 -0
- package/dist/reporters/SetupReporter.js +21 -0
- package/dist/reporters/SummaryReporter.d.ts +5 -0
- package/dist/reporters/SummaryReporter.js +19 -0
- package/dist/reporters/WatchReporter.d.ts +5 -0
- package/dist/reporters/WatchReporter.js +21 -0
- package/dist/reporters/index.d.ts +7 -0
- package/dist/reporters/index.js +6 -0
- package/dist/reporters/types.d.ts +5 -0
- package/dist/reporters/types.js +1 -0
- package/dist/result/DescribeResult.d.ts +9 -0
- package/dist/result/DescribeResult.js +11 -0
- package/dist/result/ExpectResult.d.ts +10 -0
- package/dist/result/ExpectResult.js +11 -0
- package/dist/result/FileResult.d.ts +15 -0
- package/dist/result/FileResult.js +13 -0
- package/dist/result/ProjectConfigKind.enum.d.ts +6 -0
- package/dist/result/ProjectConfigKind.enum.js +7 -0
- package/dist/result/ProjectResult.d.ts +8 -0
- package/dist/result/ProjectResult.js +9 -0
- package/dist/result/Result.d.ts +13 -0
- package/dist/result/Result.js +14 -0
- package/dist/result/ResultStatus.enum.d.ts +10 -0
- package/dist/result/ResultStatus.enum.js +11 -0
- package/dist/result/SuppressedResult.d.ts +5 -0
- package/dist/result/SuppressedResult.js +6 -0
- package/dist/result/TargetResult.d.ts +11 -0
- package/dist/result/TargetResult.js +12 -0
- package/dist/result/TestResult.d.ts +13 -0
- package/dist/result/TestResult.js +13 -0
- package/dist/result/helpers.d.ts +7 -0
- package/dist/result/helpers.js +21 -0
- package/dist/result/index.d.ts +11 -0
- package/dist/result/index.js +10 -0
- package/dist/result/types.d.ts +31 -0
- package/dist/result/types.js +1 -0
- package/dist/runner/FileRunner.d.ts +10 -0
- package/dist/runner/FileRunner.js +93 -0
- package/dist/runner/FixmeDiagnosticText.d.ts +4 -0
- package/dist/runner/FixmeDiagnosticText.js +8 -0
- package/dist/runner/FixmeService.d.ts +9 -0
- package/dist/runner/FixmeService.js +51 -0
- package/dist/runner/RunModeFlags.enum.d.ts +7 -0
- package/dist/runner/RunModeFlags.enum.js +8 -0
- package/dist/runner/Runner.d.ts +9 -0
- package/dist/runner/Runner.js +101 -0
- package/dist/runner/TestTreeWalker.d.ts +19 -0
- package/dist/runner/TestTreeWalker.js +169 -0
- package/dist/runner/index.d.ts +1 -0
- package/dist/runner/index.js +1 -0
- package/dist/scribbler/Color.enum.d.ts +10 -0
- package/dist/scribbler/Color.enum.js +11 -0
- package/dist/scribbler/Line.d.ts +9 -0
- package/dist/scribbler/Line.js +5 -0
- package/dist/scribbler/Scribbler.d.ts +10 -0
- package/dist/scribbler/Scribbler.js +53 -0
- package/dist/scribbler/Text.d.ts +9 -0
- package/dist/scribbler/Text.js +8 -0
- package/dist/scribbler/index.d.ts +5 -0
- package/dist/scribbler/index.js +4 -0
- package/dist/scribbler/jsxRuntime.d.ts +4 -0
- package/dist/scribbler/jsxRuntime.js +4 -0
- package/dist/scribbler/types.d.ts +19 -0
- package/dist/scribbler/types.js +1 -0
- package/dist/select/Select.d.ts +7 -0
- package/dist/select/Select.js +91 -0
- package/dist/select/SelectDiagnosticText.d.ts +6 -0
- package/dist/select/SelectDiagnosticText.js +24 -0
- package/dist/select/index.d.ts +2 -0
- package/dist/select/index.js +2 -0
- package/dist/store/Fetcher.d.ts +24 -0
- package/dist/store/Fetcher.js +68 -0
- package/dist/store/Lock.d.ts +5 -0
- package/dist/store/Lock.js +24 -0
- package/dist/store/LockService.d.ts +8 -0
- package/dist/store/LockService.js +36 -0
- package/dist/store/Manifest.d.ts +30 -0
- package/dist/store/Manifest.js +58 -0
- package/dist/store/ManifestService.d.ts +10 -0
- package/dist/store/ManifestService.js +91 -0
- package/dist/store/PackageService.d.ts +9 -0
- package/dist/store/PackageService.js +89 -0
- package/dist/store/Store.d.ts +12 -0
- package/dist/store/Store.js +103 -0
- package/dist/store/StoreDiagnosticText.d.ts +13 -0
- package/dist/store/StoreDiagnosticText.js +42 -0
- package/dist/store/TarReader.d.ts +9 -0
- package/dist/store/TarReader.js +56 -0
- package/dist/store/helpers.d.ts +1 -0
- package/dist/store/helpers.js +3 -0
- package/dist/store/index.d.ts +1 -0
- package/dist/store/index.js +1 -0
- package/dist/structure/ComparisonResult.enum.d.ts +5 -0
- package/dist/structure/ComparisonResult.enum.js +6 -0
- package/dist/structure/Structure.d.ts +24 -0
- package/dist/structure/Structure.js +481 -0
- package/dist/structure/index.d.ts +1 -0
- package/dist/structure/index.js +1 -0
- package/dist/suppressed/SuppressedDiagnosticText.d.ts +6 -0
- package/dist/suppressed/SuppressedDiagnosticText.js +18 -0
- package/dist/suppressed/SuppressedService.d.ts +5 -0
- package/dist/suppressed/SuppressedService.js +61 -0
- package/dist/suppressed/index.d.ts +1 -0
- package/dist/suppressed/index.js +1 -0
- package/dist/tag.d.ts +1 -3
- package/dist/tag.js +2 -5
- package/dist/text/TextFile.d.ts +11 -0
- package/dist/text/TextFile.js +41 -0
- package/dist/text/TextFileService.d.ts +10 -0
- package/dist/text/TextFileService.js +31 -0
- package/dist/text/index.d.ts +3 -0
- package/dist/text/index.js +2 -0
- package/dist/text/types.d.ts +5 -0
- package/dist/text/types.js +1 -0
- package/dist/token/CancellationReason.enum.d.ts +6 -0
- package/dist/token/CancellationReason.enum.js +7 -0
- package/dist/token/CancellationToken.d.ts +8 -0
- package/dist/token/CancellationToken.js +22 -0
- package/dist/token/index.d.ts +2 -0
- package/dist/token/index.js +2 -0
- package/dist/typescript/BaseAdapter.d.ts +36 -0
- package/dist/typescript/BaseAdapter.js +83 -0
- package/dist/typescript/CompatTypeScript.d.ts +21 -0
- package/dist/typescript/CompatTypeScript.js +37 -0
- package/dist/typescript/NativeTypeScript.d.ts +24 -0
- package/dist/typescript/NativeTypeScript.js +44 -0
- package/dist/typescript/index.d.ts +3 -0
- package/dist/typescript/index.js +2 -0
- package/dist/typescript/types.d.ts +69 -0
- package/dist/typescript/types.js +1 -0
- package/dist/version/Version.d.ts +6 -0
- package/dist/version/Version.js +30 -0
- package/dist/version/index.d.ts +1 -0
- package/dist/version/index.js +1 -0
- package/dist/watch/Debounce.d.ts +9 -0
- package/dist/watch/Debounce.js +27 -0
- package/dist/watch/FileWatcher.d.ts +5 -0
- package/dist/watch/FileWatcher.js +12 -0
- package/dist/watch/WatchService.d.ts +8 -0
- package/dist/watch/WatchService.js +96 -0
- package/dist/watch/Watcher.d.ts +10 -0
- package/dist/watch/Watcher.js +31 -0
- package/dist/watch/index.d.ts +3 -0
- package/dist/watch/index.js +3 -0
- package/package.json +10 -2
package/dist/cli/Cli.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import { Config, Options } from "#config";
|
|
4
|
+
import { Diagnostic } from "#diagnostic";
|
|
5
|
+
import { environmentOptions } from "#environment";
|
|
6
|
+
import { EventEmitter } from "#events";
|
|
7
|
+
import { CancellationHandler, ExitCodeHandler } from "#handlers";
|
|
8
|
+
import { diagnosticText, formattedText, helpText, OutputService, waitingForFileChangesText } from "#output";
|
|
9
|
+
import { Path } from "#path";
|
|
10
|
+
import { SetupReporter } from "#reporters";
|
|
11
|
+
import { Runner } from "#runner";
|
|
12
|
+
import { Select } from "#select";
|
|
13
|
+
import { Store } from "#store";
|
|
14
|
+
import { CancellationToken } from "#token";
|
|
15
|
+
import { FileWatcher, Watcher } from "#watch";
|
|
16
|
+
import { CliDiagnosticText } from "./CliDIagnosticText.js";
|
|
17
|
+
export class Cli {
|
|
18
|
+
#deferredDiagnostics;
|
|
19
|
+
#eventEmitter = new EventEmitter();
|
|
20
|
+
async run(commandLine, cancellationToken = new CancellationToken()) {
|
|
21
|
+
const exitCodeHandler = new ExitCodeHandler();
|
|
22
|
+
this.#eventEmitter.addHandler(exitCodeHandler);
|
|
23
|
+
await this.#run(commandLine, exitCodeHandler, cancellationToken);
|
|
24
|
+
if (this.#deferredDiagnostics != null) {
|
|
25
|
+
OutputService.writeBlankLine();
|
|
26
|
+
OutputService.writeWarning(diagnosticText(this.#deferredDiagnostics));
|
|
27
|
+
}
|
|
28
|
+
this.#eventEmitter.removeHandlers();
|
|
29
|
+
return exitCodeHandler.getExitCode();
|
|
30
|
+
}
|
|
31
|
+
async #run(commandLine, exitCodeHandler, cancellationToken) {
|
|
32
|
+
const cancellationHandler = new CancellationHandler(cancellationToken, "configError");
|
|
33
|
+
this.#eventEmitter.addHandler(cancellationHandler);
|
|
34
|
+
const setupReporter = new SetupReporter();
|
|
35
|
+
this.#eventEmitter.addReporter(setupReporter);
|
|
36
|
+
if (commandLine.includes("--help")) {
|
|
37
|
+
const options = Options.for(2);
|
|
38
|
+
OutputService.writeMessage(helpText(options, Runner.version));
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (commandLine.includes("--version")) {
|
|
42
|
+
OutputService.writeMessage(formattedText(Runner.version));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (commandLine.includes("--list")) {
|
|
46
|
+
await Store.open();
|
|
47
|
+
if (Store.manifest != null) {
|
|
48
|
+
OutputService.writeMessage(formattedText({ resolutions: Store.manifest.resolutions, versions: Store.manifest.versions }));
|
|
49
|
+
}
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (commandLine.includes("--prune")) {
|
|
53
|
+
await Store.prune();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (commandLine.includes("--update")) {
|
|
57
|
+
await Store.update();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const { commandLineOptions, pathMatch } = await Config.parseCommandLine(commandLine);
|
|
61
|
+
if (cancellationToken.isCancellationRequested()) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (!commandLineOptions.config) {
|
|
65
|
+
const oldConfigFilePath = Path.resolve(Config.resolveRootPath(commandLineOptions.root), "./tstyche.config.json");
|
|
66
|
+
if (existsSync(oldConfigFilePath)) {
|
|
67
|
+
const newConfigFilePath = Path.resolve(Config.resolveConfigFilePath(undefined, commandLineOptions.root));
|
|
68
|
+
await fs.rename(oldConfigFilePath, newConfigFilePath);
|
|
69
|
+
this.#deferredDiagnostics = Diagnostic.warning(CliDiagnosticText.configLocationChanged(oldConfigFilePath, newConfigFilePath));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
do {
|
|
73
|
+
if (cancellationToken.getReason() === "configChange") {
|
|
74
|
+
cancellationToken.reset();
|
|
75
|
+
exitCodeHandler.reset();
|
|
76
|
+
OutputService.clearTerminal();
|
|
77
|
+
this.#eventEmitter.addHandler(cancellationHandler);
|
|
78
|
+
this.#eventEmitter.addReporter(setupReporter);
|
|
79
|
+
}
|
|
80
|
+
const { configFileOptions } = await Config.parseConfigFile(commandLineOptions.config, commandLineOptions.root);
|
|
81
|
+
const resolvedConfig = Config.resolve({ configFileOptions, commandLineOptions, pathMatch });
|
|
82
|
+
if (cancellationToken.isCancellationRequested()) {
|
|
83
|
+
if (commandLine.includes("--watch")) {
|
|
84
|
+
await this.#waitForChangedFiles(resolvedConfig, cancellationToken);
|
|
85
|
+
}
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (commandLine.includes("--showConfig")) {
|
|
89
|
+
OutputService.writeMessage(formattedText({ ...resolvedConfig, ...environmentOptions }));
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (commandLine.includes("--fetch")) {
|
|
93
|
+
for (const tag of resolvedConfig.target) {
|
|
94
|
+
await Store.fetch(tag);
|
|
95
|
+
}
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
let testFiles = [];
|
|
99
|
+
if (resolvedConfig.testFileMatch.length > 0) {
|
|
100
|
+
testFiles = await Select.selectFiles(resolvedConfig);
|
|
101
|
+
if (testFiles.length === 0) {
|
|
102
|
+
if (commandLine.includes("--watch")) {
|
|
103
|
+
await this.#waitForChangedFiles(resolvedConfig, cancellationToken);
|
|
104
|
+
}
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (commandLine.includes("--listFiles")) {
|
|
109
|
+
OutputService.writeMessage(formattedText(testFiles));
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
this.#eventEmitter.removeHandler(cancellationHandler);
|
|
113
|
+
this.#eventEmitter.removeReporter(setupReporter);
|
|
114
|
+
const runner = new Runner(resolvedConfig);
|
|
115
|
+
await runner.run(testFiles, cancellationToken);
|
|
116
|
+
} while (cancellationToken.getReason() === "configChange");
|
|
117
|
+
}
|
|
118
|
+
#waitForChangedFiles(resolvedConfig, cancellationToken) {
|
|
119
|
+
return new Promise((resolve) => {
|
|
120
|
+
const watchers = [];
|
|
121
|
+
cancellationToken.reset();
|
|
122
|
+
OutputService.writeMessage(waitingForFileChangesText());
|
|
123
|
+
const onChanged = () => {
|
|
124
|
+
cancellationToken.cancel("configChange");
|
|
125
|
+
for (const watcher of watchers) {
|
|
126
|
+
watcher.close();
|
|
127
|
+
}
|
|
128
|
+
resolve();
|
|
129
|
+
};
|
|
130
|
+
watchers.push(new FileWatcher(resolvedConfig.configFilePath, onChanged));
|
|
131
|
+
const onChangedTestFile = (filePath) => {
|
|
132
|
+
if (Select.isTestFile(filePath, resolvedConfig)) {
|
|
133
|
+
onChanged();
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const onRemoved = () => {
|
|
137
|
+
};
|
|
138
|
+
watchers.push(new Watcher(resolvedConfig.rootPath, onChangedTestFile, onRemoved, { recursive: true }));
|
|
139
|
+
for (const watcher of watchers) {
|
|
140
|
+
watcher.watch();
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Path } from "#path";
|
|
2
|
+
export class CliDiagnosticText {
|
|
3
|
+
static configLocationChanged(oldConfigFilePath, newConfigFilePath) {
|
|
4
|
+
return [
|
|
5
|
+
"The default configuration file location has changed.",
|
|
6
|
+
`The discovered file has been automatically renamed from '${Path.relative(".", oldConfigFilePath)}' to '${Path.relative(".", newConfigFilePath)}'.`,
|
|
7
|
+
];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Cli } from "./Cli.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Cli } from "./Cli.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ResolvedConfig } from "#config";
|
|
2
|
+
import type { ProjectService } from "#project";
|
|
3
|
+
import type * as ts from "#typescript";
|
|
4
|
+
import { TestTree } from "./TestTree.js";
|
|
5
|
+
export declare class CollectService {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(ts: ts.TypeScript, projectService: ProjectService, resolvedConfig: ResolvedConfig);
|
|
8
|
+
createTestTree(sourceFile: ts.SourceFile, semanticDiagnostics?: ReadonlyArray<ts.Diagnostic>): TestTree;
|
|
9
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { Diagnostic, DiagnosticOrigin } from "#diagnostic";
|
|
2
|
+
import { EventEmitter } from "#events";
|
|
3
|
+
import { Layers } from "#layers";
|
|
4
|
+
import { TextFileService } from "#text";
|
|
5
|
+
import { CollectDiagnosticText } from "./CollectDiagnosticText.js";
|
|
6
|
+
import { ExpectNode } from "./ExpectNode.js";
|
|
7
|
+
import { IdentifierLookup } from "./IdentifierLookup.js";
|
|
8
|
+
import { TestTree } from "./TestTree.js";
|
|
9
|
+
import { TestTreeNode } from "./TestTreeNode.js";
|
|
10
|
+
export class CollectService {
|
|
11
|
+
#layers;
|
|
12
|
+
#identifierLookup;
|
|
13
|
+
#projectService;
|
|
14
|
+
#ts;
|
|
15
|
+
constructor(ts, projectService, resolvedConfig) {
|
|
16
|
+
this.#ts = ts;
|
|
17
|
+
this.#projectService = projectService;
|
|
18
|
+
this.#layers = new Layers(ts, projectService, resolvedConfig);
|
|
19
|
+
this.#identifierLookup = new IdentifierLookup(ts);
|
|
20
|
+
}
|
|
21
|
+
#collectTestTreeNodes(node, parent, testTree) {
|
|
22
|
+
if (this.#ts.isCallExpression(node)) {
|
|
23
|
+
const meta = this.#identifierLookup.resolveTestTreeNodeMeta(node);
|
|
24
|
+
if (meta != null) {
|
|
25
|
+
if (!this.#checkNode(node, meta, parent)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (meta.brand === "describe" ||
|
|
29
|
+
meta.brand === "it" ||
|
|
30
|
+
meta.brand === "test") {
|
|
31
|
+
const testTreeNode = new TestTreeNode(this.#ts, meta.brand, node, parent, meta.flags);
|
|
32
|
+
node.forEachChild((node) => {
|
|
33
|
+
this.#collectTestTreeNodes(node, testTreeNode, testTree);
|
|
34
|
+
});
|
|
35
|
+
this.#onNode(testTreeNode, parent, testTree);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (meta.brand === "expect") {
|
|
39
|
+
const modifierNode = this.#getChainedNode(node, "type");
|
|
40
|
+
if (!modifierNode) {
|
|
41
|
+
const text = "'expect()' must be followed by the '.type' modifier.";
|
|
42
|
+
const origin = DiagnosticOrigin.fromNode(node);
|
|
43
|
+
this.#onDiagnostics(Diagnostic.error(text, origin));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const notNode = this.#getChainedNode(modifierNode, "not");
|
|
47
|
+
const matcherNameNode = this.#getChainedNode(notNode ?? modifierNode);
|
|
48
|
+
if (!matcherNameNode) {
|
|
49
|
+
const text = "The final element in the chain must be a matcher.";
|
|
50
|
+
const origin = DiagnosticOrigin.fromNode(notNode ?? modifierNode);
|
|
51
|
+
this.#onDiagnostics(Diagnostic.error(text, origin));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const matcherNode = this.#getMatcherNode(matcherNameNode);
|
|
55
|
+
if (!matcherNode) {
|
|
56
|
+
const text = "The matcher must be completed with '()'.";
|
|
57
|
+
const origin = new DiagnosticOrigin(matcherNameNode.name.getStart(), this.#ts.isExpressionWithTypeArguments(matcherNameNode.parent)
|
|
58
|
+
? matcherNameNode.parent.getEnd()
|
|
59
|
+
: matcherNameNode.getEnd(), TextFileService.get(matcherNameNode.getSourceFile()));
|
|
60
|
+
this.#onDiagnostics(Diagnostic.error(text, origin));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const expectNode = new ExpectNode(this.#ts, meta.brand, node, parent, meta.flags, matcherNode, matcherNameNode, modifierNode, notNode);
|
|
64
|
+
this.#layers.visit(expectNode);
|
|
65
|
+
node.forEachChild((node) => {
|
|
66
|
+
this.#collectTestTreeNodes(node, expectNode, testTree);
|
|
67
|
+
});
|
|
68
|
+
this.#onNode(expectNode, parent, testTree);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (this.#ts.isImportDeclaration(node)) {
|
|
74
|
+
this.#identifierLookup.handleImportDeclaration(node);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
node.forEachChild((node) => {
|
|
78
|
+
this.#collectTestTreeNodes(node, parent, testTree);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
createTestTree(sourceFile, semanticDiagnostics = []) {
|
|
82
|
+
const testTree = new TestTree(this.#projectService, sourceFile, new Set(semanticDiagnostics));
|
|
83
|
+
EventEmitter.dispatch(["collect:start", { tree: testTree }]);
|
|
84
|
+
this.#layers.open(testTree);
|
|
85
|
+
this.#identifierLookup.open();
|
|
86
|
+
this.#collectTestTreeNodes(sourceFile, testTree, testTree);
|
|
87
|
+
this.#layers.close(testTree);
|
|
88
|
+
EventEmitter.dispatch(["collect:end", { tree: testTree }]);
|
|
89
|
+
return testTree;
|
|
90
|
+
}
|
|
91
|
+
#checkNode(node, meta, parent) {
|
|
92
|
+
if ("brand" in parent && !this.#isNodeAllowed(meta, parent)) {
|
|
93
|
+
const text = CollectDiagnosticText.cannotBeNestedWithin(meta.brand, parent.brand);
|
|
94
|
+
const origin = DiagnosticOrigin.fromNode(node);
|
|
95
|
+
this.#onDiagnostics(Diagnostic.error(text, origin));
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
#isNodeAllowed(meta, parent) {
|
|
101
|
+
switch (meta.brand) {
|
|
102
|
+
case "describe":
|
|
103
|
+
case "it":
|
|
104
|
+
case "test":
|
|
105
|
+
if (parent.brand === "it" ||
|
|
106
|
+
parent.brand === "test" ||
|
|
107
|
+
parent.brand === "expect") {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
case "expect":
|
|
112
|
+
if (parent.brand === "describe") {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
#getChainedNode({ parent }, name) {
|
|
120
|
+
if (!this.#ts.isPropertyAccessExpression(parent)) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (name != null && name !== parent.name.getText()) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
return parent;
|
|
127
|
+
}
|
|
128
|
+
#getMatcherNode(node) {
|
|
129
|
+
if (this.#ts.isCallExpression(node.parent)) {
|
|
130
|
+
return node.parent;
|
|
131
|
+
}
|
|
132
|
+
if (this.#ts.isDecorator(node.parent)) {
|
|
133
|
+
return node.parent;
|
|
134
|
+
}
|
|
135
|
+
if (this.#ts.isParenthesizedExpression(node.parent)) {
|
|
136
|
+
return this.#getMatcherNode(node.parent);
|
|
137
|
+
}
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
#onDiagnostics(diagnostic) {
|
|
141
|
+
EventEmitter.dispatch(["collect:error", { diagnostics: [diagnostic] }]);
|
|
142
|
+
}
|
|
143
|
+
#onNode(node, parent, testTree) {
|
|
144
|
+
parent.children.push(node);
|
|
145
|
+
if (node.flags & 1) {
|
|
146
|
+
testTree.hasOnly = true;
|
|
147
|
+
}
|
|
148
|
+
EventEmitter.dispatch(["collect:node", { node }]);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type * as ts from "#typescript";
|
|
2
|
+
import type { TestTree } from "./TestTree.js";
|
|
3
|
+
import { TestTreeNode } from "./TestTreeNode.js";
|
|
4
|
+
import type { TestTreeNodeBrand } from "./TestTreeNodeBrand.enum.js";
|
|
5
|
+
import type { TestTreeNodeFlags } from "./TestTreeNodeFlags.enum.js";
|
|
6
|
+
export declare class ExpectNode extends TestTreeNode {
|
|
7
|
+
abilityDiagnostics: Set<ts.Diagnostic>;
|
|
8
|
+
isNot: boolean;
|
|
9
|
+
matcherNode: ts.CallExpression | ts.Decorator;
|
|
10
|
+
matcherNameNode: ts.PropertyAccessExpression;
|
|
11
|
+
modifierNode: ts.PropertyAccessExpression;
|
|
12
|
+
notNode: ts.PropertyAccessExpression | undefined;
|
|
13
|
+
source: ts.NodeArray<ts.Expression> | ts.NodeArray<ts.TypeNode>;
|
|
14
|
+
target: ts.NodeArray<ts.Expression> | ts.NodeArray<ts.TypeNode> | undefined;
|
|
15
|
+
constructor(ts: ts.TypeScript, brand: TestTreeNodeBrand, node: ts.CallExpression, parent: TestTree | TestTreeNode, flags: TestTreeNodeFlags, matcherNode: ts.CallExpression | ts.Decorator, matcherNameNode: ts.PropertyAccessExpression, modifierNode: ts.PropertyAccessExpression, notNode: ts.PropertyAccessExpression | undefined);
|
|
16
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { diagnosticBelongsToNode } from "#diagnostic";
|
|
2
|
+
import { TestTreeNode } from "./TestTreeNode.js";
|
|
3
|
+
export class ExpectNode extends TestTreeNode {
|
|
4
|
+
abilityDiagnostics = new Set();
|
|
5
|
+
isNot;
|
|
6
|
+
matcherNode;
|
|
7
|
+
matcherNameNode;
|
|
8
|
+
modifierNode;
|
|
9
|
+
notNode;
|
|
10
|
+
source;
|
|
11
|
+
target;
|
|
12
|
+
constructor(ts, brand, node, parent, flags, matcherNode, matcherNameNode, modifierNode, notNode) {
|
|
13
|
+
super(ts, brand, node, parent, flags);
|
|
14
|
+
this.isNot = notNode != null;
|
|
15
|
+
this.matcherNode = matcherNode;
|
|
16
|
+
this.matcherNameNode = matcherNameNode;
|
|
17
|
+
this.modifierNode = modifierNode;
|
|
18
|
+
this.source = this.node.typeArguments ?? this.node.arguments;
|
|
19
|
+
if (ts.isCallExpression(this.matcherNode)) {
|
|
20
|
+
this.target = this.matcherNode.typeArguments ?? this.matcherNode.arguments;
|
|
21
|
+
}
|
|
22
|
+
for (const diagnostic of parent.diagnostics) {
|
|
23
|
+
if (diagnosticBelongsToNode(diagnostic, this.source) ||
|
|
24
|
+
(this.target != null && diagnosticBelongsToNode(diagnostic, this.target))) {
|
|
25
|
+
this.diagnostics.add(diagnostic);
|
|
26
|
+
parent.diagnostics.delete(diagnostic);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type * as ts from "#typescript";
|
|
2
|
+
import { TestTreeNodeBrand } from "./TestTreeNodeBrand.enum.js";
|
|
3
|
+
import { TestTreeNodeFlags } from "./TestTreeNodeFlags.enum.js";
|
|
4
|
+
export interface Identifiers {
|
|
5
|
+
namedImports: Record<string, string | undefined>;
|
|
6
|
+
namespace: string | undefined;
|
|
7
|
+
}
|
|
8
|
+
export interface TestTreeNodeMeta {
|
|
9
|
+
brand: TestTreeNodeBrand;
|
|
10
|
+
flags: TestTreeNodeFlags;
|
|
11
|
+
}
|
|
12
|
+
export declare class IdentifierLookup {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(ts: ts.TypeScript);
|
|
15
|
+
handleImportDeclaration(node: ts.ImportDeclaration): void;
|
|
16
|
+
open(): void;
|
|
17
|
+
resolveTestTreeNodeMeta(node: ts.CallExpression): TestTreeNodeMeta | undefined;
|
|
18
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export class IdentifierLookup {
|
|
2
|
+
#ts;
|
|
3
|
+
#identifiers;
|
|
4
|
+
#moduleSpecifiers = ['"tstyche"', "'tstyche'"];
|
|
5
|
+
constructor(ts) {
|
|
6
|
+
this.#ts = ts;
|
|
7
|
+
}
|
|
8
|
+
handleImportDeclaration(node) {
|
|
9
|
+
if (this.#moduleSpecifiers.includes(node.moduleSpecifier.getText()) &&
|
|
10
|
+
!this.#ts.isTypeOnlyImportDeclaration(node) &&
|
|
11
|
+
node.importClause?.namedBindings != null) {
|
|
12
|
+
if (this.#ts.isNamedImports(node.importClause.namedBindings)) {
|
|
13
|
+
for (const element of node.importClause.namedBindings.elements) {
|
|
14
|
+
if (element.isTypeOnly) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
let identifierKey;
|
|
18
|
+
if (element.propertyName) {
|
|
19
|
+
identifierKey = element.propertyName.getText();
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
identifierKey = element.name.getText();
|
|
23
|
+
}
|
|
24
|
+
if (identifierKey in this.#identifiers.namedImports) {
|
|
25
|
+
this.#identifiers.namedImports[identifierKey] = element.name.getText();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (this.#ts.isNamespaceImport(node.importClause.namedBindings)) {
|
|
30
|
+
this.#identifiers.namespace = node.importClause.namedBindings.name.getText();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
open() {
|
|
35
|
+
this.#identifiers = {
|
|
36
|
+
namedImports: {
|
|
37
|
+
describe: undefined,
|
|
38
|
+
expect: undefined,
|
|
39
|
+
it: undefined,
|
|
40
|
+
namespace: undefined,
|
|
41
|
+
test: undefined,
|
|
42
|
+
when: undefined,
|
|
43
|
+
},
|
|
44
|
+
namespace: undefined,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
resolveTestTreeNodeMeta(node) {
|
|
48
|
+
let flags = 0;
|
|
49
|
+
let expression = node.expression;
|
|
50
|
+
while (this.#ts.isPropertyAccessExpression(expression)) {
|
|
51
|
+
if (expression.expression.getText() === this.#identifiers.namespace) {
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
switch (expression.name.getText()) {
|
|
55
|
+
case "only":
|
|
56
|
+
flags |= 1;
|
|
57
|
+
break;
|
|
58
|
+
case "skip":
|
|
59
|
+
flags |= 2;
|
|
60
|
+
break;
|
|
61
|
+
case "todo":
|
|
62
|
+
flags |= 4;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
expression = expression.expression;
|
|
66
|
+
}
|
|
67
|
+
let identifier;
|
|
68
|
+
if (this.#ts.isPropertyAccessExpression(expression) &&
|
|
69
|
+
expression.expression.getText() === this.#identifiers.namespace) {
|
|
70
|
+
identifier = expression.name.getText();
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
identifier = Object.keys(this.#identifiers.namedImports).find((key) => this.#identifiers.namedImports[key] === expression.getText());
|
|
74
|
+
}
|
|
75
|
+
if (!identifier) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
switch (identifier) {
|
|
79
|
+
case "describe":
|
|
80
|
+
return { brand: "describe", flags };
|
|
81
|
+
case "it":
|
|
82
|
+
return { brand: "it", flags };
|
|
83
|
+
case "test":
|
|
84
|
+
return { brand: "test", flags };
|
|
85
|
+
case "expect":
|
|
86
|
+
return { brand: "expect", flags };
|
|
87
|
+
}
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Checker } from "#checker";
|
|
2
|
+
import type { SuppressedError } from "#layers";
|
|
3
|
+
import type { ProjectService } from "#project";
|
|
4
|
+
import type * as ts from "#typescript";
|
|
5
|
+
import type { ExpectNode } from "./ExpectNode.js";
|
|
6
|
+
import type { TestTreeNode } from "./TestTreeNode.js";
|
|
7
|
+
export declare class TestTree {
|
|
8
|
+
children: Array<TestTreeNode | ExpectNode>;
|
|
9
|
+
diagnostics: Set<ts.Diagnostic>;
|
|
10
|
+
hasOnly: boolean;
|
|
11
|
+
program: ts.Program;
|
|
12
|
+
checker: Checker;
|
|
13
|
+
sourceFile: ts.SourceFile;
|
|
14
|
+
suppressedErrors: Array<SuppressedError> | undefined;
|
|
15
|
+
constructor(projectService: ProjectService, sourceFile: ts.SourceFile, diagnostics: Set<ts.Diagnostic>);
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class TestTree {
|
|
2
|
+
children = [];
|
|
3
|
+
diagnostics;
|
|
4
|
+
hasOnly = false;
|
|
5
|
+
program;
|
|
6
|
+
checker;
|
|
7
|
+
sourceFile;
|
|
8
|
+
suppressedErrors;
|
|
9
|
+
constructor(projectService, sourceFile, diagnostics) {
|
|
10
|
+
this.sourceFile = sourceFile;
|
|
11
|
+
this.diagnostics = diagnostics;
|
|
12
|
+
this.checker = projectService.getChecker();
|
|
13
|
+
this.program = projectService.getProgram();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type * as ts from "#typescript";
|
|
2
|
+
import type { ExpectNode } from "./ExpectNode.js";
|
|
3
|
+
import type { TestTree } from "./TestTree.js";
|
|
4
|
+
import type { TestTreeNodeBrand } from "./TestTreeNodeBrand.enum.js";
|
|
5
|
+
import type { TestTreeNodeFlags } from "./TestTreeNodeFlags.enum.js";
|
|
6
|
+
export declare class TestTreeNode {
|
|
7
|
+
brand: TestTreeNodeBrand;
|
|
8
|
+
children: Array<TestTreeNode | ExpectNode>;
|
|
9
|
+
diagnostics: Set<ts.Diagnostic>;
|
|
10
|
+
flags: TestTreeNodeFlags;
|
|
11
|
+
name: string;
|
|
12
|
+
node: ts.CallExpression;
|
|
13
|
+
parent: TestTree | TestTreeNode;
|
|
14
|
+
constructor(ts: ts.TypeScript, brand: TestTreeNodeBrand, node: ts.CallExpression, parent: TestTree | TestTreeNode, flags: TestTreeNodeFlags);
|
|
15
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { diagnosticBelongsToNode } from "#diagnostic";
|
|
2
|
+
export class TestTreeNode {
|
|
3
|
+
brand;
|
|
4
|
+
children = [];
|
|
5
|
+
diagnostics = new Set();
|
|
6
|
+
flags;
|
|
7
|
+
name = "";
|
|
8
|
+
node;
|
|
9
|
+
parent;
|
|
10
|
+
constructor(ts, brand, node, parent, flags) {
|
|
11
|
+
this.brand = brand;
|
|
12
|
+
this.node = node;
|
|
13
|
+
this.parent = parent;
|
|
14
|
+
this.flags = flags;
|
|
15
|
+
if (node.arguments[0] != null && ts.isStringLiteralLikeNode(node.arguments[0])) {
|
|
16
|
+
this.name = node.arguments[0].text;
|
|
17
|
+
}
|
|
18
|
+
if (node.arguments[1] != null && ts.isCallbackFunction(node.arguments[1])) {
|
|
19
|
+
for (const diagnostic of parent.diagnostics) {
|
|
20
|
+
if (node.arguments[1].body != null && diagnosticBelongsToNode(diagnostic, node.arguments[1].body)) {
|
|
21
|
+
this.diagnostics.add(diagnostic);
|
|
22
|
+
parent.diagnostics.delete(diagnostic);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var TestTreeNodeBrand;
|
|
2
|
+
(function (TestTreeNodeBrand) {
|
|
3
|
+
TestTreeNodeBrand["Describe"] = "describe";
|
|
4
|
+
TestTreeNodeBrand["Test"] = "test";
|
|
5
|
+
TestTreeNodeBrand["It"] = "it";
|
|
6
|
+
TestTreeNodeBrand["Expect"] = "expect";
|
|
7
|
+
})(TestTreeNodeBrand || (TestTreeNodeBrand = {}));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var TestTreeNodeFlags;
|
|
2
|
+
(function (TestTreeNodeFlags) {
|
|
3
|
+
TestTreeNodeFlags[TestTreeNodeFlags["None"] = 0] = "None";
|
|
4
|
+
TestTreeNodeFlags[TestTreeNodeFlags["Only"] = 1] = "Only";
|
|
5
|
+
TestTreeNodeFlags[TestTreeNodeFlags["Skip"] = 2] = "Skip";
|
|
6
|
+
TestTreeNodeFlags[TestTreeNodeFlags["Todo"] = 4] = "Todo";
|
|
7
|
+
})(TestTreeNodeFlags || (TestTreeNodeFlags = {}));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { CollectService } from "./CollectService.js";
|
|
2
|
+
export { ExpectNode } from "./ExpectNode.js";
|
|
3
|
+
export { TestTree } from "./TestTree.js";
|
|
4
|
+
export { TestTreeNode } from "./TestTreeNode.js";
|
|
5
|
+
export { TestTreeNodeBrand } from "./TestTreeNodeBrand.enum.js";
|
|
6
|
+
export { TestTreeNodeFlags } from "./TestTreeNodeFlags.enum.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { CollectService } from "./CollectService.js";
|
|
2
|
+
export { ExpectNode } from "./ExpectNode.js";
|
|
3
|
+
export { TestTree } from "./TestTree.js";
|
|
4
|
+
export { TestTreeNode } from "./TestTreeNode.js";
|
|
5
|
+
export { TestTreeNodeBrand } from "./TestTreeNodeBrand.enum.js";
|
|
6
|
+
export { TestTreeNodeFlags } from "./TestTreeNodeFlags.enum.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type DiagnosticsHandler } from "#diagnostic";
|
|
2
|
+
import type { OptionValue } from "./types.js";
|
|
3
|
+
export declare class CommandParser {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(commandLine: Record<string, OptionValue>, pathMatch: Array<string>, onDiagnostics: DiagnosticsHandler);
|
|
6
|
+
parse(commandLineArgs: ReadonlyArray<string>): Promise<void>;
|
|
7
|
+
}
|