@convesoft/nx-rust 0.0.0-stage → 1.0.0-rc.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/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +21 -0
- package/README.md +48 -2
- package/executors.json +35 -0
- package/generators.json +19 -0
- package/package.json +26 -4
- package/src/cargo/build-settings.d.ts +54 -0
- package/src/cargo/build-settings.js +93 -0
- package/src/cargo/build-settings.js.map +1 -0
- package/src/cargo/configured-runner.d.ts +36 -0
- package/src/cargo/configured-runner.js +99 -0
- package/src/cargo/configured-runner.js.map +1 -0
- package/src/cargo/configured-tools.d.ts +35 -0
- package/src/cargo/configured-tools.js +46 -0
- package/src/cargo/configured-tools.js.map +1 -0
- package/src/cargo/dep-info-basedir.d.ts +18 -0
- package/src/cargo/dep-info-basedir.js +38 -0
- package/src/cargo/dep-info-basedir.js.map +1 -0
- package/src/cargo/directories.d.ts +40 -0
- package/src/cargo/directories.js +89 -0
- package/src/cargo/directories.js.map +1 -0
- package/src/cargo/host-triple.d.ts +7 -0
- package/src/cargo/host-triple.js +21 -0
- package/src/cargo/host-triple.js.map +1 -0
- package/src/cargo/lockfile.d.ts +63 -0
- package/src/cargo/lockfile.js +157 -0
- package/src/cargo/lockfile.js.map +1 -0
- package/src/cargo/metadata.d.ts +112 -0
- package/src/cargo/metadata.js +37 -0
- package/src/cargo/metadata.js.map +1 -0
- package/src/cargo/package-specs.d.ts +54 -0
- package/src/cargo/package-specs.js +109 -0
- package/src/cargo/package-specs.js.map +1 -0
- package/src/cargo/paths-crates.d.ts +27 -0
- package/src/cargo/paths-crates.js +69 -0
- package/src/cargo/paths-crates.js.map +1 -0
- package/src/cargo/print-artifact-folders.d.ts +1 -0
- package/src/cargo/print-artifact-folders.js +58 -0
- package/src/cargo/print-artifact-folders.js.map +1 -0
- package/src/cargo/redirections.d.ts +87 -0
- package/src/cargo/redirections.js +195 -0
- package/src/cargo/redirections.js.map +1 -0
- package/src/cargo/run-cargo.d.ts +31 -0
- package/src/cargo/run-cargo.js +75 -0
- package/src/cargo/run-cargo.js.map +1 -0
- package/src/cargo/target-triples.d.ts +98 -0
- package/src/cargo/target-triples.js +265 -0
- package/src/cargo/target-triples.js.map +1 -0
- package/src/cargo/version-req.d.ts +12 -0
- package/src/cargo/version-req.js +122 -0
- package/src/cargo/version-req.js.map +1 -0
- package/src/compatibility/cargo-version.d.ts +43 -0
- package/src/compatibility/cargo-version.js +83 -0
- package/src/compatibility/cargo-version.js.map +1 -0
- package/src/compatibility/nx-bridge.d.ts +312 -0
- package/src/compatibility/nx-bridge.js +407 -0
- package/src/compatibility/nx-bridge.js.map +1 -0
- package/src/compatibility/nx-version.d.ts +104 -0
- package/src/compatibility/nx-version.js +272 -0
- package/src/compatibility/nx-version.js.map +1 -0
- package/src/executors/affected-inputs.d.ts +29 -0
- package/src/executors/affected-inputs.js +259 -0
- package/src/executors/affected-inputs.js.map +1 -0
- package/src/executors/affected-run.d.ts +54 -0
- package/src/executors/affected-run.js +394 -0
- package/src/executors/affected-run.js.map +1 -0
- package/src/executors/affected.d.ts +239 -0
- package/src/executors/affected.js +589 -0
- package/src/executors/affected.js.map +1 -0
- package/src/executors/baseline-context.d.ts +85 -0
- package/src/executors/baseline-context.js +227 -0
- package/src/executors/baseline-context.js.map +1 -0
- package/src/executors/baseline.d.ts +123 -0
- package/src/executors/baseline.js +356 -0
- package/src/executors/baseline.js.map +1 -0
- package/src/executors/batch.d.ts +75 -0
- package/src/executors/batch.js +434 -0
- package/src/executors/batch.js.map +1 -0
- package/src/executors/build-records.d.ts +110 -0
- package/src/executors/build-records.js +267 -0
- package/src/executors/build-records.js.map +1 -0
- package/src/executors/cargo/executor.d.ts +28 -0
- package/src/executors/cargo/executor.js +58 -0
- package/src/executors/cargo/executor.js.map +1 -0
- package/src/executors/cargo/schema.json +54 -0
- package/src/executors/cargo-invocation.d.ts +81 -0
- package/src/executors/cargo-invocation.js +109 -0
- package/src/executors/cargo-invocation.js.map +1 -0
- package/src/executors/cargo-output.d.ts +212 -0
- package/src/executors/cargo-output.js +646 -0
- package/src/executors/cargo-output.js.map +1 -0
- package/src/executors/command.d.ts +318 -0
- package/src/executors/command.js +517 -0
- package/src/executors/command.js.map +1 -0
- package/src/executors/coverage-baseline.d.ts +23 -0
- package/src/executors/coverage-baseline.js +284 -0
- package/src/executors/coverage-baseline.js.map +1 -0
- package/src/executors/declared-options.d.ts +21 -0
- package/src/executors/declared-options.js +58 -0
- package/src/executors/declared-options.js.map +1 -0
- package/src/executors/digests.d.ts +94 -0
- package/src/executors/digests.js +190 -0
- package/src/executors/digests.js.map +1 -0
- package/src/executors/dotenv-check.d.ts +79 -0
- package/src/executors/dotenv-check.js +553 -0
- package/src/executors/dotenv-check.js.map +1 -0
- package/src/executors/group-invocations.d.ts +80 -0
- package/src/executors/group-invocations.js +253 -0
- package/src/executors/group-invocations.js.map +1 -0
- package/src/executors/group-run.d.ts +114 -0
- package/src/executors/group-run.js +591 -0
- package/src/executors/group-run.js.map +1 -0
- package/src/executors/groups.d.ts +113 -0
- package/src/executors/groups.js +285 -0
- package/src/executors/groups.js.map +1 -0
- package/src/executors/input-check.d.ts +52 -0
- package/src/executors/input-check.js +271 -0
- package/src/executors/input-check.js.map +1 -0
- package/src/executors/kept-files.d.ts +98 -0
- package/src/executors/kept-files.js +341 -0
- package/src/executors/kept-files.js.map +1 -0
- package/src/executors/lockfile/executor.d.ts +16 -0
- package/src/executors/lockfile/executor.js +37 -0
- package/src/executors/lockfile/executor.js.map +1 -0
- package/src/executors/lockfile/schema.json +50 -0
- package/src/executors/napi-build.d.ts +73 -0
- package/src/executors/napi-build.js +420 -0
- package/src/executors/napi-build.js.map +1 -0
- package/src/executors/nextest.d.ts +185 -0
- package/src/executors/nextest.js +498 -0
- package/src/executors/nextest.js.map +1 -0
- package/src/executors/nx-command.d.ts +95 -0
- package/src/executors/nx-command.js +205 -0
- package/src/executors/nx-command.js.map +1 -0
- package/src/executors/nx-task-files.d.ts +82 -0
- package/src/executors/nx-task-files.js +156 -0
- package/src/executors/nx-task-files.js.map +1 -0
- package/src/executors/print-test-mode.d.ts +1 -0
- package/src/executors/print-test-mode.js +25 -0
- package/src/executors/print-test-mode.js.map +1 -0
- package/src/executors/release-publish/executor.d.ts +24 -0
- package/src/executors/release-publish/executor.js +165 -0
- package/src/executors/release-publish/executor.js.map +1 -0
- package/src/executors/release-publish/schema.json +30 -0
- package/src/executors/run/executor.d.ts +12 -0
- package/src/executors/run/executor.js +27 -0
- package/src/executors/run/executor.js.map +1 -0
- package/src/executors/run/schema.json +45 -0
- package/src/executors/runner-script.d.ts +12 -0
- package/src/executors/runner-script.js +22 -0
- package/src/executors/runner-script.js.map +1 -0
- package/src/executors/runtime-input-check.d.ts +24 -0
- package/src/executors/runtime-input-check.js +87 -0
- package/src/executors/runtime-input-check.js.map +1 -0
- package/src/executors/shared-artifacts.d.ts +44 -0
- package/src/executors/shared-artifacts.js +132 -0
- package/src/executors/shared-artifacts.js.map +1 -0
- package/src/executors/split-words.d.ts +24 -0
- package/src/executors/split-words.js +111 -0
- package/src/executors/split-words.js.map +1 -0
- package/src/executors/stage.d.ts +163 -0
- package/src/executors/stage.js +526 -0
- package/src/executors/stage.js.map +1 -0
- package/src/executors/staged-run.d.ts +24 -0
- package/src/executors/staged-run.js +110 -0
- package/src/executors/staged-run.js.map +1 -0
- package/src/executors/task-env.d.ts +271 -0
- package/src/executors/task-env.js +494 -0
- package/src/executors/task-env.js.map +1 -0
- package/src/executors/task-execution.d.ts +61 -0
- package/src/executors/task-execution.js +122 -0
- package/src/executors/task-execution.js.map +1 -0
- package/src/executors/task-guards.d.ts +112 -0
- package/src/executors/task-guards.js +430 -0
- package/src/executors/task-guards.js.map +1 -0
- package/src/executors/task-options.d.ts +114 -0
- package/src/executors/task-options.js +258 -0
- package/src/executors/task-options.js.map +1 -0
- package/src/executors/task.d.ts +166 -0
- package/src/executors/task.js +520 -0
- package/src/executors/task.js.map +1 -0
- package/src/executors/test-mode.d.ts +182 -0
- package/src/executors/test-mode.js +391 -0
- package/src/executors/test-mode.js.map +1 -0
- package/src/executors/test-runner.d.ts +44 -0
- package/src/executors/test-runner.js +159 -0
- package/src/executors/test-runner.js.map +1 -0
- package/src/executors/test-steps.d.ts +109 -0
- package/src/executors/test-steps.js +535 -0
- package/src/executors/test-steps.js.map +1 -0
- package/src/executors/wasm-build.d.ts +56 -0
- package/src/executors/wasm-build.js +216 -0
- package/src/executors/wasm-build.js.map +1 -0
- package/src/generators/crate/binary.schema.json +28 -0
- package/src/generators/crate/crate.d.ts +24 -0
- package/src/generators/crate/crate.js +108 -0
- package/src/generators/crate/crate.js.map +1 -0
- package/src/generators/crate/enclosing-workspace.d.ts +25 -0
- package/src/generators/crate/enclosing-workspace.js +58 -0
- package/src/generators/crate/enclosing-workspace.js.map +1 -0
- package/src/generators/crate/library.schema.json +28 -0
- package/src/generators/init/graph-check.d.ts +81 -0
- package/src/generators/init/graph-check.js +299 -0
- package/src/generators/init/graph-check.js.map +1 -0
- package/src/generators/init/init.d.ts +23 -0
- package/src/generators/init/init.js +113 -0
- package/src/generators/init/init.js.map +1 -0
- package/src/generators/init/report.d.ts +19 -0
- package/src/generators/init/report.js +93 -0
- package/src/generators/init/report.js.map +1 -0
- package/src/generators/init/schema.json +9 -0
- package/src/graph/artifact-kinds.d.ts +29 -0
- package/src/graph/artifact-kinds.js +50 -0
- package/src/graph/artifact-kinds.js.map +1 -0
- package/src/graph/artifact-names.d.ts +97 -0
- package/src/graph/artifact-names.js +276 -0
- package/src/graph/artifact-names.js.map +1 -0
- package/src/graph/build-records.d.ts +74 -0
- package/src/graph/build-records.js +104 -0
- package/src/graph/build-records.js.map +1 -0
- package/src/graph/caching.d.ts +148 -0
- package/src/graph/caching.js +676 -0
- package/src/graph/caching.js.map +1 -0
- package/src/graph/collisions.d.ts +106 -0
- package/src/graph/collisions.js +156 -0
- package/src/graph/collisions.js.map +1 -0
- package/src/graph/computation-reports.d.ts +89 -0
- package/src/graph/computation-reports.js +216 -0
- package/src/graph/computation-reports.js.map +1 -0
- package/src/graph/declared-files.d.ts +190 -0
- package/src/graph/declared-files.js +600 -0
- package/src/graph/declared-files.js.map +1 -0
- package/src/graph/discovery.d.ts +175 -0
- package/src/graph/discovery.js +656 -0
- package/src/graph/discovery.js.map +1 -0
- package/src/graph/edges.d.ts +25 -0
- package/src/graph/edges.js +94 -0
- package/src/graph/edges.js.map +1 -0
- package/src/graph/entries.d.ts +83 -0
- package/src/graph/entries.js +259 -0
- package/src/graph/entries.js.map +1 -0
- package/src/graph/inputs.d.ts +420 -0
- package/src/graph/inputs.js +746 -0
- package/src/graph/inputs.js.map +1 -0
- package/src/graph/lockfile-task.d.ts +74 -0
- package/src/graph/lockfile-task.js +105 -0
- package/src/graph/lockfile-task.js.map +1 -0
- package/src/graph/names.d.ts +41 -0
- package/src/graph/names.js +34 -0
- package/src/graph/names.js.map +1 -0
- package/src/graph/napi.d.ts +107 -0
- package/src/graph/napi.js +206 -0
- package/src/graph/napi.js.map +1 -0
- package/src/graph/nx-glob.d.ts +36 -0
- package/src/graph/nx-glob.js +152 -0
- package/src/graph/nx-glob.js.map +1 -0
- package/src/graph/nx-internals.d.ts +57 -0
- package/src/graph/nx-internals.js +128 -0
- package/src/graph/nx-internals.js.map +1 -0
- package/src/graph/options.d.ts +32 -0
- package/src/graph/options.js +80 -0
- package/src/graph/options.js.map +1 -0
- package/src/graph/outputs.d.ts +75 -0
- package/src/graph/outputs.js +140 -0
- package/src/graph/outputs.js.map +1 -0
- package/src/graph/path-dependencies.d.ts +122 -0
- package/src/graph/path-dependencies.js +459 -0
- package/src/graph/path-dependencies.js.map +1 -0
- package/src/graph/plugin-package.d.ts +36 -0
- package/src/graph/plugin-package.js +132 -0
- package/src/graph/plugin-package.js.map +1 -0
- package/src/graph/plugin-version.d.ts +20 -0
- package/src/graph/plugin-version.js +153 -0
- package/src/graph/plugin-version.js.map +1 -0
- package/src/graph/projects.d.ts +141 -0
- package/src/graph/projects.js +182 -0
- package/src/graph/projects.js.map +1 -0
- package/src/graph/reached-projects.d.ts +46 -0
- package/src/graph/reached-projects.js +102 -0
- package/src/graph/reached-projects.js.map +1 -0
- package/src/graph/real-path.d.ts +47 -0
- package/src/graph/real-path.js +113 -0
- package/src/graph/real-path.js.map +1 -0
- package/src/graph/redirected-uses.d.ts +98 -0
- package/src/graph/redirected-uses.js +434 -0
- package/src/graph/redirected-uses.js.map +1 -0
- package/src/graph/registration.d.ts +121 -0
- package/src/graph/registration.js +233 -0
- package/src/graph/registration.js.map +1 -0
- package/src/graph/script-input.d.ts +46 -0
- package/src/graph/script-input.js +65 -0
- package/src/graph/script-input.js.map +1 -0
- package/src/graph/settings.d.ts +178 -0
- package/src/graph/settings.js +479 -0
- package/src/graph/settings.js.map +1 -0
- package/src/graph/target-defaults-causes.d.ts +33 -0
- package/src/graph/target-defaults-causes.js +202 -0
- package/src/graph/target-defaults-causes.js.map +1 -0
- package/src/graph/target-defaults-layers.d.ts +186 -0
- package/src/graph/target-defaults-layers.js +420 -0
- package/src/graph/target-defaults-layers.js.map +1 -0
- package/src/graph/target-defaults-meaning.d.ts +95 -0
- package/src/graph/target-defaults-meaning.js +292 -0
- package/src/graph/target-defaults-meaning.js.map +1 -0
- package/src/graph/target-defaults-report.d.ts +77 -0
- package/src/graph/target-defaults-report.js +242 -0
- package/src/graph/target-defaults-report.js.map +1 -0
- package/src/graph/target-defaults.d.ts +79 -0
- package/src/graph/target-defaults.js +425 -0
- package/src/graph/target-defaults.js.map +1 -0
- package/src/graph/target-fields.d.ts +16 -0
- package/src/graph/target-fields.js +134 -0
- package/src/graph/target-fields.js.map +1 -0
- package/src/graph/target-tables.d.ts +45 -0
- package/src/graph/target-tables.js +299 -0
- package/src/graph/target-tables.js.map +1 -0
- package/src/graph/targets.d.ts +367 -0
- package/src/graph/targets.js +404 -0
- package/src/graph/targets.js.map +1 -0
- package/src/graph/unification.d.ts +141 -0
- package/src/graph/unification.js +459 -0
- package/src/graph/unification.js.map +1 -0
- package/src/graph/unignored-directories.d.ts +25 -0
- package/src/graph/unignored-directories.js +89 -0
- package/src/graph/unignored-directories.js.map +1 -0
- package/src/graph/visibility.d.ts +17 -0
- package/src/graph/visibility.js +67 -0
- package/src/graph/visibility.js.map +1 -0
- package/src/graph/warnings.d.ts +38 -0
- package/src/graph/warnings.js +77 -0
- package/src/graph/warnings.js.map +1 -0
- package/src/graph/wasm.d.ts +56 -0
- package/src/graph/wasm.js +77 -0
- package/src/graph/wasm.js.map +1 -0
- package/src/index.d.ts +68 -0
- package/src/index.js +109 -0
- package/src/index.js.map +1 -0
- package/src/release/manifests.d.ts +95 -0
- package/src/release/manifests.js +164 -0
- package/src/release/manifests.js.map +1 -0
- package/src/release/places.d.ts +127 -0
- package/src/release/places.js +368 -0
- package/src/release/places.js.map +1 -0
- package/src/release/publish-cargo.d.ts +177 -0
- package/src/release/publish-cargo.js +351 -0
- package/src/release/publish-cargo.js.map +1 -0
- package/src/release/publish-crates.d.ts +124 -0
- package/src/release/publish-crates.js +242 -0
- package/src/release/publish-crates.js.map +1 -0
- package/src/release/publish-environments.d.ts +50 -0
- package/src/release/publish-environments.js +284 -0
- package/src/release/publish-environments.js.map +1 -0
- package/src/release/publish-messages.d.ts +66 -0
- package/src/release/publish-messages.js +273 -0
- package/src/release/publish-messages.js.map +1 -0
- package/src/release/publish-registry.d.ts +27 -0
- package/src/release/publish-registry.js +135 -0
- package/src/release/publish-registry.js.map +1 -0
- package/src/release/publish-settings.d.ts +26 -0
- package/src/release/publish-settings.js +56 -0
- package/src/release/publish-settings.js.map +1 -0
- package/src/release/publish.d.ts +59 -0
- package/src/release/publish.js +620 -0
- package/src/release/publish.js.map +1 -0
- package/src/release/repository.d.ts +73 -0
- package/src/release/repository.js +219 -0
- package/src/release/repository.js.map +1 -0
- package/src/release/requirements.d.ts +34 -0
- package/src/release/requirements.js +30 -0
- package/src/release/requirements.js.map +1 -0
- package/src/release/toml-edit.d.ts +67 -0
- package/src/release/toml-edit.js +453 -0
- package/src/release/toml-edit.js.map +1 -0
- package/src/release/version-actions.d.ts +133 -0
- package/src/release/version-actions.js +474 -0
- package/src/release/version-actions.js.map +1 -0
- package/src/release/version-checks.d.ts +21 -0
- package/src/release/version-checks.js +151 -0
- package/src/release/version-checks.js.map +1 -0
- package/src/release/version-lockfiles.d.ts +61 -0
- package/src/release/version-lockfiles.js +222 -0
- package/src/release/version-lockfiles.js.map +1 -0
- package/src/tools/napi-cli.d.ts +70 -0
- package/src/tools/napi-cli.js +63 -0
- package/src/tools/napi-cli.js.map +1 -0
- package/src/tools/optional-tools.d.ts +121 -0
- package/src/tools/optional-tools.js +303 -0
- package/src/tools/optional-tools.js.map +1 -0
- package/src/tools/print-napi-cli.d.ts +1 -0
- package/src/tools/print-napi-cli.js +24 -0
- package/src/tools/print-napi-cli.js.map +1 -0
|
@@ -0,0 +1,646 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.plainLine = plainLine;
|
|
4
|
+
exports.commandEnd = commandEnd;
|
|
5
|
+
exports.failEvery = failEvery;
|
|
6
|
+
exports.targetClass = targetClass;
|
|
7
|
+
exports.expectedUnits = expectedUnits;
|
|
8
|
+
exports.outsideMembers = outsideMembers;
|
|
9
|
+
exports.readJsonStep = readJsonStep;
|
|
10
|
+
exports.readTestStep = readTestStep;
|
|
11
|
+
exports.startsBlock = startsBlock;
|
|
12
|
+
exports.packageName = packageName;
|
|
13
|
+
exports.describeList = describeList;
|
|
14
|
+
exports.reportedCdylibFiles = reportedCdylibFiles;
|
|
15
|
+
const node_path_1 = require("node:path");
|
|
16
|
+
const build_records_1 = require("./build-records");
|
|
17
|
+
/**
|
|
18
|
+
* Escape sequences that a terminal reads: CSI sequences such as colours, and
|
|
19
|
+
* OSC sequences such as hyperlinks, which cargo writes where
|
|
20
|
+
* `CARGO_TERM_COLOR=always` or `term.hyperlinks` asks for them.
|
|
21
|
+
*/
|
|
22
|
+
// eslint-disable-next-line no-control-regex
|
|
23
|
+
const escapeSequences = /\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g;
|
|
24
|
+
/**
|
|
25
|
+
* A line of cargo's human-readable output without terminal escape
|
|
26
|
+
* sequences, which the reading matches, while a task's output keeps the
|
|
27
|
+
* line as cargo wrote it: cargo colours its status lines, errors and lists
|
|
28
|
+
* where `CARGO_TERM_COLOR=always` asks it to, as CI configurations set it.
|
|
29
|
+
* JSON messages are written without them.
|
|
30
|
+
*/
|
|
31
|
+
function plainLine(line) {
|
|
32
|
+
return line.includes("\u001b") ? line.replace(escapeSequences, "") : line;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* How a cargo command ended ({@link CommandEnd}), from its exit status and
|
|
36
|
+
* signal, or from why it did not start.
|
|
37
|
+
*/
|
|
38
|
+
function commandEnd(code, signal, failure) {
|
|
39
|
+
if (failure === undefined && signal === null && code === 0) {
|
|
40
|
+
return { kind: "succeeded" };
|
|
41
|
+
}
|
|
42
|
+
if (failure === undefined && signal === null && code === 101) {
|
|
43
|
+
return { kind: "failed" };
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
kind: "unexplained",
|
|
47
|
+
reason: failure !== null && failure !== void 0 ? failure : (signal !== null
|
|
48
|
+
? `cargo was stopped by ${signal}`
|
|
49
|
+
: `cargo exited with status ${code}, which is neither success nor the status of a command that failed`),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Fails every crate of a command whose output the reading cannot trust, with
|
|
54
|
+
* a message that says why ({@link readJsonStep}, {@link readTestStep}).
|
|
55
|
+
*/
|
|
56
|
+
function failEvery(crates, parts, why) {
|
|
57
|
+
return crates.map((crate, index) => {
|
|
58
|
+
var _a;
|
|
59
|
+
return ({
|
|
60
|
+
passed: false,
|
|
61
|
+
output: (_a = parts[index]) !== null && _a !== void 0 ? _a : "",
|
|
62
|
+
message: `${crate.task}: ${why}, so the output does not show that ${crate.name} passed. Unknown counts as failed: run the task again, or with --batch=false to see cargo's own result for its crate.`,
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/** The class of a target, from its `kind` list in a `cargo metadata` report or a JSON message. */
|
|
67
|
+
function targetClass(kind) {
|
|
68
|
+
for (const name of ["bin", "test", "example", "bench", "custom-build"]) {
|
|
69
|
+
if (kind.includes(name)) {
|
|
70
|
+
return name;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return "lib";
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The units of a crate that a `build`, `check` or `clippy` command builds
|
|
77
|
+
* whatever else it selects (`DES-BATCH`, "Builds, checks and clippy"): of
|
|
78
|
+
* the crate's library, binaries, tests, examples and benchmarks, those that
|
|
79
|
+
* the command's flags select and whose required features the task's own
|
|
80
|
+
* selection turns on.
|
|
81
|
+
*
|
|
82
|
+
* Without `--all-targets`, that is the library and the binaries. With it,
|
|
83
|
+
* cargo 1.91.0 and 1.100.0 also compile the examples, and compile as a test
|
|
84
|
+
* every target that `--tests` or `--benches` selects: the library and each
|
|
85
|
+
* binary, test and example whose `test` flag is on, and the library, each
|
|
86
|
+
* binary and each bench target whose `bench` flag is on. The report does
|
|
87
|
+
* not give the `bench` flag, which is on by default for these three kinds,
|
|
88
|
+
* so the library, the binaries and the bench targets count as compiled as
|
|
89
|
+
* tests whatever their flags say. That can only fail a task whose crate
|
|
90
|
+
* turned both flags off, and only when the command fails, while leaving out
|
|
91
|
+
* a unit could pass a task whose test units cargo never reached, as when a
|
|
92
|
+
* dev-dependency does not compile and the crate has no other test target.
|
|
93
|
+
*/
|
|
94
|
+
// @mara implements DES-BATCH
|
|
95
|
+
function expectedUnits(pkg, allTargets, selection) {
|
|
96
|
+
var _a;
|
|
97
|
+
const enabled = (0, build_records_1.enabledFeatures)(pkg.name, (_a = pkg.features) !== null && _a !== void 0 ? _a : {}, selection, optionalDependencies(pkg));
|
|
98
|
+
const turnedOn = (target) => { var _a; return ((_a = target["required-features"]) !== null && _a !== void 0 ? _a : []).every((feature) => enabled.has(feature)); };
|
|
99
|
+
const units = [];
|
|
100
|
+
for (const target of pkg.targets) {
|
|
101
|
+
const kind = targetClass(target.kind);
|
|
102
|
+
if (kind === "custom-build" || !turnedOn(target)) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
const normal = kind === "lib" || kind === "bin" || (allTargets && kind === "example");
|
|
106
|
+
if (normal) {
|
|
107
|
+
units.push({ name: target.name, kind, test: false });
|
|
108
|
+
}
|
|
109
|
+
if (!allTargets) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const testFlag = target.test !== false;
|
|
113
|
+
const asTest = kind === "lib" ||
|
|
114
|
+
kind === "bin" ||
|
|
115
|
+
kind === "bench" ||
|
|
116
|
+
((kind === "test" || kind === "example") && testFlag);
|
|
117
|
+
if (asTest) {
|
|
118
|
+
units.push({ name: target.name, kind, test: true });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return units;
|
|
122
|
+
}
|
|
123
|
+
// The names under which the crate lists its optional dependencies that no
|
|
124
|
+
// platform limits, as `buildRecordSource` gives them for the build records.
|
|
125
|
+
function optionalDependencies(pkg) {
|
|
126
|
+
return [
|
|
127
|
+
...new Set(pkg.dependencies
|
|
128
|
+
.filter((dependency) => dependency.optional === true && !dependency.target)
|
|
129
|
+
.map((dependency) => { var _a; return (_a = dependency.rename) !== null && _a !== void 0 ? _a : dependency.name; })),
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
/** The members outside the group of `crates` ({@link OutsideMembers}); none without a scope. */
|
|
133
|
+
function outsideMembers(crates, scope) {
|
|
134
|
+
var _a;
|
|
135
|
+
const inGroup = new Set(crates.map((crate) => crate.spec));
|
|
136
|
+
const members = ((_a = scope === null || scope === void 0 ? void 0 : scope.members) !== null && _a !== void 0 ? _a : []).filter((member) => !inGroup.has(member.id));
|
|
137
|
+
const folders = members
|
|
138
|
+
.map((member) => ({ member, folder: (0, node_path_1.resolve)((0, node_path_1.dirname)(member.manifest_path)) }))
|
|
139
|
+
.sort((a, b) => b.folder.length - a.folder.length);
|
|
140
|
+
const atPath = (path) => {
|
|
141
|
+
var _a, _b;
|
|
142
|
+
const file = (0, node_path_1.resolve)((_a = scope === null || scope === void 0 ? void 0 : scope.root) !== null && _a !== void 0 ? _a : ".", path);
|
|
143
|
+
// The deepest member folder that holds the file, among every member, so
|
|
144
|
+
// that a member nested in another's folder is told apart.
|
|
145
|
+
const all = ((_b = scope === null || scope === void 0 ? void 0 : scope.members) !== null && _b !== void 0 ? _b : [])
|
|
146
|
+
.map((member) => ({ member, folder: (0, node_path_1.resolve)((0, node_path_1.dirname)(member.manifest_path)) }))
|
|
147
|
+
.sort((a, b) => b.folder.length - a.folder.length);
|
|
148
|
+
const holder = all.find(({ folder }) => file === folder || file.startsWith(folder.endsWith(node_path_1.sep) ? folder : folder + node_path_1.sep));
|
|
149
|
+
return holder !== undefined && !inGroup.has(holder.member.id) ? holder.member : undefined;
|
|
150
|
+
};
|
|
151
|
+
return {
|
|
152
|
+
ids: new Set(members.map((member) => member.id)),
|
|
153
|
+
names: new Set(members.map((member) => member.name)),
|
|
154
|
+
atPath,
|
|
155
|
+
ownsLine: (raw) => {
|
|
156
|
+
var _a;
|
|
157
|
+
const line = plainLine(raw);
|
|
158
|
+
const status = /^\s*[A-Z][a-z]+ (\S+) v\S+ \(([^)]+)\)/.exec(line);
|
|
159
|
+
if (status !== null) {
|
|
160
|
+
return folders.some(({ member, folder }) => member.name === status[1] && folder === (0, node_path_1.resolve)(status[2]));
|
|
161
|
+
}
|
|
162
|
+
const summary = (_a = /^warning: `([^`]+)` \(/.exec(line)) !== null && _a !== void 0 ? _a : /^\s*-->\s+(.+?):\d+:\d+$/.exec(line);
|
|
163
|
+
if (summary === null) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
return line.includes("-->")
|
|
167
|
+
? atPath(summary[1]) !== undefined
|
|
168
|
+
: members.some((member) => member.name === summary[1]);
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
// The command's output, line by line, with each line that holds a JSON
|
|
173
|
+
// message of cargo parsed.
|
|
174
|
+
function outputLines(output) {
|
|
175
|
+
const lines = output.split("\n");
|
|
176
|
+
if (lines.at(-1) === "") {
|
|
177
|
+
lines.pop();
|
|
178
|
+
}
|
|
179
|
+
return lines.map((line) => {
|
|
180
|
+
if (line.startsWith('{"reason":')) {
|
|
181
|
+
try {
|
|
182
|
+
return { json: JSON.parse(line) };
|
|
183
|
+
}
|
|
184
|
+
catch (_a) {
|
|
185
|
+
return { malformed: line };
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return { text: line };
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Reads the output of a `build`, `check` or `clippy` command with
|
|
193
|
+
* `--keep-going` and `--message-format=json` that selected several crates
|
|
194
|
+
* (`DES-BATCH`, "Builds, checks and clippy"; `EVD-CARGO-BATCH-FAILURES`).
|
|
195
|
+
*
|
|
196
|
+
* The output counts only where it is whole: every crate fails, with a
|
|
197
|
+
* message that says why, where cargo ended in a way that the reading cannot
|
|
198
|
+
* explain ({@link CommandEnd}), where a line that starts as a JSON message is
|
|
199
|
+
* none, as one cut short, where the messages end without `build-finished`,
|
|
200
|
+
* which cargo prints last, or where that message contradicts the exit
|
|
201
|
+
* status. Unknown counts as failed.
|
|
202
|
+
*
|
|
203
|
+
* When cargo succeeded, every crate passed. Otherwise a crate passes only
|
|
204
|
+
* when the messages report an artifact for each of its {@link expectedUnits}
|
|
205
|
+
* and no error for any of its targets. A failed crate's message names its
|
|
206
|
+
* units that cargo did not report and the crates that cargo reported as
|
|
207
|
+
* failed, by their errors, the build scripts that failed and the crates that
|
|
208
|
+
* did not compile; a crate that fails because it needs one of them has no
|
|
209
|
+
* error of its own. Where cargo failed and every crate passed, each gets a
|
|
210
|
+
* warning that cargo failed outside them.
|
|
211
|
+
*
|
|
212
|
+
* Each crate's output holds, in order, the rendered diagnostics of its own
|
|
213
|
+
* package, and every line of text and every diagnostic of another package
|
|
214
|
+
* that the output does not attribute to another crate of the command.
|
|
215
|
+
*
|
|
216
|
+
* @param allTargets Whether the command passed `--all-targets`.
|
|
217
|
+
* @param libraryOnly Whether the command passed `--lib`, as the compile of
|
|
218
|
+
* `wasm-build` does, so that it builds no binary (`DES-WASM`).
|
|
219
|
+
*/
|
|
220
|
+
// @mara implements DES-BATCH
|
|
221
|
+
function readJsonStep(output, end, crates, allTargets, scope, libraryOnly = false) {
|
|
222
|
+
var _a, _b, _c, _d, _e, _f;
|
|
223
|
+
const lines = outputLines(output);
|
|
224
|
+
// The members outside the group, whose own lines no task shows.
|
|
225
|
+
const outside = outsideMembers(crates, scope);
|
|
226
|
+
const messages = lines.flatMap((line) => ("json" in line ? [line.json] : []));
|
|
227
|
+
const bySpec = new Map(crates.map((crate, index) => [crate.spec, index]));
|
|
228
|
+
// The packages that the messages name, by their names, to tell where a
|
|
229
|
+
// line of text that names a package by its name alone is ambiguous.
|
|
230
|
+
const idsByName = new Map();
|
|
231
|
+
for (const message of messages) {
|
|
232
|
+
if (typeof message.package_id === "string") {
|
|
233
|
+
const name = packageName(message.package_id);
|
|
234
|
+
idsByName.set(name, ((_a = idsByName.get(name)) !== null && _a !== void 0 ? _a : new Set()).add(message.package_id));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const owner = textOwner(crates, idsByName);
|
|
238
|
+
const parts = crates.map(() => []);
|
|
239
|
+
const everyone = (text) => parts.forEach((part) => part.push(text));
|
|
240
|
+
let current;
|
|
241
|
+
let dropped = false;
|
|
242
|
+
for (const line of lines) {
|
|
243
|
+
if ("malformed" in line) {
|
|
244
|
+
everyone(line.malformed);
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
if ("json" in line) {
|
|
248
|
+
const { json } = line;
|
|
249
|
+
const rendered = json.reason === "compiler-message" ? (_b = json.message) === null || _b === void 0 ? void 0 : _b.rendered : undefined;
|
|
250
|
+
if (typeof rendered === "string" && rendered !== "") {
|
|
251
|
+
const index = bySpec.get((_c = json.package_id) !== null && _c !== void 0 ? _c : "");
|
|
252
|
+
const text = rendered.replace(/\n$/, "");
|
|
253
|
+
if (index !== undefined) {
|
|
254
|
+
parts[index].push(text);
|
|
255
|
+
}
|
|
256
|
+
else if (!outside.ids.has((_d = json.package_id) !== null && _d !== void 0 ? _d : "") ||
|
|
257
|
+
((_f = (_e = json.message) === null || _e === void 0 ? void 0 : _e.level) !== null && _f !== void 0 ? _f : "").startsWith("error")) {
|
|
258
|
+
// A member outside the group shows only its errors, which can
|
|
259
|
+
// explain why a task that needs it fails.
|
|
260
|
+
everyone(text);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
if (startsBlock(line.text)) {
|
|
266
|
+
current = owner(line.text);
|
|
267
|
+
dropped =
|
|
268
|
+
current === undefined &&
|
|
269
|
+
!plainLine(line.text).startsWith("error") &&
|
|
270
|
+
outside.ownsLine(line.text);
|
|
271
|
+
}
|
|
272
|
+
if (dropped) {
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
if (current === undefined) {
|
|
276
|
+
everyone(line.text);
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
parts[current].push(line.text);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
const texts = parts.map((part) => part.join("\n"));
|
|
283
|
+
if (end.kind === "unexplained") {
|
|
284
|
+
return failEvery(crates, texts, end.reason);
|
|
285
|
+
}
|
|
286
|
+
if (lines.some((line) => "malformed" in line)) {
|
|
287
|
+
return failEvery(crates, texts, "a line of cargo's JSON messages is cut short or malformed");
|
|
288
|
+
}
|
|
289
|
+
const finished = messages.filter((message) => message.reason === "build-finished");
|
|
290
|
+
if (finished.length !== 1) {
|
|
291
|
+
return failEvery(crates, texts, finished.length === 0
|
|
292
|
+
? "cargo's JSON messages end without build-finished, which cargo prints when the build has ended"
|
|
293
|
+
: "cargo's JSON messages hold build-finished more than once");
|
|
294
|
+
}
|
|
295
|
+
const reported = finished[0].success;
|
|
296
|
+
if (reported !== (end.kind === "succeeded")) {
|
|
297
|
+
return failEvery(crates, texts, `cargo's build-finished message says success: ${JSON.stringify(reported)}, while cargo ${end.kind === "succeeded" ? "succeeded" : "failed"}`);
|
|
298
|
+
}
|
|
299
|
+
const failed = failedPackages(lines);
|
|
300
|
+
return crates.map((crate, index) => {
|
|
301
|
+
var _a;
|
|
302
|
+
const text = texts[index];
|
|
303
|
+
if (end.kind === "succeeded") {
|
|
304
|
+
return { passed: true, output: text };
|
|
305
|
+
}
|
|
306
|
+
const errors = messages.some((message) => {
|
|
307
|
+
var _a, _b;
|
|
308
|
+
return message.reason === "compiler-message" &&
|
|
309
|
+
message.package_id === crate.spec &&
|
|
310
|
+
((_b = (_a = message.message) === null || _a === void 0 ? void 0 : _a.level) !== null && _b !== void 0 ? _b : "").startsWith("error");
|
|
311
|
+
});
|
|
312
|
+
const built = messages.filter((message) => message.reason === "compiler-artifact" && message.package_id === crate.spec);
|
|
313
|
+
const missing = (_a = (crate.package === undefined
|
|
314
|
+
? undefined
|
|
315
|
+
: expectedUnits(crate.package, allTargets, crate.selection).filter((unit) => !libraryOnly || unit.kind === "lib"))) === null || _a === void 0 ? void 0 : _a.filter((unit) => !built.some((message) => {
|
|
316
|
+
var _a, _b, _c, _d;
|
|
317
|
+
return ((_a = message.target) === null || _a === void 0 ? void 0 : _a.name) === unit.name &&
|
|
318
|
+
targetClass((_c = (_b = message.target) === null || _b === void 0 ? void 0 : _b.kind) !== null && _c !== void 0 ? _c : []) === unit.kind &&
|
|
319
|
+
(((_d = message.profile) === null || _d === void 0 ? void 0 : _d.test) === true) === unit.test;
|
|
320
|
+
}));
|
|
321
|
+
if (missing !== undefined && missing.length === 0 && !errors) {
|
|
322
|
+
const beyond = failed.filter((name) => outside.names.has(name.slice(1, -1)));
|
|
323
|
+
return {
|
|
324
|
+
passed: true,
|
|
325
|
+
output: text,
|
|
326
|
+
message: `${crate.task}: cargo failed, but not for ${crate.name}: its output shows every target of ${crate.name} that this task builds as built, and no error in it.${failed.length === 0 ? "" : ` cargo reported ${describeList(failed)} as failed.`}${beyond.length === 0 ? "" : ` ${describeList(beyond)} ${beyond.length === 1 ? "is" : "are"} outside the selection of this run: under workspace-build, every cargo command builds the whole workspace, and a failure in a crate that no task of the run needs fails no task.`}`,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
const why = missing === undefined
|
|
330
|
+
? `@convesoft/nx-rust does not know the targets of ${crate.name}, so the output cannot show that they were built`
|
|
331
|
+
: [
|
|
332
|
+
...(errors ? [`cargo reported errors in ${crate.name}`] : []),
|
|
333
|
+
...(missing.length > 0
|
|
334
|
+
? [
|
|
335
|
+
`cargo did not report ${missing.length === 1 ? "this target" : "these targets"} of ${crate.name} as built: ${missing.map(describeUnit).join(", ")}`,
|
|
336
|
+
]
|
|
337
|
+
: []),
|
|
338
|
+
].join(", and ");
|
|
339
|
+
const cause = failed.length === 0
|
|
340
|
+
? "cargo's output names no crate that failed."
|
|
341
|
+
: `cargo reported ${describeList(failed)} as failed: a task fails when its own crate fails or when it needs a crate that failed.`;
|
|
342
|
+
return {
|
|
343
|
+
passed: false,
|
|
344
|
+
output: text,
|
|
345
|
+
message: `${crate.task}: ${why}. ${cause}`,
|
|
346
|
+
};
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Reads the output of a `cargo test --no-fail-fast` that selected several
|
|
351
|
+
* crates (`DES-TEST-RUN`, "Attributing the output of `cargo test`";
|
|
352
|
+
* `EVD-CARGO-BATCH-FAILURES`).
|
|
353
|
+
*
|
|
354
|
+
* The output counts only where it is whole: every crate fails, with a
|
|
355
|
+
* message that says why, where cargo ended in a way that the reading cannot
|
|
356
|
+
* explain ({@link CommandEnd}), or where the list of failed targets that
|
|
357
|
+
* ends the output is not exactly what its first line announces, as when
|
|
358
|
+
* cargo was stopped while it printed it, or a line after it is no entry of
|
|
359
|
+
* the list. Only that last list counts: a line that a test prints, which
|
|
360
|
+
* looks like the first line of a list, earlier in the output changes
|
|
361
|
+
* nothing. Unknown counts as failed.
|
|
362
|
+
*
|
|
363
|
+
* When cargo succeeded, every crate passed. When it failed and printed its
|
|
364
|
+
* list of failed targets, which names each package by its bare name, the
|
|
365
|
+
* crates that the list names failed and the others passed; a name in the
|
|
366
|
+
* list that is no crate of the command fails every crate, since the output
|
|
367
|
+
* then cannot tell which crate it belongs to. When it failed without the
|
|
368
|
+
* list, as after a compile error, which stops the run before any test runs,
|
|
369
|
+
* every crate failed, and the message names the crates that did not compile
|
|
370
|
+
* and says that the tests of the others were not run.
|
|
371
|
+
*
|
|
372
|
+
* Each block of the output, from a `Running` or `Doc-tests` line to the next,
|
|
373
|
+
* goes to the crates that have a target of the name in its header, or to
|
|
374
|
+
* the crate that its line `to rerun pass \`-p <name> ...\`` names; a block
|
|
375
|
+
* that it cannot attribute to one crate goes to every crate it could
|
|
376
|
+
* belong to, and the lines before the first block and the closing list go
|
|
377
|
+
* to every crate.
|
|
378
|
+
*/
|
|
379
|
+
// @mara implements DES-TEST-RUN
|
|
380
|
+
// @mara implements DES-BATCH
|
|
381
|
+
function readTestStep(output, end, crates) {
|
|
382
|
+
var _a;
|
|
383
|
+
// Test output is text: a test may print anything, a line of JSON included.
|
|
384
|
+
const lines = output.split("\n");
|
|
385
|
+
if (lines.at(-1) === "") {
|
|
386
|
+
lines.pop();
|
|
387
|
+
}
|
|
388
|
+
// Cargo's list of failed targets is the last thing it prints. A test can
|
|
389
|
+
// print a line that looks like its first line, so only the last such line
|
|
390
|
+
// counts, and only where the list after it ends the output.
|
|
391
|
+
const headers = lines.flatMap((line, index) => /^error: \d+ targets? failed:$/.test(plainLine(line)) ? [index] : []);
|
|
392
|
+
const listStart = headers.length === 0 ? -1 : headers[headers.length - 1];
|
|
393
|
+
const body = listStart === -1 ? lines : lines.slice(0, listStart);
|
|
394
|
+
const list = listStart === -1 ? [] : lines.slice(listStart);
|
|
395
|
+
const parts = crates.map(() => []);
|
|
396
|
+
const all = crates.map((_, index) => index);
|
|
397
|
+
let block = [];
|
|
398
|
+
let candidates = all;
|
|
399
|
+
const flush = () => {
|
|
400
|
+
const rerun = block
|
|
401
|
+
.map((line) => { var _a; return (_a = /to rerun pass `-p (\S+)/.exec(plainLine(line))) === null || _a === void 0 ? void 0 : _a[1]; })
|
|
402
|
+
.find((name) => name !== undefined);
|
|
403
|
+
const named = rerun === undefined ? -1 : crates.findIndex((crate) => crate.name === rerun);
|
|
404
|
+
for (const index of named === -1 ? candidates : [named]) {
|
|
405
|
+
parts[index].push(...block);
|
|
406
|
+
}
|
|
407
|
+
block = [];
|
|
408
|
+
};
|
|
409
|
+
for (const line of body) {
|
|
410
|
+
const header = testBlockTarget(line);
|
|
411
|
+
if (header !== undefined) {
|
|
412
|
+
flush();
|
|
413
|
+
const owners = all.filter((index) => hasTarget(crates[index], header));
|
|
414
|
+
candidates = owners.length === 0 ? all : owners;
|
|
415
|
+
}
|
|
416
|
+
block.push(line);
|
|
417
|
+
}
|
|
418
|
+
flush();
|
|
419
|
+
for (const part of parts) {
|
|
420
|
+
part.push(...list);
|
|
421
|
+
}
|
|
422
|
+
const texts = parts.map((part) => part.join("\n"));
|
|
423
|
+
if (end.kind === "unexplained") {
|
|
424
|
+
return failEvery(crates, texts, end.reason);
|
|
425
|
+
}
|
|
426
|
+
// Every line of the list after its first names one failed target, as
|
|
427
|
+
// `-p <package> <target flag>` in backquotes, and there are as many as the
|
|
428
|
+
// first line announces.
|
|
429
|
+
const entries = list
|
|
430
|
+
.slice(1)
|
|
431
|
+
.map(plainLine)
|
|
432
|
+
.filter((line) => line.trim() !== "");
|
|
433
|
+
const announced = listStart === -1 ? 0 : Number((_a = /^error: (\d+)/.exec(plainLine(list[0]))) === null || _a === void 0 ? void 0 : _a[1]);
|
|
434
|
+
const malformed = entries.find((line) => !/^\s+`-p \S+ [^`]+`$/.test(line));
|
|
435
|
+
if (end.kind === "failed" && listStart !== -1 && malformed !== undefined) {
|
|
436
|
+
return failEvery(crates, texts, `the list of failed test targets that ends cargo's output is malformed or does not end it: ${JSON.stringify(malformed)}`);
|
|
437
|
+
}
|
|
438
|
+
if (end.kind === "failed" && listStart !== -1 && entries.length !== announced) {
|
|
439
|
+
return failEvery(crates, texts, `cargo announced ${announced} failed test ${announced === 1 ? "target" : "targets"} and listed ${entries.length}`);
|
|
440
|
+
}
|
|
441
|
+
const failedNames = entries.flatMap((line) => {
|
|
442
|
+
var _a;
|
|
443
|
+
const name = (_a = /^\s+`-p (\S+)/.exec(line)) === null || _a === void 0 ? void 0 : _a[1];
|
|
444
|
+
return name === undefined ? [] : [name];
|
|
445
|
+
});
|
|
446
|
+
const notCompiled = [
|
|
447
|
+
...new Set(lines.flatMap((line) => {
|
|
448
|
+
var _a;
|
|
449
|
+
const name = (_a = /^error: could not compile `([^`]+)`/.exec(plainLine(line))) === null || _a === void 0 ? void 0 : _a[1];
|
|
450
|
+
return name === undefined ? [] : [name];
|
|
451
|
+
})),
|
|
452
|
+
];
|
|
453
|
+
const unknown = failedNames.filter((name) => !crates.some((crate) => crate.name === name));
|
|
454
|
+
return crates.map((crate, index) => {
|
|
455
|
+
const text = texts[index];
|
|
456
|
+
if (end.kind === "succeeded") {
|
|
457
|
+
return { passed: true, output: text };
|
|
458
|
+
}
|
|
459
|
+
if (listStart === -1) {
|
|
460
|
+
return {
|
|
461
|
+
passed: false,
|
|
462
|
+
output: text,
|
|
463
|
+
message: notCompiled.length === 0
|
|
464
|
+
? `${crate.task}: cargo test failed before it printed which test targets failed, so its output does not show whether the tests of ${crate.name} passed.`
|
|
465
|
+
: `${crate.task}: the tests of ${crate.name} were not run: cargo test stopped before running any test, because ${describeList(notCompiled.map((name) => `\`${name}\``))} did not compile. The tests of every crate of this cargo command were not run. Fix the crate that does not compile and run the tasks again.`,
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
if (unknown.length > 0) {
|
|
469
|
+
return {
|
|
470
|
+
passed: false,
|
|
471
|
+
output: text,
|
|
472
|
+
message: `${crate.task}: cargo test reported failed test targets of ${describeList(unknown.map((name) => `\`${name}\``))}, which is no crate of this cargo command, so its output does not show whether the tests of ${crate.name} passed.`,
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
const own = entries.filter((line) => new RegExp(`^\\s+\`-p ${escape(crate.name)} `).test(line));
|
|
476
|
+
return own.length === 0
|
|
477
|
+
? { passed: true, output: text }
|
|
478
|
+
: {
|
|
479
|
+
passed: false,
|
|
480
|
+
output: text,
|
|
481
|
+
message: `${crate.task}: ${own.length === 1 ? "a test target" : `${own.length} test targets`} of ${crate.name} failed: ${own.map((line) => line.trim()).join(", ")}.`,
|
|
482
|
+
};
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
// The target that a line of `cargo test` that starts a block names: the
|
|
486
|
+
// file name of the test executable without its hash, as in `Running
|
|
487
|
+
// unittests src/lib.rs (target/debug/deps/good-1a2b3c)`, or the library of
|
|
488
|
+
// `Doc-tests good`.
|
|
489
|
+
function testBlockTarget(raw) {
|
|
490
|
+
var _a;
|
|
491
|
+
const line = plainLine(raw);
|
|
492
|
+
const doc = /^\s+Doc-tests (\S+)$/.exec(line);
|
|
493
|
+
if (doc !== undefined && doc !== null) {
|
|
494
|
+
return doc[1];
|
|
495
|
+
}
|
|
496
|
+
const running = /^\s+Running .*\(([^()]+)\)$/.exec(line);
|
|
497
|
+
if (running === null) {
|
|
498
|
+
return undefined;
|
|
499
|
+
}
|
|
500
|
+
const file = (_a = running[1].split(/[\\/]/).at(-1)) !== null && _a !== void 0 ? _a : "";
|
|
501
|
+
return file.replace(/\.exe$/, "").replace(/-[0-9a-f]{16}$/, "");
|
|
502
|
+
}
|
|
503
|
+
// Whether a crate has a target whose name, as a test executable or a
|
|
504
|
+
// library's doctests name it, is `name`.
|
|
505
|
+
function hasTarget(crate, name) {
|
|
506
|
+
var _a, _b;
|
|
507
|
+
return ((_b = (_a = crate.package) === null || _a === void 0 ? void 0 : _a.targets) !== null && _b !== void 0 ? _b : []).some((target) => target.name.replace(/-/g, "_") === name.replace(/-/g, "_"));
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Whether a line of cargo's text output starts a block of its own: an
|
|
511
|
+
* error, a warning or a note, or one of cargo's status lines.
|
|
512
|
+
*/
|
|
513
|
+
function startsBlock(raw) {
|
|
514
|
+
const line = plainLine(raw);
|
|
515
|
+
return (/^(error|warning|note)(\[[^\]]*\])?: /.test(line) ||
|
|
516
|
+
/^\s*(Compiling|Checking|Fresh|Finished|Running|Doc-tests|Documenting|Building|Blocking|Downloading|Downloaded|Updating|Locking|Adding|Removing|Packaging|Scraping|Waiting|Dirty|Ignored)\b/.test(line));
|
|
517
|
+
}
|
|
518
|
+
// Which crate of the command a block of text belongs to, from its first
|
|
519
|
+
// line: a status line that names the crate with its folder, or an error or
|
|
520
|
+
// warning that names it in backquotes, such as "could not compile `core`".
|
|
521
|
+
// A name that two packages of the output share, or that the line names
|
|
522
|
+
// without a folder while another package has it, belongs to no one crate.
|
|
523
|
+
function textOwner(crates, idsByName) {
|
|
524
|
+
return (raw) => {
|
|
525
|
+
var _a;
|
|
526
|
+
const line = plainLine(raw);
|
|
527
|
+
const status = /^\s*[A-Z][a-z]+ (\S+) v\S+ \(([^)]+)\)/.exec(line);
|
|
528
|
+
const quoted = /`([A-Za-z0-9_-]+)(?: v[^ `]+(?: \(([^)]+)\))?)?`/.exec(line);
|
|
529
|
+
const match = status !== null && status !== void 0 ? status : quoted;
|
|
530
|
+
if (match === null) {
|
|
531
|
+
return undefined;
|
|
532
|
+
}
|
|
533
|
+
const [, name, folder] = match;
|
|
534
|
+
const index = crates.findIndex((crate) => crate.name === name);
|
|
535
|
+
if (index === -1) {
|
|
536
|
+
return undefined;
|
|
537
|
+
}
|
|
538
|
+
if (folder !== undefined) {
|
|
539
|
+
const manifest = (_a = crates[index].package) === null || _a === void 0 ? void 0 : _a.manifest_path;
|
|
540
|
+
return manifest !== undefined && (0, node_path_1.resolve)((0, node_path_1.dirname)(manifest)) === (0, node_path_1.resolve)(folder)
|
|
541
|
+
? index
|
|
542
|
+
: undefined;
|
|
543
|
+
}
|
|
544
|
+
const ids = idsByName.get(name);
|
|
545
|
+
return ids === undefined || [...ids].every((id) => id === crates[index].spec)
|
|
546
|
+
? index
|
|
547
|
+
: undefined;
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
// The packages that cargo reported as failed: those of its error messages,
|
|
551
|
+
// those whose build script it could not run and those it could not compile,
|
|
552
|
+
// by name, each once, in the order the output names them.
|
|
553
|
+
function failedPackages(lines) {
|
|
554
|
+
var _a, _b, _c;
|
|
555
|
+
const names = [];
|
|
556
|
+
for (const line of lines) {
|
|
557
|
+
if ("json" in line) {
|
|
558
|
+
const { json } = line;
|
|
559
|
+
if (json.reason === "compiler-message" &&
|
|
560
|
+
((_b = (_a = json.message) === null || _a === void 0 ? void 0 : _a.level) !== null && _b !== void 0 ? _b : "").startsWith("error") &&
|
|
561
|
+
typeof json.package_id === "string") {
|
|
562
|
+
names.push(packageName(json.package_id));
|
|
563
|
+
}
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
if (!("text" in line)) {
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
const text = plainLine(line.text);
|
|
570
|
+
const failed = (_c = /^error: failed to run custom build command for `(\S+)/.exec(text)) !== null && _c !== void 0 ? _c : /^error: could not compile `([^`]+)`/.exec(text);
|
|
571
|
+
if (failed !== null) {
|
|
572
|
+
names.push(failed[1]);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
return [...new Set(names)].map((name) => `\`${name}\``);
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* The package name in a package ID specification, as cargo's JSON messages
|
|
579
|
+
* give it: `path+file:///repo/crates/core#core-lib@0.1.0` names `core-lib`,
|
|
580
|
+
* and `path+file:///repo/crates/core#0.1.0` the folder's name, `core`.
|
|
581
|
+
*/
|
|
582
|
+
function packageName(spec) {
|
|
583
|
+
var _a;
|
|
584
|
+
const fragment = spec.includes("#") ? spec.slice(spec.lastIndexOf("#") + 1) : "";
|
|
585
|
+
const at = fragment.lastIndexOf("@");
|
|
586
|
+
if (at > 0) {
|
|
587
|
+
return fragment.slice(0, at);
|
|
588
|
+
}
|
|
589
|
+
if (fragment !== "" && !/^\d/.test(fragment)) {
|
|
590
|
+
return fragment;
|
|
591
|
+
}
|
|
592
|
+
const base = spec.slice(0, spec.includes("#") ? spec.lastIndexOf("#") : undefined);
|
|
593
|
+
return decodeURIComponent((_a = base.split(/[\\/]/).at(-1)) !== null && _a !== void 0 ? _a : base);
|
|
594
|
+
}
|
|
595
|
+
function describeUnit(unit) {
|
|
596
|
+
const target = unit.kind === "lib"
|
|
597
|
+
? "the library"
|
|
598
|
+
: `the ${unit.kind === "bin" ? "binary" : unit.kind} ${unit.name}`;
|
|
599
|
+
return unit.test ? `${target} compiled as a test` : target;
|
|
600
|
+
}
|
|
601
|
+
function describeList(items) {
|
|
602
|
+
var _a;
|
|
603
|
+
return items.length <= 1
|
|
604
|
+
? ((_a = items[0]) !== null && _a !== void 0 ? _a : "")
|
|
605
|
+
: `${items.slice(0, -1).join(", ")} and ${items[items.length - 1]}`;
|
|
606
|
+
}
|
|
607
|
+
function escape(text) {
|
|
608
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* The files that cargo's JSON messages report for each package's `cdylib`
|
|
612
|
+
* target, by the package's ID, as cargo names it in the messages and in
|
|
613
|
+
* `cargo metadata`: the files of the `compiler-artifact` messages whose name
|
|
614
|
+
* matches `file`, fresh units included, which cargo reports as well. Cargo
|
|
615
|
+
* reports each file where it puts it, in the folder of a triple where one is
|
|
616
|
+
* selected, also the host's, so the artifact targets post-process the file
|
|
617
|
+
* of this command, never one at a path that the plugin derives
|
|
618
|
+
* (`DES-NAPI`, `DES-WASM`).
|
|
619
|
+
*/
|
|
620
|
+
function reportedCdylibFiles(output, file) {
|
|
621
|
+
var _a, _b;
|
|
622
|
+
const libraries = new Map();
|
|
623
|
+
for (const line of output.split("\n")) {
|
|
624
|
+
if (!line.startsWith("{")) {
|
|
625
|
+
continue;
|
|
626
|
+
}
|
|
627
|
+
let message;
|
|
628
|
+
try {
|
|
629
|
+
message = JSON.parse(line);
|
|
630
|
+
}
|
|
631
|
+
catch (_c) {
|
|
632
|
+
continue;
|
|
633
|
+
}
|
|
634
|
+
if (message.reason !== "compiler-artifact" ||
|
|
635
|
+
typeof message.package_id !== "string" ||
|
|
636
|
+
!Array.isArray((_a = message.target) === null || _a === void 0 ? void 0 : _a.kind) ||
|
|
637
|
+
!message.target.kind.includes("cdylib") ||
|
|
638
|
+
!Array.isArray(message.filenames)) {
|
|
639
|
+
continue;
|
|
640
|
+
}
|
|
641
|
+
const files = message.filenames.filter((name) => typeof name === "string" && file.test(name));
|
|
642
|
+
libraries.set(message.package_id, [...((_b = libraries.get(message.package_id)) !== null && _b !== void 0 ? _b : []), ...files]);
|
|
643
|
+
}
|
|
644
|
+
return libraries;
|
|
645
|
+
}
|
|
646
|
+
//# sourceMappingURL=cargo-output.js.map
|