@specific.dev/spectest 0.79.2 → 0.81.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.
- package/dist/coverage.d.ts +111 -69
- package/dist/coverage.js +280 -171
- package/dist/daemon.js +24 -14
- package/package.json +1 -1
- package/src/coverage.test.ts +198 -131
- package/src/coverage.ts +320 -177
- package/src/daemon.ts +20 -16
package/src/daemon.ts
CHANGED
|
@@ -53,9 +53,6 @@ import {
|
|
|
53
53
|
coverageAdapters,
|
|
54
54
|
coverageReportsMode,
|
|
55
55
|
validateCoverage,
|
|
56
|
-
nodeCoverageToolsAvailable,
|
|
57
|
-
nodeCoverageToolsDir,
|
|
58
|
-
NODE_COVERAGE_TOOLS_CONTAINER_DIR,
|
|
59
56
|
type CoverageAdapter,
|
|
60
57
|
type CoverageCaptureContext,
|
|
61
58
|
} from "./coverage.js";
|
|
@@ -93,7 +90,7 @@ import {
|
|
|
93
90
|
import { pollUntilReady } from "./harness/ready-poll.js";
|
|
94
91
|
import { runWrapperRules } from "./harness/wrapper-rules.js";
|
|
95
92
|
import type { WrapperDiagnostic } from "./harness/wrapper-rules.js";
|
|
96
|
-
import { cpus } from "node:os";
|
|
93
|
+
import { cpus, tmpdir } from "node:os";
|
|
97
94
|
import { APP_DIR, WORKSPACE, resolveExistingProjectPath, resolveProjectPath } from "./project-files.js";
|
|
98
95
|
import { installFetchWrapper, isTransportError } from "./harness/fetch.js";
|
|
99
96
|
import {
|
|
@@ -979,16 +976,9 @@ async function ensureCoverage(svc: NamedService): Promise<string[]> {
|
|
|
979
976
|
const host = coverageHostDir(WORKSPACE, svc.name);
|
|
980
977
|
await fs.mkdir(host, { recursive: true });
|
|
981
978
|
await fs.chmod(host, 0o777);
|
|
982
|
-
|
|
983
|
-
//
|
|
984
|
-
|
|
985
|
-
// — so the VM and the container agree on whether they are there. A
|
|
986
|
-
// plain `--volume`, never a config `volumes` entry: an absolute-source
|
|
987
|
-
// volume dir is listed in the delta-restore manifest and wiped.
|
|
988
|
-
if (await nodeCoverageToolsAvailable()) {
|
|
989
|
-
flags.push(`--volume=${nodeCoverageToolsDir()}:${NODE_COVERAGE_TOOLS_CONTAINER_DIR}:ro`);
|
|
990
|
-
}
|
|
991
|
-
return flags;
|
|
979
|
+
// Nothing else is mounted: no conversion runs in the container (the
|
|
980
|
+
// c8 tools mount went with SDK 0.80).
|
|
981
|
+
return [`--volume=${host}:${COVERAGE_CONTAINER_DIR}`];
|
|
992
982
|
}
|
|
993
983
|
|
|
994
984
|
/** A `user`/`group` pair resolved to the numeric ids the kernel wants.
|
|
@@ -4062,6 +4052,21 @@ function coverageCaptureContext(
|
|
|
4062
4052
|
await fs.rename(tmp, file);
|
|
4063
4053
|
written.add(path.relative(reportDir, file));
|
|
4064
4054
|
},
|
|
4055
|
+
async readContainerFile(containerPath: string) {
|
|
4056
|
+
// `docker cp` rather than `exec cat`: a source map can be tens of
|
|
4057
|
+
// MB, and the exec path buffers stdout as a string. The copy lands
|
|
4058
|
+
// in the VM's tmp, never in the coverage directory (it would ship).
|
|
4059
|
+
const tmp = path.join(tmpdir(), `spectest-cov-${svc.name}-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`);
|
|
4060
|
+
try {
|
|
4061
|
+
const r = await docker(["cp", `${svc.name}:${containerPath}`, tmp], COVERAGE_CAPTURE_TIMEOUT_MS);
|
|
4062
|
+
if (r.code !== 0) return null;
|
|
4063
|
+
return await fs.readFile(tmp);
|
|
4064
|
+
} catch {
|
|
4065
|
+
return null;
|
|
4066
|
+
} finally {
|
|
4067
|
+
await fs.rm(tmp, { force: true, recursive: true }).catch(() => {});
|
|
4068
|
+
}
|
|
4069
|
+
},
|
|
4065
4070
|
};
|
|
4066
4071
|
}
|
|
4067
4072
|
|
|
@@ -6076,8 +6081,7 @@ async function evalCode(
|
|
|
6076
6081
|
|
|
6077
6082
|
/** Where the baked compiler lives. Overridable so the typecheck — and the
|
|
6078
6083
|
* blocking rules, which always use THIS copy rather than the project's own —
|
|
6079
|
-
* can be driven outside a VM
|
|
6080
|
-
* `SPECTEST_COVERAGE_TOOLS_DIR`). */
|
|
6084
|
+
* can be driven outside a VM. */
|
|
6081
6085
|
const TYPECHECK_DIR = process.env.SPECTEST_TYPECHECK_DIR ?? "/opt/spectest/typecheck";
|
|
6082
6086
|
/** Cap on errors shipped in the report; `totalErrors` carries the true count. */
|
|
6083
6087
|
const TYPECHECK_ERROR_CAP = 50;
|