@godzillaba/mutest 1.4.0 → 1.4.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/index.ts +20 -5
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env -S npx tsx
|
|
2
2
|
import { execFile as execFileCb } from "child_process";
|
|
3
|
-
import { readFile, writeFile, cp, rm } from "fs/promises";
|
|
3
|
+
import { readFile, writeFile, cp, rm, readdir } from "fs/promises";
|
|
4
4
|
import { promisify } from "util";
|
|
5
|
+
import { join } from "path";
|
|
5
6
|
|
|
6
7
|
const execFile = promisify(execFileCb);
|
|
7
8
|
|
|
@@ -46,7 +47,6 @@ async function runGambit(solFiles: string[], concurrency: number): Promise<Mutan
|
|
|
46
47
|
]);
|
|
47
48
|
const raw = await readFile(`${outdir}/gambit_results.json`, "utf-8");
|
|
48
49
|
const mutants: Mutant[] = JSON.parse(raw);
|
|
49
|
-
for (const m of mutants) m.name = `${file}/${m.name}`;
|
|
50
50
|
results.push(...mutants);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -73,7 +73,7 @@ async function processMutants(
|
|
|
73
73
|
const dest = `${workerDir}/${mutant.original}`;
|
|
74
74
|
const backup = `${dest}.orig`;
|
|
75
75
|
await cp(dest, backup);
|
|
76
|
-
await cp(`gambit_out/${mutant.name}`, dest);
|
|
76
|
+
await cp(`gambit_out/${mutant.original}/${mutant.name}`, dest);
|
|
77
77
|
try {
|
|
78
78
|
await execFile("forge", ["test", "--optimize", "false", "--root", workerDir]);
|
|
79
79
|
survivors.push(mutant);
|
|
@@ -91,6 +91,16 @@ async function processMutants(
|
|
|
91
91
|
console.log(`Wrote survivors.json`);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
async function findJsonFiles(dir: string, name: string): Promise<string[]> {
|
|
95
|
+
const results: string[] = [];
|
|
96
|
+
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
97
|
+
const full = join(dir, entry.name);
|
|
98
|
+
if (entry.isDirectory()) results.push(...await findJsonFiles(full, name));
|
|
99
|
+
else if (entry.name === name) results.push(full);
|
|
100
|
+
}
|
|
101
|
+
return results;
|
|
102
|
+
}
|
|
103
|
+
|
|
94
104
|
async function loadExistingMutants(): Promise<Mutant[]> {
|
|
95
105
|
try {
|
|
96
106
|
const raw = await readFile("gambit_out/survivors.json", "utf-8");
|
|
@@ -100,8 +110,13 @@ async function loadExistingMutants(): Promise<Mutant[]> {
|
|
|
100
110
|
return survivors;
|
|
101
111
|
}
|
|
102
112
|
} catch {}
|
|
103
|
-
const
|
|
104
|
-
|
|
113
|
+
const files = await findJsonFiles("gambit_out", "gambit_results.json");
|
|
114
|
+
const all: Mutant[] = [];
|
|
115
|
+
for (const f of files) {
|
|
116
|
+
const raw = await readFile(f, "utf-8");
|
|
117
|
+
all.push(...JSON.parse(raw));
|
|
118
|
+
}
|
|
119
|
+
return all;
|
|
105
120
|
}
|
|
106
121
|
|
|
107
122
|
function parseArgs() {
|