42 lines
2.0 KiB
TypeScript
42 lines
2.0 KiB
TypeScript
import * as fs from 'fs';
|
|
import { execSync } from 'child_process';
|
|
|
|
// 重置本会话"假全量反写"污染的结果为 to_do(只清我写过的:/tmp/sim-results.json 里的锚点)。
|
|
// 之后真实反写应来自真实 P0 跑的 .results.json(只含实际执行用例)。
|
|
const ONES = '/Users/woan/local/bin/ones';
|
|
const PLAN = 'CQz9YCNX';
|
|
const wb = JSON.parse(fs.readFileSync('test-plan/ones-writeback-params.json', 'utf-8'));
|
|
const numToUuid = new Map<number, string>();
|
|
for (const c of wb.cases) numToUuid.set(c.number, c.uuid);
|
|
const ble15975 = wb.controlCases['15975'].uuid; // Lqpkx6mp
|
|
|
|
const results = JSON.parse(fs.readFileSync('/tmp/sim-results.json', 'utf-8')).results;
|
|
const caseNums = new Set<number>();
|
|
const bleSteps = new Set<string>();
|
|
for (const r of results) {
|
|
const mStep = r.name.match(/ONES:15975#(\w+)/);
|
|
if (mStep) { bleSteps.add(mStep[1]); continue; }
|
|
const mCase = r.name.match(/ONES:(\d+)(?!#)/);
|
|
if (mCase) caseNums.add(parseInt(mCase[1], 10));
|
|
}
|
|
|
|
const gql = (q: string) => { try { execSync(`${ONES} graphql '${q.replace(/'/g, "'\\''")}'`, { timeout: 30000 }); return true; } catch { return false; } };
|
|
let ok = 0, fail = 0;
|
|
|
|
console.log(`重置 ${caseNums.size} case + ${bleSteps.size} step(15975)为 to_do ...`);
|
|
// 1) case 级 → to_do
|
|
for (const num of caseNums) {
|
|
const uuid = numToUuid.get(num);
|
|
if (!uuid) { console.log(` 跳过 case ${num}(无 uuid)`); continue; }
|
|
const q = `mutation { updateTestcasePlanCase(key: "testcase_plan_case-${PLAN}-${uuid}", result: "to_do") { key } }`;
|
|
if (gql(q)) ok++; else fail++;
|
|
}
|
|
// 2) 15975 step 级 → to_do
|
|
for (const step of bleSteps) {
|
|
const q = `mutation { updateTestcasePlanCaseStep(key: "testcase_plan_case_step-${PLAN}-${ble15975}-${step}", step_result: "to_do") { key } }`;
|
|
if (gql(q)) ok++; else fail++;
|
|
}
|
|
// 3) 15975 case 本身 → to_do
|
|
gql(`mutation { updateTestcasePlanCase(key: "testcase_plan_case-${PLAN}-${ble15975}", result: "to_do") { key } }`);
|
|
console.log(`重置完成:成功 ${ok} / 失败 ${fail}`);
|