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
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var RunModeFlags;
|
|
2
|
+
(function (RunModeFlags) {
|
|
3
|
+
RunModeFlags[RunModeFlags["None"] = 0] = "None";
|
|
4
|
+
RunModeFlags[RunModeFlags["Only"] = 1] = "Only";
|
|
5
|
+
RunModeFlags[RunModeFlags["Skip"] = 2] = "Skip";
|
|
6
|
+
RunModeFlags[RunModeFlags["Todo"] = 4] = "Todo";
|
|
7
|
+
RunModeFlags[RunModeFlags["Void"] = 8] = "Void";
|
|
8
|
+
})(RunModeFlags || (RunModeFlags = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ResolvedConfig } from "#config";
|
|
2
|
+
import { FilePosition } from "#file";
|
|
3
|
+
import { CancellationToken } from "#token";
|
|
4
|
+
export declare class Runner {
|
|
5
|
+
#private;
|
|
6
|
+
static version: string;
|
|
7
|
+
constructor(resolvedConfig: ResolvedConfig);
|
|
8
|
+
run(files: Array<string | URL | FilePosition>, cancellationToken?: CancellationToken): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { environmentOptions } from "#environment";
|
|
2
|
+
import { EventEmitter } from "#events";
|
|
3
|
+
import { FilePosition } from "#file";
|
|
4
|
+
import { CancellationHandler, ResultHandler } from "#handlers";
|
|
5
|
+
import { OutputService, prologueText } from "#output";
|
|
6
|
+
import { DotReporter, ListReporter, SummaryReporter, WatchReporter } from "#reporters";
|
|
7
|
+
import { Result, TargetResult } from "#result";
|
|
8
|
+
import { Store } from "#store";
|
|
9
|
+
import { CancellationToken } from "#token";
|
|
10
|
+
import { WatchService } from "#watch";
|
|
11
|
+
import { FileRunner } from "./FileRunner.js";
|
|
12
|
+
export class Runner {
|
|
13
|
+
#eventEmitter = new EventEmitter();
|
|
14
|
+
#resolvedConfig;
|
|
15
|
+
static version = "8.0.0-beta.1";
|
|
16
|
+
constructor(resolvedConfig) {
|
|
17
|
+
this.#resolvedConfig = resolvedConfig;
|
|
18
|
+
}
|
|
19
|
+
#addHandlers(cancellationToken) {
|
|
20
|
+
const resultHandler = new ResultHandler();
|
|
21
|
+
this.#eventEmitter.addHandler(resultHandler);
|
|
22
|
+
if (this.#resolvedConfig.failFast) {
|
|
23
|
+
const cancellationHandler = new CancellationHandler(cancellationToken, "failFast");
|
|
24
|
+
this.#eventEmitter.addHandler(cancellationHandler);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async #addReporters() {
|
|
28
|
+
if (this.#resolvedConfig.watch && !environmentOptions.noInteractive) {
|
|
29
|
+
const watchReporter = new WatchReporter(this.#resolvedConfig);
|
|
30
|
+
this.#eventEmitter.addReporter(watchReporter);
|
|
31
|
+
}
|
|
32
|
+
for (const reporter of this.#resolvedConfig.reporters) {
|
|
33
|
+
switch (reporter) {
|
|
34
|
+
case "dot": {
|
|
35
|
+
this.#eventEmitter.addReporter(new DotReporter(this.#resolvedConfig));
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
case "list": {
|
|
39
|
+
this.#eventEmitter.addReporter(new ListReporter(this.#resolvedConfig));
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
case "summary": {
|
|
43
|
+
this.#eventEmitter.addReporter(new SummaryReporter(this.#resolvedConfig));
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
default: {
|
|
47
|
+
const CustomReporter = (await import(reporter)).default;
|
|
48
|
+
const customReporter = new CustomReporter(this.#resolvedConfig);
|
|
49
|
+
this.#eventEmitter.addReporter(customReporter);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async run(files, cancellationToken = new CancellationToken()) {
|
|
55
|
+
if (this.#resolvedConfig.quiet) {
|
|
56
|
+
OutputService.outputStream.disable();
|
|
57
|
+
}
|
|
58
|
+
if (!this.#resolvedConfig.watch) {
|
|
59
|
+
OutputService.writeMessage(prologueText(Runner.version, this.#resolvedConfig.rootPath));
|
|
60
|
+
}
|
|
61
|
+
const filePositions = files.map((file) => (file instanceof FilePosition ? file : new FilePosition(file)));
|
|
62
|
+
this.#addHandlers(cancellationToken);
|
|
63
|
+
await this.#addReporters();
|
|
64
|
+
await this.#run(filePositions, cancellationToken);
|
|
65
|
+
if (this.#resolvedConfig.watch) {
|
|
66
|
+
await this.#watch(filePositions, cancellationToken);
|
|
67
|
+
}
|
|
68
|
+
this.#eventEmitter.removeReporters();
|
|
69
|
+
this.#eventEmitter.removeHandlers();
|
|
70
|
+
if (this.#resolvedConfig.quiet) {
|
|
71
|
+
OutputService.outputStream.enable();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async #run(files, cancellationToken) {
|
|
75
|
+
const result = new Result(files);
|
|
76
|
+
EventEmitter.dispatch(["run:start", { result }]);
|
|
77
|
+
for (const target of this.#resolvedConfig.target) {
|
|
78
|
+
const targetResult = new TargetResult(target, files);
|
|
79
|
+
EventEmitter.dispatch(["target:start", { result: targetResult }]);
|
|
80
|
+
const ts = await Store.load(target);
|
|
81
|
+
if (ts != null) {
|
|
82
|
+
const fileRunner = new FileRunner(ts, this.#resolvedConfig);
|
|
83
|
+
for (const file of files) {
|
|
84
|
+
await fileRunner.run(file, cancellationToken);
|
|
85
|
+
}
|
|
86
|
+
fileRunner.close();
|
|
87
|
+
}
|
|
88
|
+
EventEmitter.dispatch(["target:end", { result: targetResult }]);
|
|
89
|
+
}
|
|
90
|
+
EventEmitter.dispatch(["run:end", { result }]);
|
|
91
|
+
if (cancellationToken.getReason() === "failFast") {
|
|
92
|
+
cancellationToken.reset();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async #watch(files, cancellationToken) {
|
|
96
|
+
const watchService = new WatchService(this.#resolvedConfig, files);
|
|
97
|
+
for await (const testFiles of watchService.watch(cancellationToken)) {
|
|
98
|
+
await this.#run(testFiles, cancellationToken);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Checker } from "#checker";
|
|
2
|
+
import { type ExpectNode, type TestTreeNode } from "#collect";
|
|
3
|
+
import { type ResolvedConfig } from "#config";
|
|
4
|
+
import { Diagnostic, type DiagnosticsHandler } from "#diagnostic";
|
|
5
|
+
import { DescribeResult, TestResult } from "#result";
|
|
6
|
+
import type { CancellationToken } from "#token";
|
|
7
|
+
import type * as ts from "#typescript";
|
|
8
|
+
import { RunModeFlags } from "./RunModeFlags.enum.js";
|
|
9
|
+
interface TestTreeWalkerOptions {
|
|
10
|
+
cancellationToken: CancellationToken | undefined;
|
|
11
|
+
hasOnly: boolean;
|
|
12
|
+
position: number | undefined;
|
|
13
|
+
}
|
|
14
|
+
export declare class TestTreeWalker {
|
|
15
|
+
#private;
|
|
16
|
+
constructor(ts: ts.TypeScript, program: ts.Program, checker: Checker, resolvedConfig: ResolvedConfig, onFileDiagnostics: DiagnosticsHandler<Array<Diagnostic>>, options: TestTreeWalkerOptions);
|
|
17
|
+
visit(nodes: Array<TestTreeNode | ExpectNode>, runModeFlags: RunModeFlags, parentResult: DescribeResult | TestResult | undefined): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { Directive } from "#config";
|
|
2
|
+
import { Diagnostic } from "#diagnostic";
|
|
3
|
+
import { EventEmitter } from "#events";
|
|
4
|
+
import { ExpectService } from "#expect";
|
|
5
|
+
import { DescribeResult, ExpectResult, TestResult } from "#result";
|
|
6
|
+
import { Version } from "#version";
|
|
7
|
+
import { FixmeService } from "./FixmeService.js";
|
|
8
|
+
export class TestTreeWalker {
|
|
9
|
+
#cancellationToken;
|
|
10
|
+
#expectService;
|
|
11
|
+
#hasOnly;
|
|
12
|
+
#onFileDiagnostics;
|
|
13
|
+
#position;
|
|
14
|
+
#resolvedConfig;
|
|
15
|
+
#ts;
|
|
16
|
+
constructor(ts, program, checker, resolvedConfig, onFileDiagnostics, options) {
|
|
17
|
+
this.#ts = ts;
|
|
18
|
+
this.#resolvedConfig = resolvedConfig;
|
|
19
|
+
this.#onFileDiagnostics = onFileDiagnostics;
|
|
20
|
+
this.#cancellationToken = options.cancellationToken;
|
|
21
|
+
this.#hasOnly = options.hasOnly || resolvedConfig.only != null || options.position != null;
|
|
22
|
+
this.#position = options.position;
|
|
23
|
+
this.#expectService = new ExpectService(ts, program, checker, resolvedConfig);
|
|
24
|
+
}
|
|
25
|
+
async #resolveRunMode(flags, node) {
|
|
26
|
+
const ifDirective = Directive.getDirectiveRange(this.#ts, node, "if");
|
|
27
|
+
const inlineConfig = await Directive.getInlineConfig(ifDirective);
|
|
28
|
+
if (inlineConfig?.if?.target != null && !Version.isIncluded(this.#ts.version, inlineConfig.if.target)) {
|
|
29
|
+
flags |= 8;
|
|
30
|
+
}
|
|
31
|
+
if (node.flags & 1 ||
|
|
32
|
+
(this.#resolvedConfig.only != null && node.name.toLowerCase().includes(this.#resolvedConfig.only.toLowerCase()))) {
|
|
33
|
+
flags |= 1;
|
|
34
|
+
}
|
|
35
|
+
if (node.flags & 2 ||
|
|
36
|
+
(this.#resolvedConfig.skip != null && node.name.toLowerCase().includes(this.#resolvedConfig.skip.toLowerCase()))) {
|
|
37
|
+
flags |= 2;
|
|
38
|
+
}
|
|
39
|
+
if (node.flags & 4) {
|
|
40
|
+
flags |= 4;
|
|
41
|
+
}
|
|
42
|
+
if (this.#position != null && node.node.getStart() === this.#position) {
|
|
43
|
+
flags |= 1;
|
|
44
|
+
flags &= ~2;
|
|
45
|
+
}
|
|
46
|
+
return flags;
|
|
47
|
+
}
|
|
48
|
+
async visit(nodes, runModeFlags, parentResult) {
|
|
49
|
+
for (const node of nodes) {
|
|
50
|
+
if (this.#cancellationToken?.isCancellationRequested()) {
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
const fixmeDirective = Directive.getDirectiveRange(this.#ts, node, "fixme");
|
|
54
|
+
if (fixmeDirective) {
|
|
55
|
+
await FixmeService.start(fixmeDirective, node);
|
|
56
|
+
}
|
|
57
|
+
switch (node.brand) {
|
|
58
|
+
case "describe":
|
|
59
|
+
await this.#visitDescribe(node, runModeFlags, parentResult);
|
|
60
|
+
break;
|
|
61
|
+
case "it":
|
|
62
|
+
case "test":
|
|
63
|
+
await this.#visitTest(node, runModeFlags, parentResult);
|
|
64
|
+
break;
|
|
65
|
+
case "expect":
|
|
66
|
+
await this.#visitExpect(node, runModeFlags, parentResult);
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
if (fixmeDirective) {
|
|
70
|
+
FixmeService.end(fixmeDirective, node, this.#onFileDiagnostics);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async #visitExpect(expect, runModeFlags, parentResult) {
|
|
75
|
+
await this.visit(expect.children, runModeFlags, parentResult);
|
|
76
|
+
runModeFlags = await this.#resolveRunMode(runModeFlags, expect);
|
|
77
|
+
if (runModeFlags & 8) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const expectResult = new ExpectResult(expect, parentResult);
|
|
81
|
+
EventEmitter.dispatch(["expect:start", { result: expectResult }]);
|
|
82
|
+
if (runModeFlags & 2 || (this.#hasOnly && !(runModeFlags & 1))) {
|
|
83
|
+
EventEmitter.dispatch(["expect:skip", { result: expectResult }]);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const onExpectDiagnostics = (diagnostics) => {
|
|
87
|
+
EventEmitter.dispatch([
|
|
88
|
+
"expect:error",
|
|
89
|
+
{ diagnostics: Array.isArray(diagnostics) ? diagnostics : [diagnostics], result: expectResult },
|
|
90
|
+
]);
|
|
91
|
+
};
|
|
92
|
+
if (expect.diagnostics.size > 0 && expect.matcherNameNode.name.text !== "toRaiseError") {
|
|
93
|
+
onExpectDiagnostics(Diagnostic.fromDiagnostics([...expect.diagnostics]));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const matchResult = this.#expectService.match(expect, onExpectDiagnostics);
|
|
97
|
+
if (!matchResult) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const isPass = expect.isNot ? !matchResult.isMatch : matchResult.isMatch;
|
|
101
|
+
if (FixmeService.isFixme(expect, isPass)) {
|
|
102
|
+
EventEmitter.dispatch(["expect:fixme", { result: expectResult }]);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (isPass) {
|
|
106
|
+
EventEmitter.dispatch(["expect:pass", { result: expectResult }]);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
EventEmitter.dispatch(["expect:fail", { diagnostics: matchResult.explain(), result: expectResult }]);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async #visitDescribe(describe, runModeFlags, parentResult) {
|
|
113
|
+
runModeFlags = await this.#resolveRunMode(runModeFlags, describe);
|
|
114
|
+
if (runModeFlags & 8) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const describeResult = new DescribeResult(describe, parentResult);
|
|
118
|
+
EventEmitter.dispatch(["describe:start", { result: describeResult }]);
|
|
119
|
+
if (!(runModeFlags & 2 ||
|
|
120
|
+
(this.#hasOnly && !(runModeFlags & 1)) ||
|
|
121
|
+
runModeFlags & 4) &&
|
|
122
|
+
describe.diagnostics.size > 0) {
|
|
123
|
+
this.#onFileDiagnostics(Diagnostic.fromDiagnostics([...describe.diagnostics]));
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
await this.visit(describe.children, runModeFlags, describeResult);
|
|
127
|
+
}
|
|
128
|
+
EventEmitter.dispatch(["describe:end", { result: describeResult }]);
|
|
129
|
+
}
|
|
130
|
+
async #visitTest(test, runModeFlags, parentResult) {
|
|
131
|
+
runModeFlags = await this.#resolveRunMode(runModeFlags, test);
|
|
132
|
+
if (runModeFlags & 8) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const testResult = new TestResult(test, parentResult);
|
|
136
|
+
EventEmitter.dispatch(["test:start", { result: testResult }]);
|
|
137
|
+
if (runModeFlags & 4) {
|
|
138
|
+
EventEmitter.dispatch(["test:todo", { result: testResult }]);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (!(runModeFlags & 2 || (this.#hasOnly && !(runModeFlags & 1))) &&
|
|
142
|
+
test.diagnostics.size > 0) {
|
|
143
|
+
EventEmitter.dispatch([
|
|
144
|
+
"test:error",
|
|
145
|
+
{
|
|
146
|
+
diagnostics: Diagnostic.fromDiagnostics([...test.diagnostics]),
|
|
147
|
+
result: testResult,
|
|
148
|
+
},
|
|
149
|
+
]);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
await this.visit(test.children, runModeFlags, testResult);
|
|
153
|
+
if (runModeFlags & 2 || (this.#hasOnly && !(runModeFlags & 1))) {
|
|
154
|
+
EventEmitter.dispatch(["test:skip", { result: testResult }]);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const isPass = testResult.assertionCounts.failed === 0;
|
|
158
|
+
if (FixmeService.isFixme(test, isPass)) {
|
|
159
|
+
EventEmitter.dispatch(["test:fixme", { result: testResult }]);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (isPass) {
|
|
163
|
+
EventEmitter.dispatch(["test:pass", { result: testResult }]);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
EventEmitter.dispatch(["test:fail", { result: testResult }]);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Runner } from "./Runner.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Runner } from "./Runner.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export var Color;
|
|
2
|
+
(function (Color) {
|
|
3
|
+
Color["Reset"] = "0";
|
|
4
|
+
Color["Red"] = "31";
|
|
5
|
+
Color["Green"] = "32";
|
|
6
|
+
Color["Yellow"] = "33";
|
|
7
|
+
Color["Blue"] = "34";
|
|
8
|
+
Color["Magenta"] = "35";
|
|
9
|
+
Color["Cyan"] = "36";
|
|
10
|
+
Color["Gray"] = "90";
|
|
11
|
+
})(Color || (Color = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Color } from "./Color.enum.js";
|
|
2
|
+
import type { ScribblerNode } from "./types.js";
|
|
3
|
+
interface LineProps {
|
|
4
|
+
children?: ScribblerNode;
|
|
5
|
+
color?: Color;
|
|
6
|
+
indent?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function Line({ children, color, indent }: LineProps): import("./types.js").ScribblerJsx.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ScribblerJsx } from "./types.js";
|
|
2
|
+
export interface ScribblerOptions {
|
|
3
|
+
newLine?: string;
|
|
4
|
+
noColor?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare class Scribbler {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(options?: ScribblerOptions);
|
|
9
|
+
render(element: ScribblerJsx.Element): string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { environmentOptions } from "#environment";
|
|
2
|
+
export class Scribbler {
|
|
3
|
+
#indentStep = " ";
|
|
4
|
+
#newLine;
|
|
5
|
+
#noColor;
|
|
6
|
+
#notEmptyLineRegex = /^(?!$)/gm;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.#newLine = options?.newLine ?? "\n";
|
|
9
|
+
this.#noColor = options?.noColor ?? environmentOptions.noColor;
|
|
10
|
+
}
|
|
11
|
+
#escapeSequence(attributes) {
|
|
12
|
+
return ["\u001B[", Array.isArray(attributes) ? attributes.join(";") : attributes, "m"].join("");
|
|
13
|
+
}
|
|
14
|
+
#indentEachLine(lines, level) {
|
|
15
|
+
if (level === 0) {
|
|
16
|
+
return lines;
|
|
17
|
+
}
|
|
18
|
+
return lines.replace(this.#notEmptyLineRegex, this.#indentStep.repeat(level));
|
|
19
|
+
}
|
|
20
|
+
render(element) {
|
|
21
|
+
if (typeof element.type === "function") {
|
|
22
|
+
return this.render(element.type({ ...element.props }));
|
|
23
|
+
}
|
|
24
|
+
if (element.type === "ansi" && !this.#noColor) {
|
|
25
|
+
return this.#escapeSequence(element.props.escapes);
|
|
26
|
+
}
|
|
27
|
+
if (element.type === "newLine") {
|
|
28
|
+
return this.#newLine;
|
|
29
|
+
}
|
|
30
|
+
if (element.type === "text") {
|
|
31
|
+
const text = this.#visitChildren(element.props.children);
|
|
32
|
+
return this.#indentEachLine(text, element.props.indent);
|
|
33
|
+
}
|
|
34
|
+
return "";
|
|
35
|
+
}
|
|
36
|
+
#visitChildren(children) {
|
|
37
|
+
const text = [];
|
|
38
|
+
for (const child of children) {
|
|
39
|
+
if (typeof child === "string" || typeof child === "number") {
|
|
40
|
+
text.push(child);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (Array.isArray(child)) {
|
|
44
|
+
text.push(this.#visitChildren(child));
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (child != null && typeof child === "object") {
|
|
48
|
+
text.push(this.render(child));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return text.join("");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Color } from "./Color.enum.js";
|
|
2
|
+
import type { ScribblerNode } from "./types.js";
|
|
3
|
+
interface TextProps {
|
|
4
|
+
children?: ScribblerNode;
|
|
5
|
+
color?: Color | undefined;
|
|
6
|
+
indent?: number | undefined;
|
|
7
|
+
}
|
|
8
|
+
export declare function Text({ children, color, indent }: TextProps): import("./types.js").ScribblerJsx.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "#scribbler/jsx-runtime";
|
|
2
|
+
export function Text({ children, color, indent }) {
|
|
3
|
+
const ansiEscapes = [];
|
|
4
|
+
if (color != null) {
|
|
5
|
+
ansiEscapes.push(color);
|
|
6
|
+
}
|
|
7
|
+
return (_jsxs("text", { indent: indent ?? 0, children: [ansiEscapes.length > 0 ? _jsx("ansi", { escapes: ansiEscapes }) : undefined, children, ansiEscapes.length > 0 ? _jsx("ansi", { escapes: "0" }) : undefined] }));
|
|
8
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Color } from "./Color.enum.js";
|
|
2
|
+
export type ScribblerNode = Array<ScribblerNode> | ScribblerJsx.Element | string | number | undefined;
|
|
3
|
+
export type FunctionComponent = (props: Record<string, unknown>) => ScribblerJsx.Element;
|
|
4
|
+
export declare namespace ScribblerJsx {
|
|
5
|
+
interface Element {
|
|
6
|
+
props: Record<string, unknown>;
|
|
7
|
+
type: FunctionComponent | number | string;
|
|
8
|
+
}
|
|
9
|
+
interface IntrinsicElements {
|
|
10
|
+
ansi: {
|
|
11
|
+
escapes: Color | Array<Color>;
|
|
12
|
+
};
|
|
13
|
+
newLine: {};
|
|
14
|
+
text: {
|
|
15
|
+
children: Array<ScribblerNode>;
|
|
16
|
+
indent: number;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ResolvedConfig } from "#config";
|
|
2
|
+
export declare class Select {
|
|
3
|
+
#private;
|
|
4
|
+
static isFixtureFile(filePath: string, resolvedConfig: ResolvedConfig): boolean;
|
|
5
|
+
static isTestFile(filePath: string, resolvedConfig: ResolvedConfig): boolean;
|
|
6
|
+
static selectFiles(resolvedConfig: ResolvedConfig): Promise<Array<string>>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import { Diagnostic } from "#diagnostic";
|
|
3
|
+
import { EventEmitter } from "#events";
|
|
4
|
+
import { Glob } from "#glob";
|
|
5
|
+
import { Path } from "#path";
|
|
6
|
+
import { SelectDiagnosticText } from "./SelectDiagnosticText.js";
|
|
7
|
+
export class Select {
|
|
8
|
+
static #patternsCache = new WeakMap();
|
|
9
|
+
static async #getAccessibleFileSystemEntries(targetPath) {
|
|
10
|
+
const directories = [];
|
|
11
|
+
const files = [];
|
|
12
|
+
try {
|
|
13
|
+
const entries = await fs.readdir(targetPath, { withFileTypes: true });
|
|
14
|
+
for (const entry of entries) {
|
|
15
|
+
let entryMeta = entry;
|
|
16
|
+
try {
|
|
17
|
+
if (entry.isSymbolicLink()) {
|
|
18
|
+
entryMeta = await fs.stat([targetPath, entry.name].join("/"));
|
|
19
|
+
}
|
|
20
|
+
if (entryMeta.isDirectory()) {
|
|
21
|
+
directories.push(entry.name);
|
|
22
|
+
}
|
|
23
|
+
else if (entryMeta.isFile()) {
|
|
24
|
+
files.push(entry.name);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
}
|
|
33
|
+
return { directories, files };
|
|
34
|
+
}
|
|
35
|
+
static #getMatchPatterns(globPatterns) {
|
|
36
|
+
let matchPatterns = Select.#patternsCache.get(globPatterns);
|
|
37
|
+
if (!matchPatterns) {
|
|
38
|
+
matchPatterns = {
|
|
39
|
+
includedDirectory: Glob.toRegex(globPatterns, "directories"),
|
|
40
|
+
includedFile: Glob.toRegex(globPatterns, "files"),
|
|
41
|
+
};
|
|
42
|
+
Select.#patternsCache.set(globPatterns, matchPatterns);
|
|
43
|
+
}
|
|
44
|
+
return matchPatterns;
|
|
45
|
+
}
|
|
46
|
+
static #isDirectoryIncluded(directoryPath, matchPatterns) {
|
|
47
|
+
return matchPatterns.includedDirectory.test(directoryPath);
|
|
48
|
+
}
|
|
49
|
+
static #isFileIncluded(filePath, matchPatterns, pathMatch = []) {
|
|
50
|
+
if (pathMatch.length > 0 && !pathMatch.some((match) => filePath.toLowerCase().includes(match.toLowerCase()))) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return matchPatterns.includedFile.test(filePath);
|
|
54
|
+
}
|
|
55
|
+
static isFixtureFile(filePath, resolvedConfig) {
|
|
56
|
+
const matchPatterns = Select.#getMatchPatterns(resolvedConfig.fixtureFileMatch);
|
|
57
|
+
return Select.#isFileIncluded(Path.relative(resolvedConfig.rootPath, filePath), matchPatterns);
|
|
58
|
+
}
|
|
59
|
+
static isTestFile(filePath, resolvedConfig) {
|
|
60
|
+
const matchPatterns = Select.#getMatchPatterns(resolvedConfig.testFileMatch);
|
|
61
|
+
return Select.#isFileIncluded(Path.relative(resolvedConfig.rootPath, filePath), matchPatterns, resolvedConfig.pathMatch);
|
|
62
|
+
}
|
|
63
|
+
static #onDiagnostics(diagnostic) {
|
|
64
|
+
EventEmitter.dispatch(["select:error", { diagnostics: [diagnostic] }]);
|
|
65
|
+
}
|
|
66
|
+
static async selectFiles(resolvedConfig) {
|
|
67
|
+
const matchPatterns = Select.#getMatchPatterns(resolvedConfig.testFileMatch);
|
|
68
|
+
const testFilePaths = [];
|
|
69
|
+
await Select.#visitDirectory(".", testFilePaths, matchPatterns, resolvedConfig);
|
|
70
|
+
if (testFilePaths.length === 0) {
|
|
71
|
+
Select.#onDiagnostics(Diagnostic.error(SelectDiagnosticText.noTestFilesWereSelected(resolvedConfig)));
|
|
72
|
+
}
|
|
73
|
+
return testFilePaths.sort((a, b) => a.localeCompare(b));
|
|
74
|
+
}
|
|
75
|
+
static async #visitDirectory(currentPath, testFilePaths, matchPatterns, resolvedConfig) {
|
|
76
|
+
const targetPath = Path.join(resolvedConfig.rootPath, currentPath);
|
|
77
|
+
const entries = await Select.#getAccessibleFileSystemEntries(targetPath);
|
|
78
|
+
for (const directoryName of entries.directories) {
|
|
79
|
+
const directoryPath = [currentPath, directoryName].join("/");
|
|
80
|
+
if (Select.#isDirectoryIncluded(directoryPath, matchPatterns)) {
|
|
81
|
+
await Select.#visitDirectory(directoryPath, testFilePaths, matchPatterns, resolvedConfig);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
for (const fileName of entries.files) {
|
|
85
|
+
const filePath = [currentPath, fileName].join("/");
|
|
86
|
+
if (Select.#isFileIncluded(filePath, matchPatterns, resolvedConfig.pathMatch)) {
|
|
87
|
+
testFilePaths.push([targetPath, fileName].join("/"));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export class SelectDiagnosticText {
|
|
2
|
+
static #pathSelectOptions(resolvedConfig) {
|
|
3
|
+
const text = [
|
|
4
|
+
`Root directory: ${resolvedConfig.rootPath}`,
|
|
5
|
+
`Test file match: ${resolvedConfig.testFileMatch.join(", ")}`,
|
|
6
|
+
];
|
|
7
|
+
if (resolvedConfig.pathMatch.length > 0) {
|
|
8
|
+
text.push(`Path match: ${resolvedConfig.pathMatch.join(", ")}`);
|
|
9
|
+
}
|
|
10
|
+
return text;
|
|
11
|
+
}
|
|
12
|
+
static noTestFilesWereLeft(resolvedConfig) {
|
|
13
|
+
return [
|
|
14
|
+
"No test files were left to run using current configuration.",
|
|
15
|
+
...SelectDiagnosticText.#pathSelectOptions(resolvedConfig),
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
static noTestFilesWereSelected(resolvedConfig) {
|
|
19
|
+
return [
|
|
20
|
+
"No test files were selected using current configuration.",
|
|
21
|
+
...SelectDiagnosticText.#pathSelectOptions(resolvedConfig),
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Diagnostic, type DiagnosticsHandler } from "#diagnostic";
|
|
2
|
+
export interface VersionMetadata {
|
|
3
|
+
dist: {
|
|
4
|
+
integrity: string;
|
|
5
|
+
tarball: string;
|
|
6
|
+
};
|
|
7
|
+
optionalDependencies?: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
export interface PackageMetadata {
|
|
10
|
+
["dist-tags"]: Record<string, string>;
|
|
11
|
+
modified: string;
|
|
12
|
+
name: string;
|
|
13
|
+
versions: Record<string, VersionMetadata>;
|
|
14
|
+
}
|
|
15
|
+
export declare class Fetcher {
|
|
16
|
+
#private;
|
|
17
|
+
constructor(onDiagnostics: DiagnosticsHandler, registry: string, retries: number, timeout: number);
|
|
18
|
+
get(request: Request, diagnostic: () => Diagnostic, options?: {
|
|
19
|
+
suppressErrors?: boolean | undefined;
|
|
20
|
+
}): Promise<Response | undefined>;
|
|
21
|
+
getMetadata<T>(packageSpecifier: string, options?: {
|
|
22
|
+
suppressErrors?: boolean | undefined;
|
|
23
|
+
}): Promise<T | undefined>;
|
|
24
|
+
}
|