@dads-framework/testing 0.0.0-stage → 0.2.0

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.
Files changed (125) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +276 -2
  3. package/bin/dad-test.js +3 -0
  4. package/dist/cli-arguments.d.ts +26 -0
  5. package/dist/cli-arguments.d.ts.map +1 -0
  6. package/dist/cli-arguments.js +90 -0
  7. package/dist/cli-arguments.js.map +1 -0
  8. package/dist/cli-output.d.ts +8 -0
  9. package/dist/cli-output.d.ts.map +1 -0
  10. package/dist/cli-output.js +11 -0
  11. package/dist/cli-output.js.map +1 -0
  12. package/dist/cli.d.ts +3 -0
  13. package/dist/cli.d.ts.map +1 -0
  14. package/dist/cli.js +14 -0
  15. package/dist/cli.js.map +1 -0
  16. package/dist/commands/explain.d.ts +8 -0
  17. package/dist/commands/explain.d.ts.map +1 -0
  18. package/dist/commands/explain.js +39 -0
  19. package/dist/commands/explain.js.map +1 -0
  20. package/dist/commands/init.d.ts +9 -0
  21. package/dist/commands/init.d.ts.map +1 -0
  22. package/dist/commands/init.js +57 -0
  23. package/dist/commands/init.js.map +1 -0
  24. package/dist/commands/plan-run.d.ts +8 -0
  25. package/dist/commands/plan-run.d.ts.map +1 -0
  26. package/dist/commands/plan-run.js +93 -0
  27. package/dist/commands/plan-run.js.map +1 -0
  28. package/dist/dad-test-cli.d.ts +33 -0
  29. package/dist/dad-test-cli.d.ts.map +1 -0
  30. package/dist/dad-test-cli.js +52 -0
  31. package/dist/dad-test-cli.js.map +1 -0
  32. package/dist/explain-plan.d.ts +86 -0
  33. package/dist/explain-plan.d.ts.map +1 -0
  34. package/dist/explain-plan.js +302 -0
  35. package/dist/explain-plan.js.map +1 -0
  36. package/dist/index.d.ts +13 -0
  37. package/dist/index.d.ts.map +1 -0
  38. package/dist/index.js +13 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/init/check-testing-manifest.d.ts +11 -0
  41. package/dist/init/check-testing-manifest.d.ts.map +1 -0
  42. package/dist/init/check-testing-manifest.js +166 -0
  43. package/dist/init/check-testing-manifest.js.map +1 -0
  44. package/dist/init/describe-error.d.ts +11 -0
  45. package/dist/init/describe-error.d.ts.map +1 -0
  46. package/dist/init/describe-error.js +13 -0
  47. package/dist/init/describe-error.js.map +1 -0
  48. package/dist/init/detect-workspace.d.ts +21 -0
  49. package/dist/init/detect-workspace.d.ts.map +1 -0
  50. package/dist/init/detect-workspace.js +133 -0
  51. package/dist/init/detect-workspace.js.map +1 -0
  52. package/dist/init/infer-one-package.d.ts +43 -0
  53. package/dist/init/infer-one-package.d.ts.map +1 -0
  54. package/dist/init/infer-one-package.js +173 -0
  55. package/dist/init/infer-one-package.js.map +1 -0
  56. package/dist/init/infer-testing-manifest.d.ts +60 -0
  57. package/dist/init/infer-testing-manifest.d.ts.map +1 -0
  58. package/dist/init/infer-testing-manifest.js +90 -0
  59. package/dist/init/infer-testing-manifest.js.map +1 -0
  60. package/dist/init/init-testing-manifest.d.ts +30 -0
  61. package/dist/init/init-testing-manifest.d.ts.map +1 -0
  62. package/dist/init/init-testing-manifest.js +205 -0
  63. package/dist/init/init-testing-manifest.js.map +1 -0
  64. package/dist/init/package-inventory.d.ts +21 -0
  65. package/dist/init/package-inventory.d.ts.map +1 -0
  66. package/dist/init/package-inventory.js +215 -0
  67. package/dist/init/package-inventory.js.map +1 -0
  68. package/dist/init/pnpm-workspace-yaml.d.ts +15 -0
  69. package/dist/init/pnpm-workspace-yaml.d.ts.map +1 -0
  70. package/dist/init/pnpm-workspace-yaml.js +158 -0
  71. package/dist/init/pnpm-workspace-yaml.js.map +1 -0
  72. package/dist/init/project-ids.d.ts +18 -0
  73. package/dist/init/project-ids.d.ts.map +1 -0
  74. package/dist/init/project-ids.js +54 -0
  75. package/dist/init/project-ids.js.map +1 -0
  76. package/dist/init/strip-json-comments.d.ts +9 -0
  77. package/dist/init/strip-json-comments.d.ts.map +1 -0
  78. package/dist/init/strip-json-comments.js +119 -0
  79. package/dist/init/strip-json-comments.js.map +1 -0
  80. package/dist/init/workspace-glob.d.ts +22 -0
  81. package/dist/init/workspace-glob.d.ts.map +1 -0
  82. package/dist/init/workspace-glob.js +154 -0
  83. package/dist/init/workspace-glob.js.map +1 -0
  84. package/dist/init/workspace-relative-path.d.ts +11 -0
  85. package/dist/init/workspace-relative-path.d.ts.map +1 -0
  86. package/dist/init/workspace-relative-path.js +17 -0
  87. package/dist/init/workspace-relative-path.js.map +1 -0
  88. package/dist/native-platform.d.ts +19 -0
  89. package/dist/native-platform.d.ts.map +1 -0
  90. package/dist/native-platform.js +115 -0
  91. package/dist/native-platform.js.map +1 -0
  92. package/dist/parse-guards.d.ts +13 -0
  93. package/dist/parse-guards.d.ts.map +1 -0
  94. package/dist/parse-guards.js +17 -0
  95. package/dist/parse-guards.js.map +1 -0
  96. package/dist/path-ownership.d.ts +17 -0
  97. package/dist/path-ownership.d.ts.map +1 -0
  98. package/dist/path-ownership.js +37 -0
  99. package/dist/path-ownership.js.map +1 -0
  100. package/dist/plan-issues.d.ts +17 -0
  101. package/dist/plan-issues.d.ts.map +1 -0
  102. package/dist/plan-issues.js +39 -0
  103. package/dist/plan-issues.js.map +1 -0
  104. package/dist/plan-reasons.d.ts +3 -0
  105. package/dist/plan-reasons.d.ts.map +1 -0
  106. package/dist/plan-reasons.js +14 -0
  107. package/dist/plan-reasons.js.map +1 -0
  108. package/dist/testing-api.d.ts +115 -0
  109. package/dist/testing-api.d.ts.map +1 -0
  110. package/dist/testing-api.js +96 -0
  111. package/dist/testing-api.js.map +1 -0
  112. package/dist/testing-manifest.d.ts +59 -0
  113. package/dist/testing-manifest.d.ts.map +1 -0
  114. package/dist/testing-manifest.js +196 -0
  115. package/dist/testing-manifest.js.map +1 -0
  116. package/dist/testing-report.d.ts +77 -0
  117. package/dist/testing-report.d.ts.map +1 -0
  118. package/dist/testing-report.js +184 -0
  119. package/dist/testing-report.js.map +1 -0
  120. package/dist/testing.tsbuildinfo +1 -0
  121. package/dist/write-files-atomically.d.ts +11 -0
  122. package/dist/write-files-atomically.d.ts.map +1 -0
  123. package/dist/write-files-atomically.js +30 -0
  124. package/dist/write-files-atomically.js.map +1 -0
  125. package/package.json +43 -4
@@ -0,0 +1,17 @@
1
+ import { relative, sep } from "node:path";
2
+ /**
3
+ * One spelling for a path inside the workspace.
4
+ *
5
+ * The inventory keys packages by it, and the manifest writer reports the files
6
+ * it wrote by it. Two spellings of one directory — a Windows separator here and
7
+ * a `/` there — would leave a resolved reference failing to match the package
8
+ * the inventory already holds.
9
+ */
10
+ /** `target` as a `/`-separated path relative to `workspaceRoot`, or `.` for the root. */
11
+ export function workspaceRelative(workspaceRoot, target) {
12
+ const relativePath = relative(workspaceRoot, target);
13
+ if (relativePath === "")
14
+ return ".";
15
+ return relativePath.split(sep).join("/");
16
+ }
17
+ //# sourceMappingURL=workspace-relative-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-relative-path.js","sourceRoot":"","sources":["../../src/init/workspace-relative-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;;;;GAOG;AAEH,yFAAyF;AACzF,MAAM,UAAU,iBAAiB,CAC/B,aAAqB,EACrB,MAAc;IAEd,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACrD,IAAI,YAAY,KAAK,EAAE;QAAE,OAAO,GAAG,CAAC;IACpC,OAAO,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,19 @@
1
+ export type NativeLibc = "glibc" | "musl" | "unknown" | "not-applicable";
2
+ export type NativePackageResolver = (packageName: string) => string;
3
+ /** Which input supplied the engine path, named the way a reader would name it. */
4
+ export type NativeBinarySource = "nativeBinary" | "DADS_TEST_NATIVE_BINARY" | "platform-package";
5
+ export type NativeBinaryResolution = {
6
+ readonly binary: string;
7
+ readonly source: NativeBinarySource;
8
+ };
9
+ export declare function nativePackageNameForPlatform(platform?: string, architecture?: string, libc?: NativeLibc): string;
10
+ export declare function resolveNativeTestingBinary(options?: {
11
+ readonly explicitBinary?: string;
12
+ readonly environment?: NodeJS.ProcessEnv;
13
+ readonly platform?: string;
14
+ readonly architecture?: string;
15
+ readonly libc?: NativeLibc;
16
+ readonly packageResolver?: NativePackageResolver;
17
+ }): NativeBinaryResolution;
18
+ export declare function detectNativeLibc(platform?: string): NativeLibc;
19
+ //# sourceMappingURL=native-platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-platform.d.ts","sourceRoot":"","sources":["../src/native-platform.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,gBAAgB,CAAC;AAyBzE,MAAM,MAAM,qBAAqB,GAAG,CAAC,WAAW,EAAE,MAAM,KAAK,MAAM,CAAC;AAEpE,kFAAkF;AAClF,MAAM,MAAM,kBAAkB,GAC5B,cAAc,GAAG,yBAAyB,GAAG,kBAAkB,CAAC;AAElE,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;CACrC,CAAC;AAEF,wBAAgB,4BAA4B,CAC1C,QAAQ,GAAE,MAAyB,EACnC,YAAY,GAAE,MAAqB,EACnC,IAAI,GAAE,UAAuC,GAC5C,MAAM,CAGR;AAED,wBAAgB,0BAA0B,CACxC,OAAO,GAAE;IACP,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACzC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,eAAe,CAAC,EAAE,qBAAqB,CAAC;CAC7C,GACL,sBAAsB,CAuBxB;AAiDD,wBAAgB,gBAAgB,CAC9B,QAAQ,GAAE,MAAyB,GAClC,UAAU,CAeZ"}
@@ -0,0 +1,115 @@
1
+ import { existsSync } from "node:fs";
2
+ import { createRequire } from "node:module";
3
+ import process from "node:process";
4
+ import { resolve } from "node:path";
5
+ const nativePackages = {
6
+ "darwin/arm64": {
7
+ packageName: "@dads-framework/testing-native-darwin-arm64",
8
+ },
9
+ "darwin/x64": { packageName: "@dads-framework/testing-native-darwin-x64" },
10
+ "linux/arm64/glibc": {
11
+ packageName: "@dads-framework/testing-native-linux-arm64-gnu",
12
+ libc: "glibc",
13
+ },
14
+ "linux/x64/glibc": {
15
+ packageName: "@dads-framework/testing-native-linux-x64-gnu",
16
+ libc: "glibc",
17
+ },
18
+ "win32/x64": { packageName: "@dads-framework/testing-native-win32-x64" },
19
+ };
20
+ const requireFromFacade = createRequire(import.meta.url);
21
+ export function nativePackageNameForPlatform(platform = process.platform, architecture = process.arch, libc = detectNativeLibc(platform)) {
22
+ return nativePackageDefinitionForPlatform(platform, architecture, libc)
23
+ .packageName;
24
+ }
25
+ export function resolveNativeTestingBinary(options = {}) {
26
+ const developmentBinary = developmentBinaryFor(options);
27
+ if (developmentBinary !== undefined)
28
+ return developmentBinary;
29
+ const platform = options.platform ?? process.platform;
30
+ const architecture = options.architecture ?? process.arch;
31
+ const packageName = nativePackageNameForPlatform(platform, architecture, options.libc ?? detectNativeLibc(platform));
32
+ const binary = resolveNativePackageBinary(packageName, platform, architecture, options.packageResolver ?? resolveInstalledNativePackage);
33
+ if (!existsSync(binary)) {
34
+ throw new Error(`Dads Testing native package ${packageName} resolved to a missing binary: ${binary}.`);
35
+ }
36
+ return { binary, source: "platform-package" };
37
+ }
38
+ /**
39
+ * An explicit path — from the option or from the environment — names a binary
40
+ * a developer built, so it is used as given rather than looked up. Either one
41
+ * replaces the platform package: it is read first, and no package lookup runs
42
+ * behind it.
43
+ */
44
+ function developmentBinaryFor(options) {
45
+ const explicitBinary = options.explicitBinary;
46
+ if (explicitBinary !== undefined) {
47
+ return requireExistingDevelopmentBinary(explicitBinary, "nativeBinary");
48
+ }
49
+ const environment = options.environment ?? process.env;
50
+ const environmentBinary = environment["DADS_TEST_NATIVE_BINARY"];
51
+ if (environmentBinary === undefined)
52
+ return undefined;
53
+ return requireExistingDevelopmentBinary(environmentBinary, "DADS_TEST_NATIVE_BINARY");
54
+ }
55
+ /** A resolution failure is reported against the platform, because that chose the package. */
56
+ function resolveNativePackageBinary(packageName, platform, architecture, resolvePackage) {
57
+ try {
58
+ return resolvePackage(packageName);
59
+ }
60
+ catch (error) {
61
+ throw new Error(`Dads Testing native package ${packageName} is not installed for ${platform}/${architecture}. Install that optional package explicitly${resolutionDetail(error)}.`, { cause: error });
62
+ }
63
+ }
64
+ function resolutionDetail(error) {
65
+ return error instanceof Error && error.message.length > 0
66
+ ? ` (${error.message})`
67
+ : "";
68
+ }
69
+ export function detectNativeLibc(platform = process.platform) {
70
+ if (platform !== "linux")
71
+ return "not-applicable";
72
+ try {
73
+ const report = process.report.getReport();
74
+ const header = isKeyedObject(report) ? report["header"] : undefined;
75
+ if (isKeyedObject(header) &&
76
+ typeof header["glibcVersionRuntime"] === "string") {
77
+ return "glibc";
78
+ }
79
+ }
80
+ catch {
81
+ // An unavailable diagnostic report is represented as unknown below.
82
+ }
83
+ return "unknown";
84
+ }
85
+ function nativePackageDefinitionForPlatform(platform, architecture, libc) {
86
+ const key = platform === "linux"
87
+ ? `${platform}/${architecture}/${libc}`
88
+ : `${platform}/${architecture}`;
89
+ const definition = nativePackages[key];
90
+ if (definition !== undefined)
91
+ return definition;
92
+ if (platform === "linux" && libc !== "glibc") {
93
+ throw new Error(`Dads Testing does not provide a native package for Linux ${architecture} with libc ${libc}; the supported Linux runtime is glibc.`);
94
+ }
95
+ throw new Error(`Dads Testing does not provide a native package for platform ${platform} and architecture ${architecture}. Supported targets are darwin/arm64, darwin/x64, linux/arm64/glibc, linux/x64/glibc, and win32/x64.`);
96
+ }
97
+ function requireExistingDevelopmentBinary(path, source) {
98
+ const binary = resolve(process.cwd(), path);
99
+ if (!existsSync(binary)) {
100
+ throw new Error(`The ${source} path does not exist: ${binary}.`);
101
+ }
102
+ return { binary, source };
103
+ }
104
+ function resolveInstalledNativePackage(packageName) {
105
+ return requireFromFacade.resolve(packageName);
106
+ }
107
+ /**
108
+ * True for any non-null object, an array included. The diagnostic report this
109
+ * reads is indexed by key rather than inspected for shape, so it does not need
110
+ * the array-excluding `isRecord` in `parse-guards.ts`, and must not claim it.
111
+ */
112
+ function isKeyedObject(value) {
113
+ return typeof value === "object" && value !== null;
114
+ }
115
+ //# sourceMappingURL=native-platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-platform.js","sourceRoot":"","sources":["../src/native-platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,MAAM,cAAc,GAAsD;IACxE,cAAc,EAAE;QACd,WAAW,EAAE,6CAA6C;KAC3D;IACD,YAAY,EAAE,EAAE,WAAW,EAAE,2CAA2C,EAAE;IAC1E,mBAAmB,EAAE;QACnB,WAAW,EAAE,gDAAgD;QAC7D,IAAI,EAAE,OAAO;KACd;IACD,iBAAiB,EAAE;QACjB,WAAW,EAAE,8CAA8C;QAC3D,IAAI,EAAE,OAAO;KACd;IACD,WAAW,EAAE,EAAE,WAAW,EAAE,0CAA0C,EAAE;CACzE,CAAC;AAEF,MAAM,iBAAiB,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAazD,MAAM,UAAU,4BAA4B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I,CAAC;AACrD,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The two narrowings every reader of an untrusted document starts from.
3
+ *
4
+ * A `package.json`, a `tsconfig.json` and a `dads.testing.json` all arrive as
5
+ * `unknown`, and each reader asks the same first question before it can ask any
6
+ * other. Stating the answer once is what keeps "record" meaning an object that
7
+ * is not an array in every reader this package owns.
8
+ */
9
+ /** True when `value` is an object rather than `null` or an array. */
10
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
11
+ /** True when `value` is an array whose elements have not been checked yet. */
12
+ export declare function isUnknownArray(value: unknown): value is readonly unknown[];
13
+ //# sourceMappingURL=parse-guards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-guards.d.ts","sourceRoot":"","sources":["../src/parse-guards.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,qEAAqE;AACrE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,8EAA8E;AAC9E,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,OAAO,EAAE,CAE1E"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The two narrowings every reader of an untrusted document starts from.
3
+ *
4
+ * A `package.json`, a `tsconfig.json` and a `dads.testing.json` all arrive as
5
+ * `unknown`, and each reader asks the same first question before it can ask any
6
+ * other. Stating the answer once is what keeps "record" meaning an object that
7
+ * is not an array in every reader this package owns.
8
+ */
9
+ /** True when `value` is an object rather than `null` or an array. */
10
+ export function isRecord(value) {
11
+ return typeof value === "object" && value !== null && !isUnknownArray(value);
12
+ }
13
+ /** True when `value` is an array whose elements have not been checked yet. */
14
+ export function isUnknownArray(value) {
15
+ return Array.isArray(value);
16
+ }
17
+ //# sourceMappingURL=parse-guards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-guards.js","sourceRoot":"","sources":["../src/parse-guards.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,qEAAqE;AACrE,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;AAC/E,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Path ownership is declared by project roots in the testing manifest. A root of
3
+ * "." owns the whole workspace, and the deepest declared root wins whenever more
4
+ * than one project could own a path.
5
+ */
6
+ /** Reports whether a workspace-relative path is owned by a project root. */
7
+ export declare function pathIsInside(path: string, root: string): boolean;
8
+ /**
9
+ * Returns the project owning a workspace-relative path, or undefined when no
10
+ * project owns it or when two equally deep roots both claim it. An ambiguous
11
+ * ownership answer is deliberately no answer: the caller must widen instead of
12
+ * guessing.
13
+ */
14
+ export declare function owningProjectForPath<Project extends {
15
+ readonly root: string;
16
+ }>(projects: readonly Project[], path: string): Project | undefined;
17
+ //# sourceMappingURL=path-ownership.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-ownership.d.ts","sourceRoot":"","sources":["../src/path-ownership.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAGhE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAC5E,QAAQ,EAAE,SAAS,OAAO,EAAE,EAC5B,IAAI,EAAE,MAAM,GACX,OAAO,GAAG,SAAS,CAgBrB"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Path ownership is declared by project roots in the testing manifest. A root of
3
+ * "." owns the whole workspace, and the deepest declared root wins whenever more
4
+ * than one project could own a path.
5
+ */
6
+ /** Reports whether a workspace-relative path is owned by a project root. */
7
+ export function pathIsInside(path, root) {
8
+ if (root === ".")
9
+ return true;
10
+ return path === root || path.startsWith(`${root}/`);
11
+ }
12
+ /**
13
+ * Returns the project owning a workspace-relative path, or undefined when no
14
+ * project owns it or when two equally deep roots both claim it. An ambiguous
15
+ * ownership answer is deliberately no answer: the caller must widen instead of
16
+ * guessing.
17
+ */
18
+ export function owningProjectForPath(projects, path) {
19
+ let owner;
20
+ let ownerDepth = -1;
21
+ let ambiguous = false;
22
+ for (const project of projects) {
23
+ if (!pathIsInside(path, project.root))
24
+ continue;
25
+ const depth = project.root === "." ? 0 : project.root.length;
26
+ if (depth > ownerDepth) {
27
+ owner = project;
28
+ ownerDepth = depth;
29
+ ambiguous = false;
30
+ }
31
+ else if (depth === ownerDepth) {
32
+ ambiguous = true;
33
+ }
34
+ }
35
+ return ambiguous ? undefined : owner;
36
+ }
37
+ //# sourceMappingURL=path-ownership.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-ownership.js","sourceRoot":"","sources":["../src/path-ownership.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,4EAA4E;AAC5E,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,IAAY;IACrD,IAAI,IAAI,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IAC9B,OAAO,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;AACtD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,QAA4B,EAC5B,IAAY;IAEZ,IAAI,KAA0B,CAAC;IAC/B,IAAI,UAAU,GAAG,CAAC,CAAC,CAAC;IACpB,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC;YAAE,SAAS;QAChD,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;QAC7D,IAAI,KAAK,GAAG,UAAU,EAAE,CAAC;YACvB,KAAK,GAAG,OAAO,CAAC;YAChB,UAAU,GAAG,KAAK,CAAC;YACnB,SAAS,GAAG,KAAK,CAAC;QACpB,CAAC;aAAM,IAAI,KAAK,KAAK,UAAU,EAAE,CAAC;YAChC,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;AACvC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { TestingPlanIssue } from "./testing-api.js";
2
+ /**
3
+ * Plan issues are read from an engine that may be older than this facade. Every
4
+ * classifying field is optional on the wire, so these helpers derive the same
5
+ * answer from the issue code when a field is missing.
6
+ */
7
+ /** Returns the declared severity, or the severity implied by the issue code. */
8
+ export declare function issueSeverity(issue: TestingPlanIssue): "info" | "uncertainty" | "error";
9
+ /**
10
+ * Returns the declared scope, or the scope implied by the issue code. An
11
+ * informational issue with no declared scope is "unknown" rather than "module":
12
+ * it is not evidence that any one module is uncertain.
13
+ */
14
+ export declare function issueScope(issue: TestingPlanIssue): "module" | "workspace" | "unknown";
15
+ /** Formats the issue location as path:line:column, degrading as fields are missing. */
16
+ export declare function formatIssueLocation(issue: TestingPlanIssue): string | undefined;
17
+ //# sourceMappingURL=plan-issues.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-issues.d.ts","sourceRoot":"","sources":["../src/plan-issues.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;;;GAIG;AAEH,gFAAgF;AAChF,wBAAgB,aAAa,CAC3B,KAAK,EAAE,gBAAgB,GACtB,MAAM,GAAG,aAAa,GAAG,OAAO,CAKlC;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,gBAAgB,GACtB,QAAQ,GAAG,WAAW,GAAG,SAAS,CASpC;AAED,uFAAuF;AACvF,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,gBAAgB,GACtB,MAAM,GAAG,SAAS,CAOpB"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Plan issues are read from an engine that may be older than this facade. Every
3
+ * classifying field is optional on the wire, so these helpers derive the same
4
+ * answer from the issue code when a field is missing.
5
+ */
6
+ /** Returns the declared severity, or the severity implied by the issue code. */
7
+ export function issueSeverity(issue) {
8
+ if (issue.severity !== undefined)
9
+ return issue.severity;
10
+ return issue.code.startsWith("graph-") || issue.code.startsWith("snapshot-")
11
+ ? "info"
12
+ : "uncertainty";
13
+ }
14
+ /**
15
+ * Returns the declared scope, or the scope implied by the issue code. An
16
+ * informational issue with no declared scope is "unknown" rather than "module":
17
+ * it is not evidence that any one module is uncertain.
18
+ */
19
+ export function issueScope(issue) {
20
+ if (issue.scope !== undefined)
21
+ return issue.scope;
22
+ if (issue.code === "unknown-changed-path" ||
23
+ issue.code === "reachable-module-unowned") {
24
+ return "workspace";
25
+ }
26
+ return issueSeverity(issue) === "info" ? "unknown" : "module";
27
+ }
28
+ /** Formats the issue location as path:line:column, degrading as fields are missing. */
29
+ export function formatIssueLocation(issue) {
30
+ if (issue.path === undefined)
31
+ return undefined;
32
+ if (issue.line === undefined)
33
+ return issue.path;
34
+ if (issue.column === undefined) {
35
+ return `${issue.path}:${String(issue.line)}`;
36
+ }
37
+ return `${issue.path}:${String(issue.line)}:${String(issue.column)}`;
38
+ }
39
+ //# sourceMappingURL=plan-issues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-issues.js","sourceRoot":"","sources":["../src/plan-issues.ts"],"names":[],"mappings":"AAEA;;;;GAIG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ands for. An unknown code is its own text. */
2
+ export declare const reasonTexts: Readonly<Record<string, string>>;
3
+ //# sourceMappingURL=plan-reasons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-reasons.d.ts","sourceRoot":"","sources":["../src/plan-reasons.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAYxD,CAAC"}
@@ -0,0 +1,14 @@
1
+ /** The sentence each reason code stands for. An unknown code is its own text. */
2
+ export const reasonTexts = {
3
+ "direct-task-input": "requested explicitly with --task",
4
+ "full-fallback": "complete workspace fallback selected",
5
+ "impact-always": "declared impact.mode always",
6
+ "graph-uncertainty-project-fallback": "graph proof incomplete; widened through fallback dependencies",
7
+ "selected-prerequisite": "prerequisite of a selected task",
8
+ "graph-changed-export": "an exported symbol in this project changed",
9
+ "graph-symbol-importer": "imports a changed symbol",
10
+ "changed-owned-project": "a changed path is owned by this project",
11
+ "changed-file-input": "a declared file input changed",
12
+ "proven-unaffected": "no changed path or symbol reaches this task",
13
+ };
14
+ //# sourceMappingURL=plan-reasons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-reasons.js","sourceRoot":"","sources":["../src/plan-reasons.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,MAAM,CAAC,MAAM,WAAW,GAAqC;IAC3D,mBAAmB,EAAE,kCAAkC;IACvD,eAAe,EAAE,sCAAsC;IACvD,eAAe,EAAE,6BAA6B;IAC9C,oCAAoC,EAClC,+DAA+D;IACjE,uBAAuB,EAAE,iCAAiC;IAC1D,sBAAsB,EAAE,4CAA4C;IACpE,uBAAuB,EAAE,0BAA0B;IACnD,uBAAuB,EAAE,yCAAyC;IAClE,oBAAoB,EAAE,+BAA+B;IACrD,mBAAmB,EAAE,6CAA6C;CACnE,CAAC"}
@@ -0,0 +1,115 @@
1
+ export type TestingOperationRequest = {
2
+ readonly workspaceRoot: string;
3
+ readonly manifestPath?: string;
4
+ readonly base?: string;
5
+ readonly head?: string;
6
+ readonly all?: boolean;
7
+ readonly taskIds?: readonly string[];
8
+ readonly jobs?: number;
9
+ /** An explicit native binary is intended for local development and test harnesses. */
10
+ readonly nativeBinary?: string;
11
+ };
12
+ export type TestingTaskDecision = {
13
+ readonly id: string;
14
+ readonly decision: "run" | "skip-proven-unaffected";
15
+ readonly reason: string;
16
+ readonly confidence: string;
17
+ readonly widened: boolean;
18
+ /** The project owning the task, when the engine reports it. */
19
+ readonly project?: string;
20
+ /** Every reason this task was selected, when the engine reports them. */
21
+ readonly causes?: readonly TestingTaskCause[];
22
+ };
23
+ /**
24
+ * One reason a task was selected. `issue` refers to a position in the plan's
25
+ * `issues` array as emitted, so a reader must keep that array in its original
26
+ * order to resolve the reference.
27
+ */
28
+ export type TestingTaskCause = {
29
+ readonly kind: "direct-task-input";
30
+ readonly taskId: string;
31
+ } | {
32
+ readonly kind: "prerequisite-of";
33
+ readonly taskId: string;
34
+ } | {
35
+ readonly kind: "changed-path";
36
+ readonly path: string;
37
+ } | {
38
+ readonly kind: "changed-export";
39
+ readonly path: string;
40
+ readonly symbol: string;
41
+ } | {
42
+ readonly kind: "reached-import";
43
+ readonly path: string;
44
+ readonly line?: number;
45
+ readonly column?: number;
46
+ readonly importedFrom: string;
47
+ readonly symbols: readonly string[];
48
+ } | {
49
+ readonly kind: "issue";
50
+ readonly index: number;
51
+ } | {
52
+ readonly kind: "fallback-dependency";
53
+ readonly project: string;
54
+ };
55
+ /**
56
+ * One planning issue. Every classifying field is optional: an engine older than
57
+ * this facade reports only `code` and `message`, and `plan-issues.ts` derives
58
+ * the rest from the code.
59
+ */
60
+ export type TestingPlanIssue = {
61
+ readonly code: string;
62
+ readonly message: string;
63
+ readonly severity?: "info" | "uncertainty" | "error";
64
+ readonly scope?: "module" | "workspace";
65
+ readonly path?: string;
66
+ readonly line?: number;
67
+ readonly column?: number;
68
+ readonly project?: string;
69
+ };
70
+ export type TestingPlanResult = {
71
+ readonly schemaVersion: 1;
72
+ readonly scope: {
73
+ readonly kind: string;
74
+ readonly base?: string;
75
+ readonly head?: string;
76
+ readonly changedPaths: readonly string[];
77
+ readonly fullFallback: boolean;
78
+ };
79
+ readonly tasks: readonly TestingTaskDecision[];
80
+ readonly issues: readonly TestingPlanIssue[];
81
+ readonly complete: boolean;
82
+ readonly counts: {
83
+ readonly run: number;
84
+ readonly skipProvenUnaffected: number;
85
+ };
86
+ };
87
+ export type TestingTaskRunResult = {
88
+ readonly id: string;
89
+ readonly status: "executed" | "failed" | "blocked" | "not-applicable";
90
+ readonly exitCode?: number;
91
+ readonly durationMs?: number;
92
+ readonly stdout?: TestingTaskOutput;
93
+ readonly stderr?: TestingTaskOutput;
94
+ readonly error?: string;
95
+ };
96
+ export type TestingTaskOutput = {
97
+ readonly text: string;
98
+ readonly truncated: boolean;
99
+ };
100
+ export type TestingRunResult = {
101
+ readonly tasks: readonly TestingTaskRunResult[];
102
+ readonly counts: {
103
+ readonly executed: number;
104
+ readonly failed: number;
105
+ readonly blocked: number;
106
+ readonly notApplicable: number;
107
+ };
108
+ readonly exitCode: number;
109
+ };
110
+ export declare function planTesting(request: TestingOperationRequest): Promise<TestingPlanResult>;
111
+ export declare function runTesting(request: TestingOperationRequest): Promise<{
112
+ readonly plan: TestingPlanResult;
113
+ readonly run: TestingRunResult;
114
+ }>;
115
+ //# sourceMappingURL=testing-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing-api.d.ts","sourceRoot":"","sources":["../src/testing-api.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,CA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AAyBF,wBAAsB,WAAW,CAC/B,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,iBAAiB,CAAC,CAG5B;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC;IAC1E,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,gBAAgB,CAAC;CAChC,CAAC,CAQD"}
@@ -0,0 +1,96 @@
1
+ import { spawn } from "node:child_process";
2
+ import { resolve } from "node:path";
3
+ import { resolveNativeTestingBinary } from "./native-platform.js";
4
+ const protocolSchemaVersion = 1;
5
+ export async function planTesting(request) {
6
+ const response = await invokeNativeTestingEngine("plan", request);
7
+ return response.plan;
8
+ }
9
+ export async function runTesting(request) {
10
+ const response = await invokeNativeTestingEngine("run", request);
11
+ if (!response.run) {
12
+ throw new Error("The native testing engine returned a run response without run details.");
13
+ }
14
+ return { plan: response.plan, run: response.run };
15
+ }
16
+ async function invokeNativeTestingEngine(operation, request) {
17
+ const nativeRequest = toNativeRequest(operation, request);
18
+ const response = await runNativeProcess(resolveNativeTestingBinary(request.nativeBinary === undefined
19
+ ? {}
20
+ : { explicitBinary: request.nativeBinary }).binary, nativeRequest);
21
+ return requireResultFor(response, operation);
22
+ }
23
+ /** An absent field is omitted rather than sent as null, which the engine refuses. */
24
+ function toNativeRequest(operation, request) {
25
+ return {
26
+ schemaVersion: protocolSchemaVersion,
27
+ operation,
28
+ workspaceRoot: resolve(request.workspaceRoot),
29
+ ...(request.manifestPath === undefined
30
+ ? {}
31
+ : { manifestPath: request.manifestPath }),
32
+ ...(request.base === undefined ? {} : { base: request.base }),
33
+ ...(request.head === undefined ? {} : { head: request.head }),
34
+ all: request.all ?? false,
35
+ taskIds: request.taskIds ?? [],
36
+ ...(request.jobs === undefined ? {} : { jobs: request.jobs }),
37
+ };
38
+ }
39
+ /**
40
+ * Every way the envelope can fail to carry the result asked for is an error
41
+ * here, so a caller only ever sees a result for the operation it requested.
42
+ */
43
+ function requireResultFor(response, operation) {
44
+ if (response.schemaVersion !== protocolSchemaVersion) {
45
+ throw new Error(`Unsupported native response schemaVersion ${String(response.schemaVersion)}.`);
46
+ }
47
+ if (!response.ok || !response.result) {
48
+ throw new Error(response.error ??
49
+ "The native testing engine failed without an error message.");
50
+ }
51
+ if (response.result.operation !== operation) {
52
+ throw new Error(`The native testing engine returned ${response.result.operation} for ${operation}.`);
53
+ }
54
+ return response.result;
55
+ }
56
+ async function runNativeProcess(nativeBinary, request) {
57
+ return new Promise((resolveResponse, reject) => {
58
+ const child = spawn(nativeBinary, [], { stdio: ["pipe", "pipe", "pipe"] });
59
+ const stdout = [];
60
+ const stderr = [];
61
+ child.stdout.setEncoding("utf8");
62
+ child.stderr.setEncoding("utf8");
63
+ child.stdout.on("data", (chunk) => stdout.push(chunk));
64
+ child.stderr.on("data", (chunk) => stderr.push(chunk));
65
+ child.once("error", (error) => {
66
+ reject(error);
67
+ });
68
+ child.once("close", () => {
69
+ const rawResponse = stdout.join("").trim();
70
+ try {
71
+ const parsed = JSON.parse(rawResponse);
72
+ if (!isNativeResponse(parsed)) {
73
+ reject(new Error("The native testing engine returned an invalid response."));
74
+ return;
75
+ }
76
+ resolveResponse(parsed);
77
+ }
78
+ catch (error) {
79
+ const detail = stderr.join("").trim();
80
+ reject(new Error(detail.length > 0
81
+ ? `The native testing engine did not return JSON: ${detail}`
82
+ : `The native testing engine did not return JSON: ${error instanceof Error ? error.message : "unknown parse error"}`));
83
+ }
84
+ });
85
+ child.stdin.end(JSON.stringify(request));
86
+ });
87
+ }
88
+ function isNativeResponse(value) {
89
+ return (typeof value === "object" &&
90
+ value !== null &&
91
+ "schemaVersion" in value &&
92
+ "ok" in value &&
93
+ typeof value.schemaVersion === "number" &&
94
+ typeof value.ok === "boolean");
95
+ }
96
+ //# sourceMappingURL=testing-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing-api.js","sourceRoot":"","sources":["../src/testing-api.ts"],"names":[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