@robhowley/pi-structured-return 1.9.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.
Files changed (97) hide show
  1. package/README.md +2 -1
  2. package/extensions/structured-return/config/project-config.ts +10 -0
  3. package/extensions/structured-return/config/registry.ts +306 -0
  4. package/extensions/structured-return/examples/.pi/machine-readable.json +18 -0
  5. package/extensions/structured-return/examples/.pi/parsers/foo-cli.ts +25 -0
  6. package/extensions/structured-return/{src/index.ts → index.ts} +94 -69
  7. package/extensions/structured-return/{src/parsers → parsers}/ava-text.ts +23 -15
  8. package/extensions/structured-return/{src/parsers → parsers}/bandit-json.ts +17 -15
  9. package/extensions/structured-return/{src/parsers → parsers}/black-text.ts +18 -18
  10. package/extensions/structured-return/{src/parsers → parsers}/cargo-build.ts +19 -14
  11. package/extensions/structured-return/{src/parsers → parsers}/cargo-test.ts +20 -19
  12. package/extensions/structured-return/parsers/checkstyle-xml.ts +183 -0
  13. package/extensions/structured-return/{src/parsers → parsers}/clang-text.ts +15 -13
  14. package/extensions/structured-return/{src/parsers → parsers}/dbt-json.ts +28 -23
  15. package/extensions/structured-return/{src/parsers → parsers}/dotnet-build-text.ts +10 -8
  16. package/extensions/structured-return/{src/parsers → parsers}/eslint-json.ts +15 -9
  17. package/extensions/structured-return/{src/parsers → parsers}/go-test-json.ts +23 -21
  18. package/extensions/structured-return/{src/parsers → parsers}/hadolint-json.ts +18 -12
  19. package/extensions/structured-return/{src/parsers → parsers}/htmlhint-json.ts +15 -13
  20. package/extensions/structured-return/{src/parsers → parsers}/isort-text.ts +18 -18
  21. package/extensions/structured-return/{src/parsers → parsers}/javac-text.ts +14 -12
  22. package/extensions/structured-return/{src/parsers → parsers}/jsonlint-text.ts +16 -14
  23. package/extensions/structured-return/{src/parsers → parsers}/junit-xml.ts +61 -43
  24. package/extensions/structured-return/{src/parsers → parsers}/markdownlint-json.ts +19 -17
  25. package/extensions/structured-return/{src/parsers → parsers}/minitest-text.ts +24 -15
  26. package/extensions/structured-return/{src/parsers → parsers}/mocha-json.ts +17 -10
  27. package/extensions/structured-return/{src/parsers → parsers}/mypy-json.ts +16 -16
  28. package/extensions/structured-return/{src/parsers → parsers}/node-test-text.ts +17 -14
  29. package/extensions/structured-return/{src/parsers → parsers}/npm-audit-json.ts +19 -16
  30. package/extensions/structured-return/{src/parsers → parsers}/prettier-text.ts +21 -17
  31. package/extensions/structured-return/{src/parsers → parsers}/pylint-json.ts +17 -17
  32. package/extensions/structured-return/{src/parsers → parsers}/pyright-json.ts +20 -18
  33. package/extensions/structured-return/{src/parsers → parsers}/rspec-json.ts +14 -14
  34. package/extensions/structured-return/{src/parsers → parsers}/rubocop-json.ts +22 -11
  35. package/extensions/structured-return/{src/parsers → parsers}/ruff-json.ts +7 -7
  36. package/extensions/structured-return/{src/parsers → parsers}/shellcheck-json.ts +14 -14
  37. package/extensions/structured-return/{src/parsers → parsers}/stylelint-json.ts +21 -13
  38. package/extensions/structured-return/{src/parsers → parsers}/swiftc-text.ts +16 -10
  39. package/extensions/structured-return/parsers/tail-fallback.ts +20 -0
  40. package/extensions/structured-return/{src/parsers → parsers}/tidy-text.ts +13 -13
  41. package/extensions/structured-return/{src/parsers → parsers}/tsc-text.ts +11 -11
  42. package/extensions/structured-return/{src/parsers → parsers}/unittest-text.ts +24 -14
  43. package/extensions/structured-return/{src/parsers → parsers}/utils.ts +9 -6
  44. package/extensions/structured-return/{src/parsers → parsers}/vale-json.ts +18 -18
  45. package/extensions/structured-return/{src/parsers → parsers}/vitest-json.ts +14 -14
  46. package/extensions/structured-return/{src/storage → storage}/log-store.ts +5 -5
  47. package/extensions/structured-return/{src/storage → storage}/session-stats.ts +11 -11
  48. package/extensions/structured-return/{src/types.ts → types.ts} +4 -2
  49. package/package.json +27 -43
  50. package/skills/structured-return/SKILL.md +7 -0
  51. package/LICENSE +0 -21
  52. package/extensions/structured-return/src/config/project-config.ts +0 -10
  53. package/extensions/structured-return/src/config/registry.test.ts +0 -171
  54. package/extensions/structured-return/src/config/registry.ts +0 -282
  55. package/extensions/structured-return/src/index.test.ts +0 -220
  56. package/extensions/structured-return/src/parsers/ava-text.test.ts +0 -116
  57. package/extensions/structured-return/src/parsers/bandit-json.test.ts +0 -90
  58. package/extensions/structured-return/src/parsers/black-text.test.ts +0 -67
  59. package/extensions/structured-return/src/parsers/cargo-build.test.ts +0 -170
  60. package/extensions/structured-return/src/parsers/cargo-test.test.ts +0 -191
  61. package/extensions/structured-return/src/parsers/clang-text.test.ts +0 -61
  62. package/extensions/structured-return/src/parsers/dbt-json.test.ts +0 -172
  63. package/extensions/structured-return/src/parsers/dotnet-build-text.test.ts +0 -85
  64. package/extensions/structured-return/src/parsers/eslint-json.test.ts +0 -60
  65. package/extensions/structured-return/src/parsers/go-test-json.test.ts +0 -119
  66. package/extensions/structured-return/src/parsers/hadolint-json.test.ts +0 -73
  67. package/extensions/structured-return/src/parsers/htmlhint-json.test.ts +0 -72
  68. package/extensions/structured-return/src/parsers/isort-text.test.ts +0 -58
  69. package/extensions/structured-return/src/parsers/javac-text.test.ts +0 -75
  70. package/extensions/structured-return/src/parsers/jsonlint-text.test.ts +0 -52
  71. package/extensions/structured-return/src/parsers/junit-xml.test.ts +0 -627
  72. package/extensions/structured-return/src/parsers/markdownlint-json.test.ts +0 -76
  73. package/extensions/structured-return/src/parsers/minitest-text.test.ts +0 -110
  74. package/extensions/structured-return/src/parsers/mocha-json.test.ts +0 -108
  75. package/extensions/structured-return/src/parsers/mypy-json.test.ts +0 -101
  76. package/extensions/structured-return/src/parsers/node-test-text.test.ts +0 -117
  77. package/extensions/structured-return/src/parsers/npm-audit-json.test.ts +0 -83
  78. package/extensions/structured-return/src/parsers/prettier-text.test.ts +0 -76
  79. package/extensions/structured-return/src/parsers/pylint-json.test.ts +0 -120
  80. package/extensions/structured-return/src/parsers/pyright-json.test.ts +0 -112
  81. package/extensions/structured-return/src/parsers/rspec-json.test.ts +0 -126
  82. package/extensions/structured-return/src/parsers/rubocop-json.test.ts +0 -118
  83. package/extensions/structured-return/src/parsers/ruff-json.test.ts +0 -57
  84. package/extensions/structured-return/src/parsers/shellcheck-json.test.ts +0 -110
  85. package/extensions/structured-return/src/parsers/stylelint-json.test.ts +0 -120
  86. package/extensions/structured-return/src/parsers/swiftc-text.test.ts +0 -73
  87. package/extensions/structured-return/src/parsers/tail-fallback.test.ts +0 -41
  88. package/extensions/structured-return/src/parsers/tail-fallback.ts +0 -20
  89. package/extensions/structured-return/src/parsers/tidy-text.test.ts +0 -74
  90. package/extensions/structured-return/src/parsers/tsc-text.test.ts +0 -81
  91. package/extensions/structured-return/src/parsers/unittest-text.test.ts +0 -126
  92. package/extensions/structured-return/src/parsers/vale-json.test.ts +0 -84
  93. package/extensions/structured-return/src/parsers/vitest-json.test.ts +0 -118
  94. package/extensions/structured-return/src/storage/session-stats.test.ts +0 -156
  95. package/extensions/structured-return/tsconfig.json +0 -11
  96. package/extensions/structured-return/vitest.config.ts +0 -9
  97. /package/extensions/structured-return/{src/ui → ui}/widget.ts +0 -0
@@ -1,172 +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 "./dbt-json";
6
- import type { RunContext } from "../types";
7
-
8
- const SAMPLES_DIR = path.resolve(__dirname, "../../../../benchmarks/pipeline-tools/dbt");
9
-
10
- function makeCtx(stdout: string, cwd = "/project"): RunContext {
11
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), "dbt-test-"));
12
- const stdoutPath = path.join(dir, "stdout");
13
- fs.writeFileSync(stdoutPath, stdout);
14
- return {
15
- command: "dbt run --log-format json",
16
- argv: ["dbt", "run", "--log-format", "json"],
17
- cwd,
18
- artifactPaths: [],
19
- stdoutPath,
20
- stderrPath: path.join(dir, "stderr"),
21
- logPath: path.join(dir, "log"),
22
- };
23
- }
24
-
25
- function loadSample(filename: string): string {
26
- return fs.readFileSync(path.join(SAMPLES_DIR, filename), "utf8");
27
- }
28
-
29
- describe("dbt-json parser", () => {
30
- describe("dbt run success", () => {
31
- it("3 models pass → status pass, correct summary, no failures", async () => {
32
- const result = await parser.parse(makeCtx(loadSample("dbt-run-success.jsonl")));
33
- expect(result.status).toBe("pass");
34
- expect(result.summary).toBe("3 passed in 34.22s");
35
- expect(result.failures).toHaveLength(0);
36
- });
37
- });
38
-
39
- describe("dbt run failure", () => {
40
- it("2 errors, 1 skip → status fail, both errors surfaced with node name and path", async () => {
41
- const result = await parser.parse(makeCtx(loadSample("dbt-run-failure.jsonl")));
42
- expect(result.status).toBe("fail");
43
- expect(result.summary).toMatch(/2 failed/);
44
- expect(result.summary).toMatch(/1 passed/);
45
- expect(result.summary).toMatch(/1 skipped/);
46
- expect(result.summary).toMatch(/34\.22s/);
47
- expect(result.failures).toHaveLength(2);
48
-
49
- const dbErr = result.failures![0];
50
- expect(dbErr.id).toBe("mart__core__daily_active_customers");
51
- expect(dbErr.file).toBe("models/mart/core/mart__core__daily_active_customers.sql");
52
- expect(dbErr.message).toMatch(/Column customer_id in USING clause not found/);
53
-
54
- const rtErr = result.failures![1];
55
- expect(rtErr.id).toBe("mart__core__daily_summary");
56
- expect(rtErr.file).toBe("models/mart/core/mart__core__daily_summary.sql");
57
- expect(rtErr.message).toMatch(/Access Denied/);
58
- });
59
- });
60
-
61
- describe("dbt test failure", () => {
62
- it("2 errors → status fail, both errors surfaced", async () => {
63
- const result = await parser.parse(makeCtx(loadSample("dbt-test-failure.jsonl")));
64
- expect(result.status).toBe("fail");
65
- expect(result.summary).toMatch(/2 failed/);
66
- expect(result.summary).toMatch(/1 passed/);
67
- expect(result.failures).toHaveLength(2);
68
- });
69
-
70
- it("uniqueness test failure has result count in message", async () => {
71
- const result = await parser.parse(makeCtx(loadSample("dbt-test-failure.jsonl")));
72
- const uniqueTest = result.failures!.find((f) => f.id.includes("unique_"));
73
- expect(uniqueTest).toBeDefined();
74
- expect(uniqueTest!.message).toMatch(/Got 3 results/);
75
- expect(uniqueTest!.file).toBe("models/mart/core/_core__models.yml");
76
- });
77
-
78
- it("unit test failure preserves actual/expected diff table", async () => {
79
- const result = await parser.parse(makeCtx(loadSample("dbt-test-failure.jsonl")));
80
- const unitTest = result.failures!.find((f) => f.id.includes("unit_test"));
81
- expect(unitTest).toBeDefined();
82
- expect(unitTest!.message).toMatch(/actual differs from expected/);
83
- expect(unitTest!.message).toMatch(/engagement_score/);
84
- expect(unitTest!.message).toMatch(/85\.5/);
85
- expect(unitTest!.message).toMatch(/90\.0/);
86
- });
87
-
88
- it("warnings are included with [warn] prefix when present", async () => {
89
- // Inline JSONL with a warning event
90
- const jsonl = [
91
- JSON.stringify({
92
- data: {
93
- msg: "Got 12 results, configured to warn if != 0",
94
- node_info: { node_name: "relationships_test", node_path: "models/test.yml", node_status: "warn" },
95
- },
96
- info: { name: "RunResultWarning", level: "warn", msg: "Got 12 results" },
97
- }),
98
- JSON.stringify({
99
- data: { elapsed_time: 5.0, num_errors: 0, num_warnings: 1, num_skipped: 0 },
100
- info: { name: "EndOfRunSummary", level: "info", msg: "Done. PASS=2 WARN=1 ERROR=0 SKIP=0 TOTAL=3" },
101
- }),
102
- ].join("\n");
103
- const result = await parser.parse(makeCtx(jsonl));
104
- expect(result.status).toBe("pass");
105
- const warning = result.failures!.find((f) => f.id === "relationships_test");
106
- expect(warning).toBeDefined();
107
- expect(warning!.message).toMatch(/^\[warn\]/);
108
- });
109
- });
110
-
111
- describe("dbt compile success", () => {
112
- it("3 models compiled, all SQL returned in rawTail", async () => {
113
- const result = await parser.parse(makeCtx(loadSample("dbt-compile.jsonl")));
114
- expect(result.status).toBe("pass");
115
- expect(result.summary).toMatch(/compiled 3 models/);
116
- expect(result.summary).toMatch(/mart__core__customer_engagement/);
117
- expect(result.summary).toMatch(/mart__core__daily_summary/);
118
- expect(result.failures).toHaveLength(0);
119
- expect(result.rawTail).toBeDefined();
120
- expect(result.rawTail).toMatch(/WITH user_events AS/);
121
- expect(result.rawTail).toMatch(/-- mart__core__daily_active_customers/);
122
- expect(result.rawTail).toMatch(/-- mart__core__daily_summary/);
123
- });
124
- });
125
-
126
- describe("dbt compile failure", () => {
127
- it("no summary + no compiled nodes → status error", async () => {
128
- // Simulate a compile failure: error-level message, no EndOfRunSummary, no CompiledNode
129
- const jsonl = [
130
- JSON.stringify({
131
- data: {},
132
- info: { name: "MainReportVersion", level: "info", msg: "Running with dbt=1.8.4" },
133
- }),
134
- JSON.stringify({
135
- data: {},
136
- info: {
137
- name: "CompilationError",
138
- level: "error",
139
- msg: "Compilation Error in model mart__core__customer_engagement (models/mart/core/mart__core__customer_engagement.sql)\n Model 'ref(\"stg__missing_model\")' was not found",
140
- },
141
- }),
142
- ].join("\n");
143
-
144
- const result = await parser.parse(makeCtx(jsonl));
145
- expect(result.status).toBe("error");
146
- expect(result.summary).toBe("1 error");
147
- expect(result.failures).toHaveLength(1);
148
- expect(result.failures![0].message).toMatch(/stg__missing_model/);
149
- });
150
- });
151
-
152
- describe("empty / malformed input", () => {
153
- it("empty stdout → error status, no crash", async () => {
154
- const result = await parser.parse(makeCtx(""));
155
- expect(result.status).toBe("error");
156
- expect(result.failures).toHaveLength(0);
157
- });
158
-
159
- it("non-JSON lines are skipped gracefully", async () => {
160
- const input =
161
- "some garbage\n" +
162
- JSON.stringify({
163
- data: { elapsed_time: 1.0, num_errors: 0, num_warnings: 0, num_skipped: 0 },
164
- info: { name: "EndOfRunSummary", level: "info", msg: "Done. PASS=1 WARN=0 ERROR=0 SKIP=0 TOTAL=1" },
165
- }) +
166
- "\nmore garbage";
167
- const result = await parser.parse(makeCtx(input));
168
- expect(result.status).toBe("pass");
169
- expect(result.summary).toBe("1 passed in 1.00s");
170
- });
171
- });
172
- });
@@ -1,85 +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 "./dotnet-build-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(), "dotnet-build-test-"));
10
- const stdoutPath = path.join(dir, "stdout");
11
- const stderrPath = path.join(dir, "stderr");
12
- fs.writeFileSync(stdoutPath, stdout);
13
- fs.writeFileSync(stderrPath, "");
14
- return {
15
- command: "dotnet build",
16
- argv: ["dotnet", "build"],
17
- cwd,
18
- artifactPaths: [],
19
- stdoutPath,
20
- stderrPath,
21
- logPath: path.join(dir, "log"),
22
- };
23
- }
24
-
25
- describe("dotnet-build-text parser", () => {
26
- it("duplicated errors → deduplicated, relative paths, rule code extracted", async () => {
27
- const cwd = "/project";
28
- const stdout = ` Determining projects to restore...
29
- All projects are up-to-date for restore.
30
- /project/src/App.cs(7,25): error CS0029: Cannot implicitly convert type 'int' to 'string' [/project/src/App.csproj]
31
- /project/src/App.cs(8,16): error CS0029: Cannot implicitly convert type 'string' to 'int' [/project/src/App.csproj]
32
-
33
- Build FAILED.
34
-
35
- /project/src/App.cs(7,25): error CS0029: Cannot implicitly convert type 'int' to 'string' [/project/src/App.csproj]
36
- /project/src/App.cs(8,16): error CS0029: Cannot implicitly convert type 'string' to 'int' [/project/src/App.csproj]
37
- 0 Warning(s)
38
- 2 Error(s)
39
-
40
- Time Elapsed 00:00:01.58`;
41
- const result = await parser.parse(makeCtx(stdout, cwd));
42
- expect(result.status).toBe("fail");
43
- expect(result.summary).toBe("2 errors");
44
- expect(result.failures).toHaveLength(2); // deduplicated from 4 lines
45
- expect(result.failures![0].file).toBe("src/App.cs");
46
- expect(result.failures![0].line).toBe(7);
47
- expect(result.failures![0].rule).toBe("CS0029");
48
- });
49
-
50
- it("no errors → status pass", async () => {
51
- const stdout = ` Determining projects to restore...
52
- All projects are up-to-date for restore.
53
- App -> /project/bin/Debug/net10.0/App.dll
54
-
55
- Build succeeded.
56
- 0 Warning(s)
57
- 0 Error(s)
58
-
59
- Time Elapsed 00:00:01.00`;
60
- const result = await parser.parse(makeCtx(stdout));
61
- expect(result.status).toBe("pass");
62
- expect(result.summary).toBe("build succeeded");
63
- expect(result.failures).toHaveLength(0);
64
- });
65
-
66
- it("empty stdout → no crash, status pass", async () => {
67
- const result = await parser.parse(makeCtx(""));
68
- expect(result.status).toBe("pass");
69
- expect(result.failures).toHaveLength(0);
70
- });
71
-
72
- it("single error → singular 'error' in summary", async () => {
73
- const stdout = `/project/a.cs(1,1): error CS0246: The type or namespace name 'Foo' could not be found [/project/a.csproj]
74
-
75
- Build FAILED.
76
-
77
- /project/a.cs(1,1): error CS0246: The type or namespace name 'Foo' could not be found [/project/a.csproj]
78
- 0 Warning(s)
79
- 1 Error(s)`;
80
- const result = await parser.parse(makeCtx(stdout));
81
- expect(result.status).toBe("fail");
82
- expect(result.summary).toBe("1 error");
83
- expect(result.failures).toHaveLength(1);
84
- });
85
- });
@@ -1,60 +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 "./eslint-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(), "eslint-test-"));
10
- const stdoutPath = path.join(dir, "stdout");
11
- fs.writeFileSync(stdoutPath, stdout);
12
- return {
13
- command: "eslint . -f json",
14
- argv: ["eslint", ".", "-f", "json"],
15
- cwd,
16
- artifactPaths: [],
17
- stdoutPath,
18
- stderrPath: path.join(dir, "stderr"),
19
- logPath: path.join(dir, "log"),
20
- };
21
- }
22
-
23
- describe("eslint-json parser", () => {
24
- it("multiple errors across multiple files → correct relative paths, correct failure count, status fail", async () => {
25
- const cwd = "/project";
26
- const stdout = JSON.stringify([
27
- {
28
- filePath: "/project/src/foo.ts",
29
- messages: [
30
- { line: 10, ruleId: "@typescript-eslint/no-explicit-any", message: "Unexpected any." },
31
- { line: 12, ruleId: "@typescript-eslint/no-explicit-any", message: "Unexpected any." },
32
- ],
33
- },
34
- {
35
- filePath: "/project/src/bar.ts",
36
- messages: [{ line: 3, ruleId: "no-unused-vars", message: "x is defined but never used." }],
37
- },
38
- ]);
39
- const result = await parser.parse(makeCtx(stdout, cwd));
40
- expect(result.status).toBe("fail");
41
- expect(result.failures).toHaveLength(3);
42
- expect(result.failures![0].file).toBe("src/foo.ts");
43
- expect(result.failures![1].file).toBe("src/foo.ts");
44
- expect(result.failures![2].file).toBe("src/bar.ts");
45
- expect(result.failures![0].file).not.toContain("/project");
46
- });
47
-
48
- it("no errors → empty failures, status pass", async () => {
49
- const stdout = JSON.stringify([{ filePath: "/project/src/foo.ts", messages: [] }]);
50
- const result = await parser.parse(makeCtx(stdout));
51
- expect(result.status).toBe("pass");
52
- expect(result.failures).toHaveLength(0);
53
- });
54
-
55
- it("empty stdout → no crash, status pass", async () => {
56
- const result = await parser.parse(makeCtx(""));
57
- expect(result.status).toBe("pass");
58
- expect(result.failures).toHaveLength(0);
59
- });
60
- });
@@ -1,119 +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 "./go-test-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(), "gotest-test-"));
10
- const stdoutPath = path.join(dir, "stdout");
11
- fs.writeFileSync(stdoutPath, stdout);
12
- return {
13
- command: "go test -json ./...",
14
- argv: ["go", "test", "-json", "./..."],
15
- cwd,
16
- artifactPaths: [],
17
- stdoutPath,
18
- stderrPath: path.join(dir, "stderr"),
19
- logPath: path.join(dir, "log"),
20
- };
21
- }
22
-
23
- function ndjson(...events: object[]): string {
24
- return events.map((e) => JSON.stringify(e)).join("\n");
25
- }
26
-
27
- describe("go-test-json parser", () => {
28
- it("assertion failure → file:line and message from t.Errorf output", async () => {
29
- const stdout = ndjson(
30
- { Action: "run", Package: "math-test", Test: "TestAdd" },
31
- { Action: "output", Package: "math-test", Test: "TestAdd", Output: "=== RUN TestAdd\n" },
32
- { Action: "output", Package: "math-test", Test: "TestAdd", Output: "--- PASS: TestAdd (0.00s)\n" },
33
- { Action: "pass", Package: "math-test", Test: "TestAdd" },
34
- { Action: "run", Package: "math-test", Test: "TestMultiply" },
35
- { Action: "output", Package: "math-test", Test: "TestMultiply", Output: "=== RUN TestMultiply\n" },
36
- {
37
- Action: "output",
38
- Package: "math-test",
39
- Test: "TestMultiply",
40
- Output: " math_test.go:14: expected 99, got 12\n",
41
- },
42
- { Action: "output", Package: "math-test", Test: "TestMultiply", Output: "--- FAIL: TestMultiply (0.00s)\n" },
43
- { Action: "fail", Package: "math-test", Test: "TestMultiply" },
44
- { Action: "fail", Package: "math-test", Elapsed: 0.1 }
45
- );
46
- const result = await parser.parse(makeCtx(stdout));
47
- expect(result.status).toBe("fail");
48
- expect(result.summary).toBe("1 failed, 1 passed");
49
- expect(result.failures).toHaveLength(1);
50
- expect(result.failures![0]).toMatchObject({
51
- file: "math_test.go",
52
- line: 14,
53
- message: "expected 99, got 12",
54
- });
55
- });
56
-
57
- it("panic → message and user-code file:line from stack trace", async () => {
58
- const stdout = ndjson(
59
- { Action: "run", Package: "math-test", Test: "TestDoesNotPanic" },
60
- { Action: "output", Package: "math-test", Test: "TestDoesNotPanic", Output: "=== RUN TestDoesNotPanic\n" },
61
- {
62
- Action: "output",
63
- Package: "math-test",
64
- Test: "TestDoesNotPanic",
65
- Output: "--- FAIL: TestDoesNotPanic (0.00s)\n",
66
- },
67
- {
68
- Action: "output",
69
- Package: "math-test",
70
- Test: "TestDoesNotPanic",
71
- Output: "panic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked]\n",
72
- },
73
- { Action: "output", Package: "math-test", Test: "TestDoesNotPanic", Output: "goroutine 23 [running]:\n" },
74
- {
75
- Action: "output",
76
- Package: "math-test",
77
- Test: "TestDoesNotPanic",
78
- Output: "testing.tRunner.func1.2({0x1003f2be0, 0x10043cec0})\n",
79
- },
80
- {
81
- Action: "output",
82
- Package: "math-test",
83
- Test: "TestDoesNotPanic",
84
- Output: "\t/usr/local/go/src/testing/testing.go:1974 +0x1a0\n",
85
- },
86
- {
87
- Action: "output",
88
- Package: "math-test",
89
- Test: "TestDoesNotPanic",
90
- Output: "math-test.TestDoesNotPanic(0x123)\n",
91
- },
92
- { Action: "output", Package: "math-test", Test: "TestDoesNotPanic", Output: "\t/project/math_test.go:20 +0x4\n" },
93
- { Action: "fail", Package: "math-test", Test: "TestDoesNotPanic" },
94
- { Action: "fail", Package: "math-test", Elapsed: 0.1 }
95
- );
96
- const result = await parser.parse(makeCtx(stdout, "/project"));
97
- expect(result.failures).toHaveLength(1);
98
- expect(result.failures![0].message).toBe("runtime error: invalid memory address or nil pointer dereference");
99
- expect(result.failures![0].file).toBe("math_test.go");
100
- expect(result.failures![0].line).toBe(20);
101
- });
102
-
103
- it("all passing → status pass", async () => {
104
- const stdout = ndjson(
105
- { Action: "run", Package: "math-test", Test: "TestAdd" },
106
- { Action: "pass", Package: "math-test", Test: "TestAdd" },
107
- { Action: "pass", Package: "math-test", Elapsed: 0.1 }
108
- );
109
- const result = await parser.parse(makeCtx(stdout));
110
- expect(result.status).toBe("pass");
111
- expect(result.summary).toBe("1 passed");
112
- expect(result.failures).toHaveLength(0);
113
- });
114
-
115
- it("empty stdout → status error", async () => {
116
- const result = await parser.parse(makeCtx(""));
117
- expect(result.status).toBe("error");
118
- });
119
- });
@@ -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 "./hadolint-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(), "hadolint-test-"));
10
- const stdoutPath = path.join(dir, "stdout");
11
- fs.writeFileSync(stdoutPath, stdout);
12
- return {
13
- command: "hadolint Dockerfile --format json",
14
- argv: ["hadolint", "Dockerfile", "--format", "json"],
15
- cwd,
16
- artifactPaths: [],
17
- stdoutPath,
18
- stderrPath: path.join(dir, "stderr"),
19
- logPath: path.join(dir, "log"),
20
- };
21
- }
22
-
23
- describe("hadolint-json parser", () => {
24
- it("multiple errors → correct file, line, message, rule", async () => {
25
- const stdout = JSON.stringify([
26
- {
27
- code: "DL3007",
28
- column: 1,
29
- file: "Dockerfile",
30
- level: "warning",
31
- line: 1,
32
- message: "Using latest is prone to errors.",
33
- },
34
- {
35
- code: "DL3008",
36
- column: 1,
37
- file: "Dockerfile",
38
- level: "warning",
39
- line: 2,
40
- message: "Pin versions in apt get install.",
41
- },
42
- ]);
43
- const result = await parser.parse(makeCtx(stdout));
44
- expect(result.status).toBe("fail");
45
- expect(result.summary).toBe("2 lint errors");
46
- expect(result.failures![0]).toMatchObject({
47
- file: "Dockerfile",
48
- line: 1,
49
- message: "Using latest is prone to errors.",
50
- rule: "DL3007",
51
- });
52
- expect(result.failures![1]).toMatchObject({ rule: "DL3008" });
53
- });
54
-
55
- it("empty array → status pass", async () => {
56
- const result = await parser.parse(makeCtx("[]"));
57
- expect(result.status).toBe("pass");
58
- expect(result.failures).toHaveLength(0);
59
- });
60
-
61
- it("empty stdout → status pass", async () => {
62
- const result = await parser.parse(makeCtx(""));
63
- expect(result.status).toBe("pass");
64
- });
65
-
66
- it("absolute paths → relativized", async () => {
67
- const stdout = JSON.stringify([
68
- { code: "DL3003", column: 1, file: "/project/Dockerfile", level: "warning", line: 3, message: "Use WORKDIR" },
69
- ]);
70
- const result = await parser.parse(makeCtx(stdout, "/project"));
71
- expect(result.failures![0].file).toBe("Dockerfile");
72
- });
73
- });
@@ -1,72 +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 "./htmlhint-json";
6
- import type { RunContext } from "../types";
7
-
8
- function makeCtx(stderr: string, cwd = "/project"): RunContext {
9
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), "htmlhint-test-"));
10
- const stdoutPath = path.join(dir, "stdout");
11
- const stderrPath = path.join(dir, "stderr");
12
- fs.writeFileSync(stdoutPath, "");
13
- fs.writeFileSync(stderrPath, stderr);
14
- return {
15
- command: "npx htmlhint --format json .",
16
- argv: ["npx", "htmlhint", "--format", "json", "."],
17
- cwd,
18
- artifactPaths: [],
19
- stdoutPath,
20
- stderrPath,
21
- logPath: path.join(dir, "log"),
22
- };
23
- }
24
-
25
- describe("htmlhint-json parser", () => {
26
- it("multiple errors → correct relative paths, rule IDs, messages", async () => {
27
- const cwd = "/project";
28
- const stderr = JSON.stringify([
29
- {
30
- file: "/project/src/index.html",
31
- messages: [
32
- {
33
- type: "error",
34
- message: "Doctype must be declared before any non-comment content.",
35
- line: 1,
36
- col: 1,
37
- rule: { id: "doctype-first", description: "...", link: "https://example.com" },
38
- },
39
- {
40
- type: "error",
41
- message: "The html element name of [ DIV ] must be in lowercase.",
42
- line: 5,
43
- col: 1,
44
- rule: { id: "tagname-lowercase", description: "...", link: "https://example.com" },
45
- },
46
- ],
47
- time: 1,
48
- },
49
- ]);
50
- const result = await parser.parse(makeCtx(stderr, cwd));
51
- expect(result.status).toBe("fail");
52
- expect(result.summary).toBe("2 lint errors");
53
- expect(result.failures).toHaveLength(2);
54
- expect(result.failures![0].file).toBe("src/index.html");
55
- expect(result.failures![0].rule).toBe("doctype-first");
56
- expect(result.failures![1].line).toBe(5);
57
- // No URLs in output
58
- expect(result.failures![0].message).not.toContain("https://");
59
- });
60
-
61
- it("no errors → status pass", async () => {
62
- const result = await parser.parse(makeCtx(JSON.stringify([])));
63
- expect(result.status).toBe("pass");
64
- expect(result.failures).toHaveLength(0);
65
- });
66
-
67
- it("empty output → no crash, status pass", async () => {
68
- const result = await parser.parse(makeCtx(""));
69
- expect(result.status).toBe("pass");
70
- expect(result.failures).toHaveLength(0);
71
- });
72
- });
@@ -1,58 +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 "./isort-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(), "isort-test-"));
10
- const stdoutPath = path.join(dir, "stdout");
11
- const stderrPath = path.join(dir, "stderr");
12
- fs.writeFileSync(stdoutPath, "");
13
- fs.writeFileSync(stderrPath, stderr);
14
- return {
15
- command: "isort --check --diff .",
16
- argv: ["isort", "--check", "--diff", "."],
17
- cwd,
18
- artifactPaths: [],
19
- stdoutPath,
20
- stderrPath,
21
- logPath: path.join(dir, "log"),
22
- };
23
- }
24
-
25
- describe("isort-text parser", () => {
26
- it("unsorted imports with diff → strips diff, extracts file, status fail", async () => {
27
- const cwd = "/project";
28
- const stderr = `ERROR: /project/src/app.py Imports are incorrectly sorted and/or formatted.
29
- --- /project/src/app.py:before\t2026-03-19 18:00:00
30
- +++ /project/src/app.py:after\t2026-03-19 18:00:00
31
- @@ -1,3 +1,3 @@
32
- +import json
33
- import os
34
- -import json
35
- ERROR: /project/src/utils.py Imports are incorrectly sorted and/or formatted.`;
36
- const result = await parser.parse(makeCtx(stderr, cwd));
37
- expect(result.status).toBe("fail");
38
- expect(result.summary).toBe("2 files have incorrectly sorted imports");
39
- expect(result.failures).toHaveLength(2);
40
- expect(result.failures![0].file).toBe("src/app.py");
41
- expect(result.failures![1].file).toBe("src/utils.py");
42
- // No diff content in failures
43
- expect(result.failures![0].message).not.toContain("---");
44
- });
45
-
46
- it("all sorted → status pass", async () => {
47
- const result = await parser.parse(makeCtx(""));
48
- expect(result.status).toBe("pass");
49
- expect(result.summary).toBe("all imports sorted");
50
- expect(result.failures).toHaveLength(0);
51
- });
52
-
53
- it("single file → singular grammar", async () => {
54
- const stderr = `ERROR: /project/bad.py Imports are incorrectly sorted and/or formatted.`;
55
- const result = await parser.parse(makeCtx(stderr));
56
- expect(result.summary).toBe("1 file has incorrectly sorted imports");
57
- });
58
- });