@godzillaba/mutest 1.4.1 → 1.5.2
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/README.md +6 -0
- package/index.ts +12 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,6 +35,12 @@ This reads `gambit_out/survivors.json` (or falls back to `gambit_out/gambit_resu
|
|
|
35
35
|
npx @godzillaba/mutest --workers 4 src/Counter.sol
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
`--test-cmd <cmd>` / `-t <cmd>` — override the test command. The command runs via `bash -c` with the worker directory as `cwd`. Defaults to `forge test --optimize false --threads 1 --root <workerDir>`.
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
npx @godzillaba/mutest --test-cmd "npx hardhat test" src/Counter.sol
|
|
42
|
+
```
|
|
43
|
+
|
|
38
44
|
## Requirements
|
|
39
45
|
|
|
40
46
|
- [Foundry](https://getfoundry.sh/) (`forge`)
|
package/index.ts
CHANGED
|
@@ -59,6 +59,7 @@ async function processMutants(
|
|
|
59
59
|
tempDir: string,
|
|
60
60
|
mutants: Mutant[],
|
|
61
61
|
workerCount: number,
|
|
62
|
+
testCmd?: string,
|
|
62
63
|
) {
|
|
63
64
|
const queues: Mutant[][] = Array.from({ length: workerCount }, () => []);
|
|
64
65
|
for (let i = 0; i < mutants.length; i++)
|
|
@@ -75,7 +76,11 @@ async function processMutants(
|
|
|
75
76
|
await cp(dest, backup);
|
|
76
77
|
await cp(`gambit_out/${mutant.original}/${mutant.name}`, dest);
|
|
77
78
|
try {
|
|
78
|
-
|
|
79
|
+
if (testCmd) {
|
|
80
|
+
await execFile("bash", ["-c", testCmd], { cwd: workerDir });
|
|
81
|
+
} else {
|
|
82
|
+
await execFile("forge", ["test", "--optimize", "false", "--threads", "1", "--root", workerDir]);
|
|
83
|
+
}
|
|
79
84
|
survivors.push(mutant);
|
|
80
85
|
} catch {}
|
|
81
86
|
await cp(backup, dest);
|
|
@@ -122,19 +127,22 @@ async function loadExistingMutants(): Promise<Mutant[]> {
|
|
|
122
127
|
function parseArgs() {
|
|
123
128
|
const args = process.argv.slice(2);
|
|
124
129
|
let workers = 8;
|
|
130
|
+
let testCmd: string | undefined;
|
|
125
131
|
const solFiles: string[] = [];
|
|
126
132
|
for (let i = 0; i < args.length; i++) {
|
|
127
133
|
if (args[i] === "--workers" || args[i] === "-w") {
|
|
128
134
|
workers = parseInt(args[++i], 10);
|
|
135
|
+
} else if (args[i] === "--test-cmd" || args[i] === "-t") {
|
|
136
|
+
testCmd = args[++i];
|
|
129
137
|
} else {
|
|
130
138
|
solFiles.push(args[i]);
|
|
131
139
|
}
|
|
132
140
|
}
|
|
133
|
-
return { solFiles, workers };
|
|
141
|
+
return { solFiles, workers, testCmd };
|
|
134
142
|
}
|
|
135
143
|
|
|
136
144
|
async function main() {
|
|
137
|
-
const { solFiles, workers: workerCount } = parseArgs();
|
|
145
|
+
const { solFiles, workers: workerCount, testCmd } = parseArgs();
|
|
138
146
|
console.log(`Setting up ${workerCount} workers...`);
|
|
139
147
|
const tempDir = await setupWorkers(workerCount);
|
|
140
148
|
|
|
@@ -148,7 +156,7 @@ async function main() {
|
|
|
148
156
|
mutants = await loadExistingMutants();
|
|
149
157
|
}
|
|
150
158
|
console.log(`${mutants.length} mutants, running tests...\n`);
|
|
151
|
-
await processMutants(tempDir, mutants, workerCount);
|
|
159
|
+
await processMutants(tempDir, mutants, workerCount, testCmd);
|
|
152
160
|
} finally {
|
|
153
161
|
await rm(tempDir, { recursive: true, force: true });
|
|
154
162
|
}
|