as-test 1.1.6 → 1.1.8
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/CHANGELOG.md +17 -0
- package/README.md +4 -9
- package/assembly/index.ts +10 -15
- package/assembly/src/expectation.ts +11 -11
- package/assembly/src/fuzz.ts +11 -7
- package/assembly/src/log.ts +2 -2
- package/assembly/src/suite.ts +5 -5
- package/assembly/src/tests.ts +8 -8
- package/assembly/util/wipc.ts +5 -1
- package/bin/build-worker-pool.js +146 -142
- package/bin/build-worker.js +37 -34
- package/bin/commands/build-core.js +577 -465
- package/bin/commands/build.js +49 -29
- package/bin/commands/clean-core.js +120 -113
- package/bin/commands/clean.js +14 -8
- package/bin/commands/doctor-core.js +288 -289
- package/bin/commands/doctor.js +1 -1
- package/bin/commands/fuzz-core.js +467 -414
- package/bin/commands/fuzz.js +27 -10
- package/bin/commands/init-core.js +908 -794
- package/bin/commands/init.js +2 -2
- package/bin/commands/run-core.js +2675 -2344
- package/bin/commands/run.js +43 -25
- package/bin/commands/test.js +56 -32
- package/bin/commands/web-runner-source.js +1 -1
- package/bin/commands/web-session.js +516 -525
- package/bin/coverage-points.js +363 -341
- package/bin/crash-store.js +56 -66
- package/bin/index.js +4092 -3150
- package/bin/reporters/default.js +1090 -890
- package/bin/reporters/tap.js +319 -325
- package/bin/types.js +67 -67
- package/bin/util.js +1290 -1239
- package/bin/wipc.js +70 -73
- package/lib/build/index.d.ts +3 -1
- package/lib/build/index.js +1039 -1034
- package/lib/build/web-runner/client.js +1 -1
- package/lib/build/web-runner/html.js +1 -1
- package/lib/build/web-runner/worker.js +1 -1
- package/package.json +6 -3
- package/transform/lib/log.js +9 -5
- package/assembly/util/json.ts +0 -112
package/bin/commands/build.js
CHANGED
|
@@ -1,32 +1,52 @@
|
|
|
1
|
-
import { closeSerialBuildWorkerPool
|
|
1
|
+
import { closeSerialBuildWorkerPool } from "./build-core.js";
|
|
2
2
|
export { build } from "./build-core.js";
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
3
|
+
export {
|
|
4
|
+
BuildFailureError,
|
|
5
|
+
formatInvocation,
|
|
6
|
+
getBuildInvocationPreview,
|
|
7
|
+
getBuildReuseInfo,
|
|
8
|
+
} from "./build-core.js";
|
|
9
|
+
export async function executeBuildCommand(
|
|
10
|
+
rawArgs,
|
|
11
|
+
configPath,
|
|
12
|
+
selectedModes,
|
|
13
|
+
deps,
|
|
14
|
+
) {
|
|
15
|
+
const commandArgs = deps.resolveCommandArgs(rawArgs, "build");
|
|
16
|
+
const listFlags = deps.resolveListFlags(rawArgs, "build");
|
|
17
|
+
const featureToggles = deps.resolveFeatureToggles(rawArgs, "build");
|
|
18
|
+
const parallel = deps.resolveBuildParallelJobs(rawArgs);
|
|
19
|
+
const buildFeatureToggles = {
|
|
20
|
+
tryAs: featureToggles.tryAs,
|
|
21
|
+
coverage: featureToggles.coverage,
|
|
22
|
+
};
|
|
23
|
+
const modeTargets = deps.resolveExecutionModes(configPath, selectedModes);
|
|
24
|
+
if (listFlags.list || listFlags.listModes) {
|
|
25
|
+
await deps.listExecutionPlan(
|
|
26
|
+
"build",
|
|
27
|
+
configPath,
|
|
28
|
+
commandArgs,
|
|
29
|
+
modeTargets,
|
|
30
|
+
listFlags,
|
|
31
|
+
);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const previousBuildApi = process.env.AS_TEST_BUILD_API;
|
|
35
|
+
process.env.AS_TEST_BUILD_API = "1";
|
|
36
|
+
try {
|
|
37
|
+
await deps.runBuildModes(
|
|
38
|
+
configPath,
|
|
39
|
+
commandArgs,
|
|
40
|
+
modeTargets,
|
|
41
|
+
buildFeatureToggles,
|
|
42
|
+
parallel,
|
|
43
|
+
);
|
|
44
|
+
} finally {
|
|
45
|
+
if (previousBuildApi == undefined) {
|
|
46
|
+
delete process.env.AS_TEST_BUILD_API;
|
|
47
|
+
} else {
|
|
48
|
+
process.env.AS_TEST_BUILD_API = previousBuildApi;
|
|
31
49
|
}
|
|
50
|
+
await closeSerialBuildWorkerPool();
|
|
51
|
+
}
|
|
32
52
|
}
|
|
@@ -3,135 +3,142 @@ import { existsSync, rmSync } from "fs";
|
|
|
3
3
|
import * as path from "path";
|
|
4
4
|
import { applyMode, loadConfig } from "../util.js";
|
|
5
5
|
const DEFAULT_CONFIG_PATH = path.join(process.cwd(), "./as-test.config.json");
|
|
6
|
-
export async function clean(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
6
|
+
export async function clean(
|
|
7
|
+
configPath = DEFAULT_CONFIG_PATH,
|
|
8
|
+
modes = [undefined],
|
|
9
|
+
fullClean = false,
|
|
10
|
+
) {
|
|
11
|
+
const loadedConfig = loadConfig(configPath, true);
|
|
12
|
+
const targets = new Map();
|
|
13
|
+
const ownership = buildOwnershipMap(loadedConfig);
|
|
14
|
+
if (fullClean) {
|
|
15
|
+
collectRootTarget(targets, loadedConfig.outDir, "build");
|
|
16
|
+
collectRootTarget(targets, loadedConfig.fuzz.crashDir, "crashes");
|
|
17
|
+
collectRootTarget(targets, loadedConfig.coverageDir, "coverage");
|
|
18
|
+
collectRootTarget(targets, loadedConfig.logs, "logs");
|
|
19
|
+
for (const modeName of modes) {
|
|
20
|
+
const active = applyMode(loadedConfig, modeName).config;
|
|
21
|
+
collectTarget(targets, active.outDir, modeName, "build");
|
|
22
|
+
collectTarget(targets, active.fuzz.crashDir, modeName, "crashes");
|
|
23
|
+
collectTarget(targets, active.coverageDir, modeName, "coverage");
|
|
24
|
+
collectTarget(targets, active.logs, modeName, "logs");
|
|
23
25
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
pruneNestedTargets(targets);
|
|
27
|
+
} else {
|
|
28
|
+
for (const modeName of modes) {
|
|
29
|
+
const active = applyMode(loadedConfig, modeName).config;
|
|
30
|
+
collectTarget(targets, active.outDir, modeName, "build");
|
|
31
|
+
collectTarget(targets, active.fuzz.crashDir, modeName, "crashes");
|
|
32
|
+
collectTarget(targets, active.coverageDir, modeName, "coverage");
|
|
33
|
+
collectTarget(targets, active.logs, modeName, "logs");
|
|
32
34
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
removed++;
|
|
47
|
-
process.stdout.write(`${chalk.bgGreenBright.black(" CLEAN ")} ${toRelativePath(targetPath)} ${chalk.dim(`(${owners.join(", ")})`)}\n`);
|
|
35
|
+
}
|
|
36
|
+
let removed = 0;
|
|
37
|
+
for (const [targetPath, owners] of [...targets.entries()].sort((a, b) =>
|
|
38
|
+
a[0].localeCompare(b[0]),
|
|
39
|
+
)) {
|
|
40
|
+
if (!fullClean) {
|
|
41
|
+
const allOwners = ownership.get(targetPath) ?? owners;
|
|
42
|
+
const unselectedOwners = allOwners.filter(
|
|
43
|
+
(owner) => !owners.includes(owner),
|
|
44
|
+
);
|
|
45
|
+
if (unselectedOwners.length) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
if (!existsSync(targetPath)) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
rmSync(targetPath, { recursive: true, force: true });
|
|
53
|
+
removed++;
|
|
54
|
+
process.stdout.write(
|
|
55
|
+
`${chalk.bgGreenBright.black(" CLEAN ")} ${toRelativePath(targetPath)} ${chalk.dim(`(${owners.join(", ")})`)}\n`,
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
process.stdout.write(
|
|
59
|
+
`${chalk.bold("Summary:")} removed ${removed} path(s)\n`,
|
|
60
|
+
);
|
|
50
61
|
}
|
|
51
62
|
function buildOwnershipMap(loadedConfig) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
collectOwnership(ownership, active.logs, modeName, "logs");
|
|
63
|
-
}
|
|
64
|
-
return ownership;
|
|
63
|
+
const ownership = new Map();
|
|
64
|
+
const modeNames = [undefined, ...Object.keys(loadedConfig.modes)];
|
|
65
|
+
for (const modeName of modeNames) {
|
|
66
|
+
const active = applyMode(loadedConfig, modeName).config;
|
|
67
|
+
collectOwnership(ownership, active.outDir, modeName, "build");
|
|
68
|
+
collectOwnership(ownership, active.fuzz.crashDir, modeName, "crashes");
|
|
69
|
+
collectOwnership(ownership, active.coverageDir, modeName, "coverage");
|
|
70
|
+
collectOwnership(ownership, active.logs, modeName, "logs");
|
|
71
|
+
}
|
|
72
|
+
return ownership;
|
|
65
73
|
}
|
|
66
74
|
function collectRootTarget(targets, rawPath, kind) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (existing)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
targets.set(resolved, [owner]);
|
|
75
|
+
if (!rawPath || rawPath == "none") return;
|
|
76
|
+
const resolved = path.resolve(process.cwd(), rawPath);
|
|
77
|
+
ensureSafeCleanPath(resolved, rawPath, kind);
|
|
78
|
+
const owner = `all:${kind}`;
|
|
79
|
+
const existing = targets.get(resolved);
|
|
80
|
+
if (existing) {
|
|
81
|
+
if (!existing.includes(owner)) existing.push(owner);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
targets.set(resolved, [owner]);
|
|
79
85
|
}
|
|
80
86
|
function collectOwnership(ownership, rawPath, modeName, kind) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (existing)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
ownership.set(resolved, [owner]);
|
|
87
|
+
if (!rawPath || rawPath == "none") return;
|
|
88
|
+
const resolved = path.resolve(process.cwd(), rawPath);
|
|
89
|
+
ensureSafeCleanPath(resolved, rawPath, kind);
|
|
90
|
+
const owner = `${modeName ?? "default"}:${kind}`;
|
|
91
|
+
const existing = ownership.get(resolved);
|
|
92
|
+
if (existing) {
|
|
93
|
+
if (!existing.includes(owner)) existing.push(owner);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
ownership.set(resolved, [owner]);
|
|
93
97
|
}
|
|
94
98
|
function collectTarget(targets, rawPath, modeName, kind) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (existing)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
targets.set(resolved, [owner]);
|
|
99
|
+
if (!rawPath || rawPath == "none") return;
|
|
100
|
+
const resolved = path.resolve(process.cwd(), rawPath);
|
|
101
|
+
ensureSafeCleanPath(resolved, rawPath, kind);
|
|
102
|
+
const owner = `${modeName ?? "default"}:${kind}`;
|
|
103
|
+
const existing = targets.get(resolved);
|
|
104
|
+
if (existing) {
|
|
105
|
+
if (!existing.includes(owner)) existing.push(owner);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
targets.set(resolved, [owner]);
|
|
107
109
|
}
|
|
108
110
|
function pruneNestedTargets(targets) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
111
|
+
const paths = [...targets.keys()].sort((a, b) => a.length - b.length);
|
|
112
|
+
for (const targetPath of paths) {
|
|
113
|
+
for (const otherPath of paths) {
|
|
114
|
+
if (targetPath == otherPath) continue;
|
|
115
|
+
const relative = path.relative(targetPath, otherPath);
|
|
116
|
+
if (
|
|
117
|
+
!relative.length ||
|
|
118
|
+
relative == ".." ||
|
|
119
|
+
relative.startsWith(`..${path.sep}`)
|
|
120
|
+
) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
targets.delete(otherPath);
|
|
122
124
|
}
|
|
125
|
+
}
|
|
123
126
|
}
|
|
124
127
|
function ensureSafeCleanPath(resolvedPath, rawPath, kind) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
const cwd = path.resolve(process.cwd());
|
|
129
|
+
const relative = path.relative(cwd, resolvedPath);
|
|
130
|
+
if (
|
|
131
|
+
!relative.length ||
|
|
132
|
+
relative == ".." ||
|
|
133
|
+
relative.startsWith(`..${path.sep}`) ||
|
|
134
|
+
path.parse(resolvedPath).root == resolvedPath
|
|
135
|
+
) {
|
|
136
|
+
throw new Error(
|
|
137
|
+
`refusing to clean unsafe ${kind} path "${rawPath}" (${resolvedPath})`,
|
|
138
|
+
);
|
|
139
|
+
}
|
|
133
140
|
}
|
|
134
141
|
function toRelativePath(targetPath) {
|
|
135
|
-
|
|
136
|
-
|
|
142
|
+
const relative = path.relative(process.cwd(), targetPath);
|
|
143
|
+
return relative.length ? relative : ".";
|
|
137
144
|
}
|
package/bin/commands/clean.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { clean } from "./clean-core.js";
|
|
2
2
|
import { loadConfig } from "../util.js";
|
|
3
3
|
export { clean } from "./clean-core.js";
|
|
4
|
-
export async function executeCleanCommand(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export async function executeCleanCommand(
|
|
5
|
+
rawArgs,
|
|
6
|
+
configPath,
|
|
7
|
+
selectedModes,
|
|
8
|
+
resolveExecutionModes,
|
|
9
|
+
) {
|
|
10
|
+
const modeTargets =
|
|
11
|
+
selectedModes.length > 0
|
|
12
|
+
? resolveExecutionModes(configPath, selectedModes)
|
|
13
|
+
: resolveAllCleanModes(configPath);
|
|
14
|
+
await clean(configPath, modeTargets, selectedModes.length == 0);
|
|
9
15
|
}
|
|
10
16
|
function resolveAllCleanModes(configPath) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
const resolvedConfigPath = configPath ?? "./as-test.config.json";
|
|
18
|
+
const config = loadConfig(resolvedConfigPath, true);
|
|
19
|
+
return [undefined, ...Object.keys(config.modes)];
|
|
14
20
|
}
|