@robhowley/pi-structured-return 1.8.0 → 1.10.0
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 +84 -73
- package/extensions/structured-return/config/project-config.ts +10 -0
- package/extensions/structured-return/config/registry.ts +306 -0
- package/extensions/structured-return/examples/.pi/machine-readable.json +18 -0
- package/extensions/structured-return/examples/.pi/parsers/foo-cli.ts +25 -0
- package/extensions/structured-return/{src/index.ts → index.ts} +94 -69
- package/extensions/structured-return/{src/parsers → parsers}/ava-text.ts +23 -15
- package/extensions/structured-return/{src/parsers → parsers}/bandit-json.ts +17 -15
- package/extensions/structured-return/{src/parsers → parsers}/black-text.ts +18 -18
- package/extensions/structured-return/{src/parsers → parsers}/cargo-build.ts +19 -14
- package/extensions/structured-return/{src/parsers → parsers}/cargo-test.ts +20 -19
- package/extensions/structured-return/parsers/checkstyle-xml.ts +183 -0
- package/extensions/structured-return/{src/parsers → parsers}/clang-text.ts +15 -13
- package/extensions/structured-return/{src/parsers → parsers}/dbt-json.ts +28 -23
- package/extensions/structured-return/{src/parsers → parsers}/dotnet-build-text.ts +10 -8
- package/extensions/structured-return/{src/parsers → parsers}/eslint-json.ts +15 -9
- package/extensions/structured-return/{src/parsers → parsers}/go-test-json.ts +23 -21
- package/extensions/structured-return/{src/parsers → parsers}/hadolint-json.ts +18 -12
- package/extensions/structured-return/{src/parsers → parsers}/htmlhint-json.ts +15 -13
- package/extensions/structured-return/{src/parsers → parsers}/isort-text.ts +18 -18
- package/extensions/structured-return/{src/parsers → parsers}/javac-text.ts +14 -12
- package/extensions/structured-return/{src/parsers → parsers}/jsonlint-text.ts +16 -14
- package/extensions/structured-return/{src/parsers → parsers}/junit-xml.ts +149 -50
- package/extensions/structured-return/{src/parsers → parsers}/markdownlint-json.ts +19 -17
- package/extensions/structured-return/{src/parsers → parsers}/minitest-text.ts +24 -15
- package/extensions/structured-return/{src/parsers → parsers}/mocha-json.ts +17 -10
- package/extensions/structured-return/{src/parsers → parsers}/mypy-json.ts +16 -16
- package/extensions/structured-return/{src/parsers → parsers}/node-test-text.ts +17 -14
- package/extensions/structured-return/{src/parsers → parsers}/npm-audit-json.ts +19 -16
- package/extensions/structured-return/{src/parsers → parsers}/prettier-text.ts +21 -17
- package/extensions/structured-return/{src/parsers → parsers}/pylint-json.ts +17 -17
- package/extensions/structured-return/{src/parsers → parsers}/pyright-json.ts +20 -18
- package/extensions/structured-return/{src/parsers → parsers}/rspec-json.ts +14 -14
- package/extensions/structured-return/{src/parsers → parsers}/rubocop-json.ts +22 -11
- package/extensions/structured-return/{src/parsers → parsers}/ruff-json.ts +7 -7
- package/extensions/structured-return/{src/parsers → parsers}/shellcheck-json.ts +14 -14
- package/extensions/structured-return/{src/parsers → parsers}/stylelint-json.ts +21 -13
- package/extensions/structured-return/{src/parsers → parsers}/swiftc-text.ts +16 -10
- package/extensions/structured-return/parsers/tail-fallback.ts +20 -0
- package/extensions/structured-return/{src/parsers → parsers}/tidy-text.ts +13 -13
- package/extensions/structured-return/{src/parsers → parsers}/tsc-text.ts +11 -11
- package/extensions/structured-return/{src/parsers → parsers}/unittest-text.ts +24 -14
- package/extensions/structured-return/{src/parsers → parsers}/utils.ts +9 -6
- package/extensions/structured-return/{src/parsers → parsers}/vale-json.ts +18 -18
- package/extensions/structured-return/{src/parsers → parsers}/vitest-json.ts +14 -14
- package/extensions/structured-return/{src/storage → storage}/log-store.ts +5 -5
- package/extensions/structured-return/{src/storage → storage}/session-stats.ts +11 -11
- package/extensions/structured-return/{src/types.ts → types.ts} +4 -2
- package/package.json +27 -43
- package/skills/structured-return/SKILL.md +62 -1
- package/LICENSE +0 -21
- package/extensions/structured-return/src/config/project-config.ts +0 -10
- package/extensions/structured-return/src/config/registry.test.ts +0 -171
- package/extensions/structured-return/src/config/registry.ts +0 -282
- package/extensions/structured-return/src/index.test.ts +0 -220
- package/extensions/structured-return/src/parsers/ava-text.test.ts +0 -116
- package/extensions/structured-return/src/parsers/bandit-json.test.ts +0 -90
- package/extensions/structured-return/src/parsers/black-text.test.ts +0 -67
- package/extensions/structured-return/src/parsers/cargo-build.test.ts +0 -170
- package/extensions/structured-return/src/parsers/cargo-test.test.ts +0 -191
- package/extensions/structured-return/src/parsers/clang-text.test.ts +0 -61
- package/extensions/structured-return/src/parsers/dbt-json.test.ts +0 -172
- package/extensions/structured-return/src/parsers/dotnet-build-text.test.ts +0 -85
- package/extensions/structured-return/src/parsers/eslint-json.test.ts +0 -60
- package/extensions/structured-return/src/parsers/go-test-json.test.ts +0 -119
- package/extensions/structured-return/src/parsers/hadolint-json.test.ts +0 -73
- package/extensions/structured-return/src/parsers/htmlhint-json.test.ts +0 -72
- package/extensions/structured-return/src/parsers/isort-text.test.ts +0 -58
- package/extensions/structured-return/src/parsers/javac-text.test.ts +0 -75
- package/extensions/structured-return/src/parsers/jsonlint-text.test.ts +0 -52
- package/extensions/structured-return/src/parsers/junit-xml.test.ts +0 -410
- package/extensions/structured-return/src/parsers/markdownlint-json.test.ts +0 -76
- package/extensions/structured-return/src/parsers/minitest-text.test.ts +0 -110
- package/extensions/structured-return/src/parsers/mocha-json.test.ts +0 -108
- package/extensions/structured-return/src/parsers/mypy-json.test.ts +0 -101
- package/extensions/structured-return/src/parsers/node-test-text.test.ts +0 -117
- package/extensions/structured-return/src/parsers/npm-audit-json.test.ts +0 -83
- package/extensions/structured-return/src/parsers/prettier-text.test.ts +0 -76
- package/extensions/structured-return/src/parsers/pylint-json.test.ts +0 -120
- package/extensions/structured-return/src/parsers/pyright-json.test.ts +0 -112
- package/extensions/structured-return/src/parsers/rspec-json.test.ts +0 -126
- package/extensions/structured-return/src/parsers/rubocop-json.test.ts +0 -118
- package/extensions/structured-return/src/parsers/ruff-json.test.ts +0 -57
- package/extensions/structured-return/src/parsers/shellcheck-json.test.ts +0 -110
- package/extensions/structured-return/src/parsers/stylelint-json.test.ts +0 -120
- package/extensions/structured-return/src/parsers/swiftc-text.test.ts +0 -73
- package/extensions/structured-return/src/parsers/tail-fallback.test.ts +0 -41
- package/extensions/structured-return/src/parsers/tail-fallback.ts +0 -20
- package/extensions/structured-return/src/parsers/tidy-text.test.ts +0 -74
- package/extensions/structured-return/src/parsers/tsc-text.test.ts +0 -81
- package/extensions/structured-return/src/parsers/unittest-text.test.ts +0 -126
- package/extensions/structured-return/src/parsers/vale-json.test.ts +0 -84
- package/extensions/structured-return/src/parsers/vitest-json.test.ts +0 -118
- package/extensions/structured-return/src/storage/session-stats.test.ts +0 -156
- package/extensions/structured-return/tsconfig.json +0 -11
- package/extensions/structured-return/vitest.config.ts +0 -9
- /package/extensions/structured-return/{src/ui → ui}/widget.ts +0 -0
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import os from "node:os";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { describe, it, expect } from "vitest";
|
|
5
|
-
import parser from "./stylelint-json";
|
|
6
|
-
import type { RunContext } from "../types";
|
|
7
|
-
|
|
8
|
-
function makeCtx(stdout: string, cwd = "/project"): RunContext {
|
|
9
|
-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "stylelint-test-"));
|
|
10
|
-
const stdoutPath = path.join(dir, "stdout");
|
|
11
|
-
fs.writeFileSync(stdoutPath, stdout);
|
|
12
|
-
return {
|
|
13
|
-
command: "stylelint lint_check.css --formatter json",
|
|
14
|
-
argv: ["stylelint", "lint_check.css", "--formatter", "json"],
|
|
15
|
-
cwd,
|
|
16
|
-
artifactPaths: [],
|
|
17
|
-
stdoutPath,
|
|
18
|
-
stderrPath: path.join(dir, "stderr"),
|
|
19
|
-
logPath: path.join(dir, "log"),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
describe("stylelint-json parser", () => {
|
|
24
|
-
it("multiple warnings → correct file, line, message, rule", async () => {
|
|
25
|
-
const stdout = JSON.stringify([
|
|
26
|
-
{
|
|
27
|
-
source: "/project/lint_check.css",
|
|
28
|
-
warnings: [
|
|
29
|
-
{
|
|
30
|
-
line: 2,
|
|
31
|
-
column: 3,
|
|
32
|
-
rule: "declaration-block-no-duplicate-properties",
|
|
33
|
-
severity: "error",
|
|
34
|
-
text: 'Unexpected duplicate "color" (declaration-block-no-duplicate-properties)',
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
line: 4,
|
|
38
|
-
column: 19,
|
|
39
|
-
rule: "declaration-no-important",
|
|
40
|
-
severity: "error",
|
|
41
|
-
text: "Unexpected !important (declaration-no-important)",
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
deprecations: [],
|
|
45
|
-
invalidOptionWarnings: [],
|
|
46
|
-
},
|
|
47
|
-
]);
|
|
48
|
-
const result = await parser.parse(makeCtx(stdout, "/project"));
|
|
49
|
-
expect(result.status).toBe("fail");
|
|
50
|
-
expect(result.summary).toBe("2 lint errors");
|
|
51
|
-
expect(result.failures![0]).toMatchObject({
|
|
52
|
-
file: "lint_check.css",
|
|
53
|
-
line: 2,
|
|
54
|
-
message: 'Unexpected duplicate "color"',
|
|
55
|
-
rule: "declaration-block-no-duplicate-properties",
|
|
56
|
-
});
|
|
57
|
-
expect(result.failures![1]).toMatchObject({ message: "Unexpected !important", rule: "declaration-no-important" });
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("no warnings → status pass", async () => {
|
|
61
|
-
const stdout = JSON.stringify([{ source: "clean.css", warnings: [], deprecations: [], invalidOptionWarnings: [] }]);
|
|
62
|
-
const result = await parser.parse(makeCtx(stdout));
|
|
63
|
-
expect(result.status).toBe("pass");
|
|
64
|
-
expect(result.failures).toHaveLength(0);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("empty stdout → status pass", async () => {
|
|
68
|
-
const result = await parser.parse(makeCtx(""));
|
|
69
|
-
expect(result.status).toBe("pass");
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("strips rule name suffix from message text", async () => {
|
|
73
|
-
const stdout = JSON.stringify([
|
|
74
|
-
{
|
|
75
|
-
source: "foo.css",
|
|
76
|
-
warnings: [
|
|
77
|
-
{
|
|
78
|
-
line: 1,
|
|
79
|
-
column: 1,
|
|
80
|
-
rule: "color-no-invalid-hex",
|
|
81
|
-
severity: "error",
|
|
82
|
-
text: 'Unexpected invalid hex color "#FG" (color-no-invalid-hex)',
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
},
|
|
86
|
-
]);
|
|
87
|
-
const result = await parser.parse(makeCtx(stdout));
|
|
88
|
-
expect(result.failures![0].message).toBe('Unexpected invalid hex color "#FG"');
|
|
89
|
-
expect(result.failures![0].rule).toBe("color-no-invalid-hex");
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it("does not strip trailing parens when they are part of the message, not the rule", async () => {
|
|
93
|
-
const stdout = JSON.stringify([
|
|
94
|
-
{
|
|
95
|
-
source: "foo.css",
|
|
96
|
-
warnings: [
|
|
97
|
-
{
|
|
98
|
-
line: 3,
|
|
99
|
-
column: 10,
|
|
100
|
-
rule: "function-no-unknown",
|
|
101
|
-
severity: "error",
|
|
102
|
-
text: 'Unexpected unknown function "clamp(10px, 5vw, 50px)" (function-no-unknown)',
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
line: 7,
|
|
106
|
-
column: 15,
|
|
107
|
-
rule: "value-no-vendor-prefix",
|
|
108
|
-
severity: "error",
|
|
109
|
-
text: "Unexpected value with parentheses calc(100% - 10px)",
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
},
|
|
113
|
-
]);
|
|
114
|
-
const result = await parser.parse(makeCtx(stdout));
|
|
115
|
-
// First warning: has the standard "(rule-name)" suffix — should be stripped
|
|
116
|
-
expect(result.failures![0].message).toBe('Unexpected unknown function "clamp(10px, 5vw, 50px)"');
|
|
117
|
-
// Second warning: trailing parens are CSS value, not rule suffix — must NOT be stripped
|
|
118
|
-
expect(result.failures![1].message).toBe("Unexpected value with parentheses calc(100% - 10px)");
|
|
119
|
-
});
|
|
120
|
-
});
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import os from "node:os";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { describe, it, expect } from "vitest";
|
|
5
|
-
import parser from "./swiftc-text";
|
|
6
|
-
import type { RunContext } from "../types";
|
|
7
|
-
|
|
8
|
-
function makeCtx(stderr: string, cwd = "/project"): RunContext {
|
|
9
|
-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "swiftc-test-"));
|
|
10
|
-
const stderrPath = path.join(dir, "stderr");
|
|
11
|
-
fs.writeFileSync(stderrPath, stderr);
|
|
12
|
-
const stdoutPath = path.join(dir, "stdout");
|
|
13
|
-
fs.writeFileSync(stdoutPath, "");
|
|
14
|
-
return {
|
|
15
|
-
command: "swiftc -typecheck type_check.swift",
|
|
16
|
-
argv: ["swiftc", "-typecheck", "type_check.swift"],
|
|
17
|
-
cwd,
|
|
18
|
-
artifactPaths: [],
|
|
19
|
-
stdoutPath,
|
|
20
|
-
stderrPath,
|
|
21
|
-
logPath: path.join(dir, "log"),
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
describe("swiftc-text parser", () => {
|
|
26
|
-
it("multiple errors with source annotations → deduplicated, correct file/line/message", async () => {
|
|
27
|
-
const stderr = [
|
|
28
|
-
"type_check.swift:5:22: error: cannot convert value of type 'Int' to specified type 'String'",
|
|
29
|
-
"3 | }",
|
|
30
|
-
"4 | ",
|
|
31
|
-
"5 | let result: String = add(1, 2)",
|
|
32
|
-
" | `- error: cannot convert value of type 'Int' to specified type 'String'",
|
|
33
|
-
'6 | let total: Int = add("hello", 3)',
|
|
34
|
-
"",
|
|
35
|
-
"type_check.swift:6:22: error: cannot convert value of type 'String' to expected argument type 'Int'",
|
|
36
|
-
"5 | let result: String = add(1, 2)",
|
|
37
|
-
'6 | let total: Int = add("hello", 3)',
|
|
38
|
-
" | `- error: cannot convert value of type 'String' to expected argument type 'Int'",
|
|
39
|
-
].join("\n");
|
|
40
|
-
const result = await parser.parse(makeCtx(stderr));
|
|
41
|
-
expect(result.status).toBe("fail");
|
|
42
|
-
expect(result.summary).toBe("2 errors");
|
|
43
|
-
expect(result.failures).toHaveLength(2);
|
|
44
|
-
expect(result.failures![0]).toMatchObject({
|
|
45
|
-
file: "type_check.swift",
|
|
46
|
-
line: 5,
|
|
47
|
-
message: "cannot convert value of type 'Int' to specified type 'String'",
|
|
48
|
-
});
|
|
49
|
-
expect(result.failures![1]).toMatchObject({ file: "type_check.swift", line: 6 });
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("empty stderr → status pass", async () => {
|
|
53
|
-
const result = await parser.parse(makeCtx(""));
|
|
54
|
-
expect(result.status).toBe("pass");
|
|
55
|
-
expect(result.failures).toHaveLength(0);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("absolute paths → relativized", async () => {
|
|
59
|
-
const stderr = "/project/Sources/main.swift:10:5: error: use of unresolved identifier 'foo'";
|
|
60
|
-
const result = await parser.parse(makeCtx(stderr, "/project"));
|
|
61
|
-
expect(result.failures![0].file).toBe("Sources/main.swift");
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("warnings are skipped", async () => {
|
|
65
|
-
const stderr = [
|
|
66
|
-
"foo.swift:1:1: warning: expression of type 'Int' is unused",
|
|
67
|
-
"foo.swift:2:1: error: cannot find 'bar' in scope",
|
|
68
|
-
].join("\n");
|
|
69
|
-
const result = await parser.parse(makeCtx(stderr));
|
|
70
|
-
expect(result.failures).toHaveLength(1);
|
|
71
|
-
expect(result.failures![0].message).toBe("cannot find 'bar' in scope");
|
|
72
|
-
});
|
|
73
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import os from "node:os";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { describe, it, expect } from "vitest";
|
|
5
|
-
import parser from "./tail-fallback";
|
|
6
|
-
import type { RunContext } from "../types";
|
|
7
|
-
|
|
8
|
-
function makeCtx(logContent: string): RunContext {
|
|
9
|
-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "tail-test-"));
|
|
10
|
-
const logPath = path.join(dir, "log");
|
|
11
|
-
fs.writeFileSync(logPath, logContent);
|
|
12
|
-
return {
|
|
13
|
-
command: "some-command",
|
|
14
|
-
argv: ["some-command"],
|
|
15
|
-
cwd: "/project",
|
|
16
|
-
artifactPaths: [],
|
|
17
|
-
stdoutPath: path.join(dir, "stdout"),
|
|
18
|
-
stderrPath: path.join(dir, "stderr"),
|
|
19
|
-
logPath,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
describe("tail-fallback parser", () => {
|
|
24
|
-
it("any command → status error, summary contains log path", async () => {
|
|
25
|
-
const ctx = makeCtx("some output");
|
|
26
|
-
const result = await parser.parse(ctx);
|
|
27
|
-
expect(result.status).toBe("error");
|
|
28
|
-
expect(result.summary).toBe("no parser matched; returning tail + log path");
|
|
29
|
-
expect(result.logPath).toBe(ctx.logPath);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("long stdout → tail is bounded to last 200 lines", async () => {
|
|
33
|
-
const lines = Array.from({ length: 300 }, (_, i) => `line ${i + 1}`);
|
|
34
|
-
const ctx = makeCtx(lines.join("\n"));
|
|
35
|
-
const result = await parser.parse(ctx);
|
|
36
|
-
const tailLines = result.rawTail!.split("\n");
|
|
37
|
-
expect(tailLines.length).toBeLessThanOrEqual(200);
|
|
38
|
-
expect(tailLines[tailLines.length - 1]).toBe("line 300");
|
|
39
|
-
expect(tailLines[0]).toBe("line 101");
|
|
40
|
-
});
|
|
41
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { ParserModule } from "../types";
|
|
2
|
-
import { safeReadFile } from "./utils";
|
|
3
|
-
|
|
4
|
-
const parser: ParserModule = {
|
|
5
|
-
id: "tail-fallback",
|
|
6
|
-
async parse(ctx) {
|
|
7
|
-
const log = safeReadFile(ctx.logPath);
|
|
8
|
-
const lines = log.split(/\r?\n/);
|
|
9
|
-
const tail = lines.slice(-200).join("\n");
|
|
10
|
-
return {
|
|
11
|
-
tool: "unknown",
|
|
12
|
-
status: "error",
|
|
13
|
-
summary: "no parser matched; returning tail + log path",
|
|
14
|
-
logPath: ctx.logPath,
|
|
15
|
-
rawTail: tail,
|
|
16
|
-
};
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export default parser;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import os from "node:os";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { describe, it, expect } from "vitest";
|
|
5
|
-
import parser from "./tidy-text";
|
|
6
|
-
import type { RunContext } from "../types";
|
|
7
|
-
|
|
8
|
-
function makeCtx(stderr: string, cwd = "/project"): RunContext {
|
|
9
|
-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "tidy-test-"));
|
|
10
|
-
const stderrPath = path.join(dir, "stderr");
|
|
11
|
-
fs.writeFileSync(stderrPath, stderr);
|
|
12
|
-
return {
|
|
13
|
-
command: "tidy -errors src/index.html",
|
|
14
|
-
argv: ["tidy", "-errors", "src/index.html"],
|
|
15
|
-
cwd,
|
|
16
|
-
artifactPaths: [],
|
|
17
|
-
stdoutPath: path.join(dir, "stdout"),
|
|
18
|
-
stderrPath,
|
|
19
|
-
logPath: path.join(dir, "log"),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
describe("tidy-text parser", () => {
|
|
24
|
-
it("warnings with remediation noise → strips advice, extracts line and message", async () => {
|
|
25
|
-
const stderr = `line 1 column 1 - Warning: missing <!DOCTYPE> declaration
|
|
26
|
-
line 1 column 9 - Warning: inserting missing 'title' element
|
|
27
|
-
line 1 column 35 - Warning: <img> lacks "alt" attribute
|
|
28
|
-
Info: Document content looks like HTML 3.2
|
|
29
|
-
3 warnings, 0 errors were found!
|
|
30
|
-
|
|
31
|
-
The alt attribute should be used to give a short description
|
|
32
|
-
of an image; longer descriptions should be given with the
|
|
33
|
-
longdesc attribute which takes a URL linked to the description.
|
|
34
|
-
These measures are needed for people using non-graphical browsers.
|
|
35
|
-
|
|
36
|
-
For further advice on how to make your pages accessible
|
|
37
|
-
see http://www.w3.org/WAI/GL.
|
|
38
|
-
|
|
39
|
-
To learn more about HTML Tidy see http://tidy.sourceforge.net`;
|
|
40
|
-
const result = await parser.parse(makeCtx(stderr));
|
|
41
|
-
expect(result.status).toBe("pass");
|
|
42
|
-
expect(result.summary).toBe("3 warnings");
|
|
43
|
-
expect(result.failures).toHaveLength(3);
|
|
44
|
-
expect(result.failures![0].file).toBe("src/index.html");
|
|
45
|
-
expect(result.failures![0].line).toBe(1);
|
|
46
|
-
expect(result.failures![0].message).toBe("missing <!DOCTYPE> declaration");
|
|
47
|
-
expect(result.failures![2].message).toBe('<img> lacks "alt" attribute');
|
|
48
|
-
// No remediation text in failures
|
|
49
|
-
expect(result.failures!.every((f) => !f.message!.includes("should be used"))).toBe(true);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("errors and warnings → both counted in summary", async () => {
|
|
53
|
-
const stderr = `line 1 column 1 - Error: unexpected end of file
|
|
54
|
-
line 1 column 1 - Warning: missing <!DOCTYPE> declaration
|
|
55
|
-
1 warning, 1 error were found!`;
|
|
56
|
-
const result = await parser.parse(makeCtx(stderr));
|
|
57
|
-
expect(result.status).toBe("fail");
|
|
58
|
-
expect(result.summary).toBe("1 error, 1 warning");
|
|
59
|
-
expect(result.failures).toHaveLength(2);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("no issues → status pass", async () => {
|
|
63
|
-
const stderr = `No warnings or errors were found.`;
|
|
64
|
-
const result = await parser.parse(makeCtx(stderr));
|
|
65
|
-
expect(result.status).toBe("pass");
|
|
66
|
-
expect(result.failures).toHaveLength(0);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("empty stderr → no crash, status pass", async () => {
|
|
70
|
-
const result = await parser.parse(makeCtx(""));
|
|
71
|
-
expect(result.status).toBe("pass");
|
|
72
|
-
expect(result.failures).toHaveLength(0);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import os from "node:os";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { describe, it, expect } from "vitest";
|
|
5
|
-
import parser from "./tsc-text";
|
|
6
|
-
import type { RunContext } from "../types";
|
|
7
|
-
|
|
8
|
-
function makeCtx(stdout: string, cwd = "/project"): RunContext {
|
|
9
|
-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "tsc-test-"));
|
|
10
|
-
const stdoutPath = path.join(dir, "stdout");
|
|
11
|
-
fs.writeFileSync(stdoutPath, stdout);
|
|
12
|
-
return {
|
|
13
|
-
command: "tsc --noEmit --pretty false",
|
|
14
|
-
argv: ["tsc", "--noEmit", "--pretty", "false"],
|
|
15
|
-
cwd,
|
|
16
|
-
artifactPaths: [],
|
|
17
|
-
stdoutPath,
|
|
18
|
-
stderrPath: path.join(dir, "stderr"),
|
|
19
|
-
logPath: path.join(dir, "log"),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
describe("tsc-text parser", () => {
|
|
24
|
-
it("multiple type errors → correct file, line, message, rule, status fail", async () => {
|
|
25
|
-
const stdout = [
|
|
26
|
-
"type_check.ts(5,7): error TS2322: Type 'number' is not assignable to type 'string'.",
|
|
27
|
-
"type_check.ts(6,27): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.",
|
|
28
|
-
].join("\n");
|
|
29
|
-
const result = await parser.parse(makeCtx(stdout));
|
|
30
|
-
expect(result.status).toBe("fail");
|
|
31
|
-
expect(result.summary).toBe("2 type errors");
|
|
32
|
-
expect(result.failures).toHaveLength(2);
|
|
33
|
-
expect(result.failures![0]).toMatchObject({
|
|
34
|
-
file: "type_check.ts",
|
|
35
|
-
line: 5,
|
|
36
|
-
message: "Type 'number' is not assignable to type 'string'.",
|
|
37
|
-
rule: "TS2322",
|
|
38
|
-
});
|
|
39
|
-
expect(result.failures![1]).toMatchObject({
|
|
40
|
-
file: "type_check.ts",
|
|
41
|
-
line: 6,
|
|
42
|
-
message: "Argument of type 'string' is not assignable to parameter of type 'number'.",
|
|
43
|
-
rule: "TS2345",
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("no errors (empty stdout) → status pass", async () => {
|
|
48
|
-
const result = await parser.parse(makeCtx(""));
|
|
49
|
-
expect(result.status).toBe("pass");
|
|
50
|
-
expect(result.summary).toBe("no type errors");
|
|
51
|
-
expect(result.failures).toHaveLength(0);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("absolute file paths → relativized to cwd", async () => {
|
|
55
|
-
const stdout = "/project/src/foo.ts(10,5): error TS2304: Cannot find name 'bar'.";
|
|
56
|
-
const result = await parser.parse(makeCtx(stdout, "/project"));
|
|
57
|
-
expect(result.failures![0].file).toBe("src/foo.ts");
|
|
58
|
-
expect(result.failures![0].file).not.toContain("/project");
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("errors across multiple files", async () => {
|
|
62
|
-
const stdout = [
|
|
63
|
-
"src/a.ts(1,1): error TS2304: Cannot find name 'foo'.",
|
|
64
|
-
"src/b.ts(5,3): error TS2551: Property 'baz' does not exist on type 'Bar'.",
|
|
65
|
-
].join("\n");
|
|
66
|
-
const result = await parser.parse(makeCtx(stdout));
|
|
67
|
-
expect(result.failures).toHaveLength(2);
|
|
68
|
-
expect(result.failures![0].file).toBe("src/a.ts");
|
|
69
|
-
expect(result.failures![1].file).toBe("src/b.ts");
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("skips non-error lines (e.g. Found N errors)", async () => {
|
|
73
|
-
const stdout = [
|
|
74
|
-
"type_check.ts(5,7): error TS2322: Type 'number' is not assignable to type 'string'.",
|
|
75
|
-
"",
|
|
76
|
-
"Found 1 error in type_check.ts:5",
|
|
77
|
-
].join("\n");
|
|
78
|
-
const result = await parser.parse(makeCtx(stdout));
|
|
79
|
-
expect(result.failures).toHaveLength(1);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import os from "node:os";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { describe, it, expect } from "vitest";
|
|
5
|
-
import parser from "./unittest-text";
|
|
6
|
-
import type { RunContext } from "../types";
|
|
7
|
-
|
|
8
|
-
function makeCtx(stderr: string, cwd = "/project"): RunContext {
|
|
9
|
-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "unittest-test-"));
|
|
10
|
-
const stderrPath = path.join(dir, "stderr");
|
|
11
|
-
fs.writeFileSync(stderrPath, stderr);
|
|
12
|
-
const stdoutPath = path.join(dir, "stdout");
|
|
13
|
-
fs.writeFileSync(stdoutPath, "");
|
|
14
|
-
return {
|
|
15
|
-
command: "python3 -m unittest test_math.py",
|
|
16
|
-
argv: ["python3", "-m", "unittest", "test_math.py"],
|
|
17
|
-
cwd,
|
|
18
|
-
artifactPaths: [],
|
|
19
|
-
stdoutPath,
|
|
20
|
-
stderrPath,
|
|
21
|
-
logPath: path.join(dir, "log"),
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const REAL_FAILURE_OUTPUT = `.EF
|
|
26
|
-
======================================================================
|
|
27
|
-
ERROR: test_does_not_divide_by_zero (test_math.TestMath.test_does_not_divide_by_zero)
|
|
28
|
-
----------------------------------------------------------------------
|
|
29
|
-
Traceback (most recent call last):
|
|
30
|
-
File "/project/test_math.py", line 12, in test_does_not_divide_by_zero
|
|
31
|
-
result = 1 / 0
|
|
32
|
-
~~^~~
|
|
33
|
-
ZeroDivisionError: division by zero
|
|
34
|
-
|
|
35
|
-
======================================================================
|
|
36
|
-
FAIL: test_multiplies_two_numbers_correctly (test_math.TestMath.test_multiplies_two_numbers_correctly)
|
|
37
|
-
----------------------------------------------------------------------
|
|
38
|
-
Traceback (most recent call last):
|
|
39
|
-
File "/project/test_math.py", line 9, in test_multiplies_two_numbers_correctly
|
|
40
|
-
self.assertEqual(3 * 4, 99)
|
|
41
|
-
~~~~~~~~~~~~~~~~^^^^^^^^^^^
|
|
42
|
-
AssertionError: 12 != 99
|
|
43
|
-
|
|
44
|
-
----------------------------------------------------------------------
|
|
45
|
-
Ran 3 tests in 0.001s
|
|
46
|
-
|
|
47
|
-
FAILED (failures=1, errors=1)`;
|
|
48
|
-
|
|
49
|
-
describe("unittest-text parser", () => {
|
|
50
|
-
it("real output → assertion failure with expected/actual, runtime error with message", async () => {
|
|
51
|
-
const result = await parser.parse(makeCtx(REAL_FAILURE_OUTPUT));
|
|
52
|
-
expect(result.status).toBe("fail");
|
|
53
|
-
expect(result.summary).toBe("2 failed, 1 passed");
|
|
54
|
-
expect(result.failures).toHaveLength(2);
|
|
55
|
-
|
|
56
|
-
// ERROR block
|
|
57
|
-
const err = result.failures!.find((f) => f.rule === "error")!;
|
|
58
|
-
expect(err.file).toBe("test_math.py");
|
|
59
|
-
expect(err.line).toBe(12);
|
|
60
|
-
expect(err.message).toBe("ZeroDivisionError: division by zero");
|
|
61
|
-
|
|
62
|
-
// FAIL block
|
|
63
|
-
const fail = result.failures!.find((f) => f.rule === "assertion")!;
|
|
64
|
-
expect(fail.file).toBe("test_math.py");
|
|
65
|
-
expect(fail.line).toBe(9);
|
|
66
|
-
expect(fail.message).toBe("12 != 99");
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("all passing → status pass", async () => {
|
|
70
|
-
const stderr = `...
|
|
71
|
-
----------------------------------------------------------------------
|
|
72
|
-
Ran 3 tests in 0.001s
|
|
73
|
-
|
|
74
|
-
OK`;
|
|
75
|
-
const result = await parser.parse(makeCtx(stderr));
|
|
76
|
-
expect(result.status).toBe("pass");
|
|
77
|
-
expect(result.summary).toBe("3 passed");
|
|
78
|
-
expect(result.failures).toHaveLength(0);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("empty stderr → status pass", async () => {
|
|
82
|
-
const result = await parser.parse(makeCtx(""));
|
|
83
|
-
expect(result.status).toBe("pass");
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it("file paths relativized to cwd", async () => {
|
|
87
|
-
const result = await parser.parse(makeCtx(REAL_FAILURE_OUTPUT, "/project"));
|
|
88
|
-
for (const f of result.failures!) {
|
|
89
|
-
expect(f.file).not.toContain("/project/");
|
|
90
|
-
expect(f.file).toBe("test_math.py");
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it("skipped tests are not counted as passed", async () => {
|
|
95
|
-
const stderr = `.sF
|
|
96
|
-
======================================================================
|
|
97
|
-
FAIL: test_fail (test_math.TestMath.test_fail)
|
|
98
|
-
----------------------------------------------------------------------
|
|
99
|
-
Traceback (most recent call last):
|
|
100
|
-
File "/project/test_math.py", line 8, in test_fail
|
|
101
|
-
self.assertEqual(1, 2)
|
|
102
|
-
~~~~~~~~~~~~~~~~^^^^^^
|
|
103
|
-
AssertionError: 1 != 2
|
|
104
|
-
|
|
105
|
-
----------------------------------------------------------------------
|
|
106
|
-
Ran 3 tests in 0.001s
|
|
107
|
-
|
|
108
|
-
FAILED (failures=1, skipped=1)`;
|
|
109
|
-
const result = await parser.parse(makeCtx(stderr));
|
|
110
|
-
expect(result.status).toBe("fail");
|
|
111
|
-
// 3 total - 1 failed - 1 skipped = 1 passed (not 2)
|
|
112
|
-
expect(result.summary).toBe("1 failed, 1 passed");
|
|
113
|
-
expect(result.failures).toHaveLength(1);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("all passing with skips → correct passed count", async () => {
|
|
117
|
-
const stderr = `.s
|
|
118
|
-
----------------------------------------------------------------------
|
|
119
|
-
Ran 2 tests in 0.001s
|
|
120
|
-
|
|
121
|
-
OK (skipped=1)`;
|
|
122
|
-
const result = await parser.parse(makeCtx(stderr));
|
|
123
|
-
expect(result.status).toBe("pass");
|
|
124
|
-
expect(result.summary).toBe("1 passed");
|
|
125
|
-
});
|
|
126
|
-
});
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import os from "node:os";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { describe, it, expect } from "vitest";
|
|
5
|
-
import parser from "./vale-json";
|
|
6
|
-
import type { RunContext } from "../types";
|
|
7
|
-
|
|
8
|
-
function makeCtx(stdout: string, cwd = "/project"): RunContext {
|
|
9
|
-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "vale-test-"));
|
|
10
|
-
const stdoutPath = path.join(dir, "stdout");
|
|
11
|
-
fs.writeFileSync(stdoutPath, stdout);
|
|
12
|
-
return {
|
|
13
|
-
command: "vale --output JSON .",
|
|
14
|
-
argv: ["vale", "--output", "JSON", "."],
|
|
15
|
-
cwd,
|
|
16
|
-
artifactPaths: [],
|
|
17
|
-
stdoutPath,
|
|
18
|
-
stderrPath: path.join(dir, "stderr"),
|
|
19
|
-
logPath: path.join(dir, "log"),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
describe("vale-json parser", () => {
|
|
24
|
-
it("multiple errors across files → correct relative paths, rule names, severity summary", async () => {
|
|
25
|
-
const cwd = "/project";
|
|
26
|
-
const stdout = JSON.stringify({
|
|
27
|
-
"/project/docs/readme.md": [
|
|
28
|
-
{
|
|
29
|
-
Line: 3,
|
|
30
|
-
Message: "Did you really mean 'writen'?",
|
|
31
|
-
Severity: "error",
|
|
32
|
-
Check: "Vale.Spelling",
|
|
33
|
-
Action: { Name: "suggest", Params: ["spellings"] },
|
|
34
|
-
Span: [57, 62],
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
Line: 5,
|
|
38
|
-
Message: "Use 'basically' instead of 'basicly'.",
|
|
39
|
-
Severity: "warning",
|
|
40
|
-
Check: "Vale.Terms",
|
|
41
|
-
Action: { Name: "replace", Params: ["basically"] },
|
|
42
|
-
Span: [10, 17],
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
});
|
|
46
|
-
const result = await parser.parse(makeCtx(stdout, cwd));
|
|
47
|
-
expect(result.status).toBe("fail");
|
|
48
|
-
expect(result.summary).toBe("1 error, 1 warning");
|
|
49
|
-
expect(result.failures).toHaveLength(2);
|
|
50
|
-
expect(result.failures![0].file).toBe("docs/readme.md");
|
|
51
|
-
expect(result.failures![0].rule).toBe("Vale.Spelling");
|
|
52
|
-
expect(result.failures![1].rule).toBe("Vale.Terms");
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("warnings only → status pass (no errors)", async () => {
|
|
56
|
-
const stdout = JSON.stringify({
|
|
57
|
-
"/project/doc.md": [
|
|
58
|
-
{
|
|
59
|
-
Line: 1,
|
|
60
|
-
Message: "Consider using active voice.",
|
|
61
|
-
Severity: "warning",
|
|
62
|
-
Check: "Vale.Passive",
|
|
63
|
-
Action: {},
|
|
64
|
-
Span: [1, 10],
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
});
|
|
68
|
-
const result = await parser.parse(makeCtx(stdout));
|
|
69
|
-
expect(result.status).toBe("pass");
|
|
70
|
-
expect(result.summary).toBe("1 warning");
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("no alerts → status pass", async () => {
|
|
74
|
-
const result = await parser.parse(makeCtx(JSON.stringify({})));
|
|
75
|
-
expect(result.status).toBe("pass");
|
|
76
|
-
expect(result.summary).toBe("no prose issues");
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("empty stdout → no crash, status pass", async () => {
|
|
80
|
-
const result = await parser.parse(makeCtx(""));
|
|
81
|
-
expect(result.status).toBe("pass");
|
|
82
|
-
expect(result.failures).toHaveLength(0);
|
|
83
|
-
});
|
|
84
|
-
});
|