Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(ci): make rust coverage cargo calls cancellation-aware

Steven Enamakeleccdaff8de7c
diff --git a/scripts/__tests__/rust-coverage-status.test.mjs b/scripts/__tests__/rust-coverage-status.test.mjs
index 8ae0457ef4..f53fd09434 100644
--- a/scripts/__tests__/rust-coverage-status.test.mjs
+++ b/scripts/__tests__/rust-coverage-status.test.mjs
@@ -324,3 +324,9 @@ test("private coverage passes when all eight selected configurations report test
const { status } = runMockedCoverage(0);
assert.equal(status, 0);
});
+
+test("instrumented CLI inventory is cancellation-aware and reuses llvm-cov's environment", () => {
+ assert.match(source, /bash scripts\/ci-cancel-aware\.sh cargo llvm-cov show-env --sh/);
+ assert.match(source, /eval "\$\{inventory_env\}"/);
+ assert.match(source, /bash scripts\/ci-cancel-aware\.sh cargo nextest list --message-format json/);
+});
diff --git a/scripts/ci/nextest-coverage.sh b/scripts/ci/nextest-coverage.sh
index 19aacab10c..3a8c3e2779 100644
--- a/scripts/ci/nextest-coverage.sh
+++ b/scripts/ci/nextest-coverage.sh
@@ -13,12 +13,14 @@ report="${report_dir}/${suite}.xml"
# cleanup. A fresh config retains the repository's timeouts/resource groups.
node - "$config" "$report" "$@" <<'JS'
const fs = require('node:fs');
-const { execFileSync } = require('node:child_process');
+const { spawnSync } = require('node:child_process');
const [config, report, ...command] = process.argv.slice(2);
const manifest = command.indexOf('--manifest-path');
const metadataArgs = ['metadata', '--no-deps', '--format-version', '1'];
if (manifest >= 0) metadataArgs.push('--manifest-path', command[manifest + 1]);
-const metadata = JSON.parse(execFileSync('cargo', metadataArgs, { encoding: 'utf8' }));
+const metadataResult = spawnSync('bash', ['scripts/ci-cancel-aware.sh', 'cargo', ...metadataArgs], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'inherit'] });
+if (metadataResult.status !== 0) process.exit(metadataResult.status ?? 1);
+const metadata = JSON.parse(metadataResult.stdout);
const targets = new Set(metadata.packages.flatMap(pkg => pkg.targets.map(target => target.name)));
// Nextest validates binary predicates against the selected workspace, even
// regex predicates. A standalone Tauri workspace has none of the root CLI's
diff --git a/scripts/ci/rust-coverage.sh b/scripts/ci/rust-coverage.sh
index 7d03936b54..bda3953b65 100755
--- a/scripts/ci/rust-coverage.sh
+++ b/scripts/ci/rust-coverage.sh
@@ -271,9 +271,9 @@ if [ "${OH_COV_RUNNER:-cargo}" = "nextest" ]; then
# Listing executes no tests. cargo-llvm-cov supplies the same wrapper and
# instrumentation environment, so Cargo can reuse this CLI test build.
cli_inventory() (
- inventory_env="$(cargo llvm-cov show-env --sh --features "${CORE_PRODUCT_FEATURES}")" || exit $?
+ inventory_env="$(bash scripts/ci-cancel-aware.sh cargo llvm-cov show-env --sh --features "${CORE_PRODUCT_FEATURES}")" || exit $?
eval "${inventory_env}"
- cargo nextest list --message-format json --features "${CORE_PRODUCT_FEATURES}" \
+ bash scripts/ci-cancel-aware.sh cargo nextest list --message-format json --features "${CORE_PRODUCT_FEATURES}" \
-p openhuman-cli --tests -E 'kind(test)' >"${expected_inventory}"
)
suite "openhuman-cli test inventory" cli_inventory