fix: 修正 CaseRun 类型审计漏报
This commit is contained in:
@@ -6,8 +6,13 @@ import test from "node:test";
|
||||
|
||||
import { auditCaseRunSources, renderCaseRunAuditText } from "../src/hwlab-caserun-audit.ts";
|
||||
|
||||
test("CaseRun static audit passes the current source modules", async () => {
|
||||
const report = await auditCaseRunSources({ root: process.cwd() });
|
||||
test("CaseRun static audit passes clean source modules", async () => {
|
||||
const root = await mkdtemp(path.join(os.tmpdir(), "caserun-audit-clean-"));
|
||||
const sourceDir = path.join(root, "tools", "src");
|
||||
await mkdir(sourceDir, { recursive: true });
|
||||
await writeFile(path.join(sourceDir, "hwlab-caserun-clean.ts"), "export const value: string = 'ok';\n", "utf8");
|
||||
|
||||
const report = await auditCaseRunSources({ root });
|
||||
assert.equal(report.ok, true, renderCaseRunAuditText(report));
|
||||
assert.equal(report.status, "passed");
|
||||
assert.equal(report.findingCount, 0);
|
||||
@@ -21,6 +26,8 @@ test("CaseRun static audit returns typed findings for representative source defe
|
||||
"import { helper } from './hwlab-caserun-helper.ts';",
|
||||
"const first = 1; const second = 2;",
|
||||
"export type MissingAlias = MissingCaseRunType;",
|
||||
"export const incompatibleValue: string = first;",
|
||||
"export const missingProperty = ({ value: first }).missing;",
|
||||
"export const runtimeValue = helper(first + second);",
|
||||
].join("\n"), "utf8");
|
||||
await writeFile(path.join(sourceDir, "hwlab-caserun-helper.ts"), [
|
||||
@@ -38,6 +45,8 @@ test("CaseRun static audit returns typed findings for representative source defe
|
||||
assert.equal(report.ok, false);
|
||||
assert.equal(report.status, "failed");
|
||||
assert.ok(codes.has("caserun_type_ts2304"));
|
||||
assert.ok(codes.has("caserun_type_ts2322"));
|
||||
assert.ok(codes.has("caserun_type_ts2339"));
|
||||
assert.ok(codes.has("caserun_runtime_reverse_dependency"));
|
||||
assert.ok(codes.has("caserun_dependency_cycle"));
|
||||
assert.ok(codes.has("caserun_duplicate_pure_helper"));
|
||||
|
||||
Reference in New Issue
Block a user