@robhowley/pi-structured-return 1.9.0 → 1.10.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/README.md +2 -1
- 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 +61 -43
- 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 +29 -44
- package/skills/structured-return/SKILL.md +7 -0
- 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 -627
- 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 "./pylint-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(), "pylint-test-"));
|
|
10
|
-
const stdoutPath = path.join(dir, "stdout");
|
|
11
|
-
fs.writeFileSync(stdoutPath, stdout);
|
|
12
|
-
return {
|
|
13
|
-
command: "pylint lint_check.py --output-format=json",
|
|
14
|
-
argv: ["pylint", "lint_check.py", "--output-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("pylint-json parser", () => {
|
|
24
|
-
it("multiple lint errors → correct file, line, message, rule, status fail", async () => {
|
|
25
|
-
const stdout = JSON.stringify([
|
|
26
|
-
{
|
|
27
|
-
type: "warning",
|
|
28
|
-
module: "lint_check",
|
|
29
|
-
obj: "process_order",
|
|
30
|
-
line: 5,
|
|
31
|
-
column: 4,
|
|
32
|
-
endLine: 5,
|
|
33
|
-
endColumn: 12,
|
|
34
|
-
path: "lint_check.py",
|
|
35
|
-
symbol: "unused-variable",
|
|
36
|
-
message: "Unused variable 'discount'",
|
|
37
|
-
"message-id": "W0612",
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
type: "warning",
|
|
41
|
-
module: "lint_check",
|
|
42
|
-
obj: "",
|
|
43
|
-
line: 1,
|
|
44
|
-
column: 0,
|
|
45
|
-
endLine: 1,
|
|
46
|
-
endColumn: 9,
|
|
47
|
-
path: "lint_check.py",
|
|
48
|
-
symbol: "unused-import",
|
|
49
|
-
message: "Unused import os",
|
|
50
|
-
"message-id": "W0611",
|
|
51
|
-
},
|
|
52
|
-
]);
|
|
53
|
-
const result = await parser.parse(makeCtx(stdout));
|
|
54
|
-
expect(result.status).toBe("fail");
|
|
55
|
-
expect(result.summary).toBe("2 lint errors");
|
|
56
|
-
expect(result.failures).toHaveLength(2);
|
|
57
|
-
expect(result.failures![0]).toMatchObject({
|
|
58
|
-
file: "lint_check.py",
|
|
59
|
-
line: 5,
|
|
60
|
-
message: "Unused variable 'discount'",
|
|
61
|
-
rule: "W0612(unused-variable)",
|
|
62
|
-
});
|
|
63
|
-
expect(result.failures![1]).toMatchObject({
|
|
64
|
-
file: "lint_check.py",
|
|
65
|
-
line: 1,
|
|
66
|
-
message: "Unused import os",
|
|
67
|
-
rule: "W0611(unused-import)",
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("no errors (empty array) → status pass", async () => {
|
|
72
|
-
const result = await parser.parse(makeCtx("[]"));
|
|
73
|
-
expect(result.status).toBe("pass");
|
|
74
|
-
expect(result.summary).toBe("no lint errors");
|
|
75
|
-
expect(result.failures).toHaveLength(0);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("empty stdout → status pass", async () => {
|
|
79
|
-
const result = await parser.parse(makeCtx(""));
|
|
80
|
-
expect(result.status).toBe("pass");
|
|
81
|
-
expect(result.failures).toHaveLength(0);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("absolute file paths → relativized to cwd", async () => {
|
|
85
|
-
const stdout = JSON.stringify([
|
|
86
|
-
{
|
|
87
|
-
type: "convention",
|
|
88
|
-
module: "foo",
|
|
89
|
-
obj: "",
|
|
90
|
-
line: 1,
|
|
91
|
-
column: 0,
|
|
92
|
-
path: "/project/src/foo.py",
|
|
93
|
-
symbol: "missing-module-docstring",
|
|
94
|
-
message: "Missing module docstring",
|
|
95
|
-
"message-id": "C0114",
|
|
96
|
-
},
|
|
97
|
-
]);
|
|
98
|
-
const result = await parser.parse(makeCtx(stdout, "/project"));
|
|
99
|
-
expect(result.failures![0].file).toBe("src/foo.py");
|
|
100
|
-
expect(result.failures![0].file).not.toContain("/project");
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it("rule includes both message-id and symbol", async () => {
|
|
104
|
-
const stdout = JSON.stringify([
|
|
105
|
-
{
|
|
106
|
-
type: "convention",
|
|
107
|
-
module: "foo",
|
|
108
|
-
obj: "",
|
|
109
|
-
line: 1,
|
|
110
|
-
column: 0,
|
|
111
|
-
path: "foo.py",
|
|
112
|
-
symbol: "line-too-long",
|
|
113
|
-
message: "Line too long (120/100)",
|
|
114
|
-
"message-id": "C0301",
|
|
115
|
-
},
|
|
116
|
-
]);
|
|
117
|
-
const result = await parser.parse(makeCtx(stdout));
|
|
118
|
-
expect(result.failures![0].rule).toBe("C0301(line-too-long)");
|
|
119
|
-
});
|
|
120
|
-
});
|
|
@@ -1,112 +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 "./pyright-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(), "pyright-test-"));
|
|
10
|
-
const stdoutPath = path.join(dir, "stdout");
|
|
11
|
-
fs.writeFileSync(stdoutPath, stdout);
|
|
12
|
-
return {
|
|
13
|
-
command: "pyright --outputjson .",
|
|
14
|
-
argv: ["pyright", "--outputjson", "."],
|
|
15
|
-
cwd,
|
|
16
|
-
artifactPaths: [],
|
|
17
|
-
stdoutPath,
|
|
18
|
-
stderrPath: path.join(dir, "stderr"),
|
|
19
|
-
logPath: path.join(dir, "log"),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
describe("pyright-json parser", () => {
|
|
24
|
-
it("single error → correct relative path, 1-based line, rule mapped, status fail", async () => {
|
|
25
|
-
const cwd = "/project";
|
|
26
|
-
const stdout = JSON.stringify({
|
|
27
|
-
version: "1.1.408",
|
|
28
|
-
generalDiagnostics: [
|
|
29
|
-
{
|
|
30
|
-
file: "/project/src/app.py",
|
|
31
|
-
severity: "error",
|
|
32
|
-
message: 'Type "str" is not assignable to declared type "int"\n "str" is not assignable to "int"',
|
|
33
|
-
range: { start: { line: 3, character: 14 }, end: { line: 3, character: 28 } },
|
|
34
|
-
rule: "reportAssignmentType",
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
summary: { filesAnalyzed: 1, errorCount: 1, warningCount: 0, informationCount: 0 },
|
|
38
|
-
});
|
|
39
|
-
const result = await parser.parse(makeCtx(stdout, cwd));
|
|
40
|
-
expect(result.status).toBe("fail");
|
|
41
|
-
expect(result.summary).toBe("1 error");
|
|
42
|
-
expect(result.failures).toHaveLength(1);
|
|
43
|
-
expect(result.failures![0].file).toBe("src/app.py");
|
|
44
|
-
expect(result.failures![0].line).toBe(4); // 0-based → 1-based
|
|
45
|
-
expect(result.failures![0].rule).toBe("reportAssignmentType");
|
|
46
|
-
expect(result.failures![0].message).not.toContain("\n");
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("multiple errors across files → correct count and paths", async () => {
|
|
50
|
-
const cwd = "/project";
|
|
51
|
-
const stdout = JSON.stringify({
|
|
52
|
-
generalDiagnostics: [
|
|
53
|
-
{
|
|
54
|
-
file: "/project/a.py",
|
|
55
|
-
severity: "error",
|
|
56
|
-
message: 'Cannot access attribute "foo" for class "Bar"',
|
|
57
|
-
range: { start: { line: 0, character: 0 }, end: { line: 0, character: 5 } },
|
|
58
|
-
rule: "reportAttributeAccessIssue",
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
file: "/project/b.py",
|
|
62
|
-
severity: "error",
|
|
63
|
-
message: 'Argument missing for parameter "x"',
|
|
64
|
-
range: { start: { line: 9, character: 0 }, end: { line: 9, character: 10 } },
|
|
65
|
-
rule: "reportCallIssue",
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
summary: { filesAnalyzed: 2, errorCount: 2, warningCount: 0, informationCount: 0 },
|
|
69
|
-
});
|
|
70
|
-
const result = await parser.parse(makeCtx(stdout, cwd));
|
|
71
|
-
expect(result.status).toBe("fail");
|
|
72
|
-
expect(result.summary).toBe("2 errors");
|
|
73
|
-
expect(result.failures).toHaveLength(2);
|
|
74
|
-
expect(result.failures![0].file).toBe("a.py");
|
|
75
|
-
expect(result.failures![1].file).toBe("b.py");
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("warnings only (no errors) → status pass, empty failures", async () => {
|
|
79
|
-
const stdout = JSON.stringify({
|
|
80
|
-
generalDiagnostics: [
|
|
81
|
-
{
|
|
82
|
-
file: "/project/c.py",
|
|
83
|
-
severity: "warning",
|
|
84
|
-
message: 'Import "os" is not accessed',
|
|
85
|
-
range: { start: { line: 0, character: 0 }, end: { line: 0, character: 9 } },
|
|
86
|
-
rule: "reportUnusedImport",
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
summary: { filesAnalyzed: 1, errorCount: 0, warningCount: 1, informationCount: 0 },
|
|
90
|
-
});
|
|
91
|
-
const result = await parser.parse(makeCtx(stdout));
|
|
92
|
-
expect(result.status).toBe("pass");
|
|
93
|
-
expect(result.summary).toBe("1 warning");
|
|
94
|
-
expect(result.failures).toHaveLength(0);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("no diagnostics → status pass", async () => {
|
|
98
|
-
const stdout = JSON.stringify({
|
|
99
|
-
generalDiagnostics: [],
|
|
100
|
-
summary: { filesAnalyzed: 1, errorCount: 0, warningCount: 0, informationCount: 0 },
|
|
101
|
-
});
|
|
102
|
-
const result = await parser.parse(makeCtx(stdout));
|
|
103
|
-
expect(result.status).toBe("pass");
|
|
104
|
-
expect(result.failures).toHaveLength(0);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("empty stdout → no crash, status pass", async () => {
|
|
108
|
-
const result = await parser.parse(makeCtx(""));
|
|
109
|
-
expect(result.status).toBe("pass");
|
|
110
|
-
expect(result.failures).toHaveLength(0);
|
|
111
|
-
});
|
|
112
|
-
});
|
|
@@ -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 "./rspec-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(), "rspec-test-"));
|
|
10
|
-
const stdoutPath = path.join(dir, "stdout");
|
|
11
|
-
fs.writeFileSync(stdoutPath, stdout);
|
|
12
|
-
return {
|
|
13
|
-
command: "bundle exec rspec --format json",
|
|
14
|
-
argv: ["bundle", "exec", "rspec", "--format", "json"],
|
|
15
|
-
cwd,
|
|
16
|
-
artifactPaths: [],
|
|
17
|
-
stdoutPath,
|
|
18
|
-
stderrPath: path.join(dir, "stderr"),
|
|
19
|
-
logPath: path.join(dir, "log"),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const passing = (id: string, file: string, line: number): object => ({
|
|
24
|
-
id,
|
|
25
|
-
full_description: id,
|
|
26
|
-
status: "passed",
|
|
27
|
-
file_path: file,
|
|
28
|
-
line_number: line,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const failing = (id: string, file: string, line: number, message: string): object => ({
|
|
32
|
-
id,
|
|
33
|
-
full_description: id,
|
|
34
|
-
status: "failed",
|
|
35
|
-
file_path: file,
|
|
36
|
-
line_number: line,
|
|
37
|
-
exception: {
|
|
38
|
-
class: "RSpec::Expectations::ExpectationNotMetError",
|
|
39
|
-
message,
|
|
40
|
-
backtrace: [`${file}:${line}:in 'block (2 levels) in <top (required)>'`],
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
function report(examples: object[], failureCount: number, pendingCount = 0): string {
|
|
45
|
-
return JSON.stringify({
|
|
46
|
-
examples,
|
|
47
|
-
summary: {
|
|
48
|
-
example_count: examples.length,
|
|
49
|
-
failure_count: failureCount,
|
|
50
|
-
pending_count: pendingCount,
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
describe("rspec-json parser", () => {
|
|
56
|
-
it("mix of passed and failed → status fail, correct counts, failures listed", async () => {
|
|
57
|
-
const cwd = "/project";
|
|
58
|
-
const stdout = report(
|
|
59
|
-
[
|
|
60
|
-
passing("Foo does something", "./spec/foo_spec.rb", 5),
|
|
61
|
-
failing("Foo blows up", "./spec/foo_spec.rb", 10, "expected: 2\n got: 1"),
|
|
62
|
-
passing("Bar works", "./spec/bar_spec.rb", 3),
|
|
63
|
-
failing("Bar also blows up", "./spec/bar_spec.rb", 8, "expected true\n got false"),
|
|
64
|
-
],
|
|
65
|
-
2
|
|
66
|
-
);
|
|
67
|
-
const result = await parser.parse(makeCtx(stdout, cwd));
|
|
68
|
-
expect(result.status).toBe("fail");
|
|
69
|
-
expect(result.summary).toBe("2 failed, 2 passed");
|
|
70
|
-
expect(result.failures).toHaveLength(2);
|
|
71
|
-
expect(result.failures![0].file).toBe("spec/foo_spec.rb");
|
|
72
|
-
expect(result.failures![1].file).toBe("spec/bar_spec.rb");
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("all passing → status pass, summary reflects passed count", async () => {
|
|
76
|
-
const stdout = report(
|
|
77
|
-
[passing("Foo works", "./spec/foo_spec.rb", 5), passing("Bar works", "./spec/bar_spec.rb", 3)],
|
|
78
|
-
0
|
|
79
|
-
);
|
|
80
|
-
const result = await parser.parse(makeCtx(stdout));
|
|
81
|
-
expect(result.status).toBe("pass");
|
|
82
|
-
expect(result.summary).toBe("2 passed");
|
|
83
|
-
expect(result.failures).toHaveLength(0);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it("failure message → expected/got pair joined, stops at blank line", async () => {
|
|
87
|
-
const stdout = report(
|
|
88
|
-
[failing("Foo blows up", "./spec/foo_spec.rb", 10, "\nexpected: 2\n got: 1\n\n(compared using ==)\n")],
|
|
89
|
-
1
|
|
90
|
-
);
|
|
91
|
-
const result = await parser.parse(makeCtx(stdout));
|
|
92
|
-
expect(result.failures![0].message).toBe("expected: 2 / got: 1");
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("file_path with ./ prefix → stripped in relative path output", async () => {
|
|
96
|
-
const stdout = report([failing("Foo blows up", "./spec/foo_spec.rb", 10, "error")], 1);
|
|
97
|
-
const result = await parser.parse(makeCtx(stdout, "/project"));
|
|
98
|
-
expect(result.failures![0].file).toBe("spec/foo_spec.rb");
|
|
99
|
-
expect(result.failures![0].file).not.toMatch(/^\.\//);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it("line number preserved on failure", async () => {
|
|
103
|
-
const stdout = report([failing("Foo blows up", "./spec/foo_spec.rb", 42, "error")], 1);
|
|
104
|
-
const result = await parser.parse(makeCtx(stdout));
|
|
105
|
-
expect(result.failures![0].line).toBe(42);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it("pending tests excluded from passed count", async () => {
|
|
109
|
-
const stdout = report(
|
|
110
|
-
[
|
|
111
|
-
passing("Foo works", "./spec/foo_spec.rb", 5),
|
|
112
|
-
{ ...passing("Pending thing", "./spec/foo_spec.rb", 20), status: "pending" },
|
|
113
|
-
],
|
|
114
|
-
0,
|
|
115
|
-
1
|
|
116
|
-
);
|
|
117
|
-
const result = await parser.parse(makeCtx(stdout));
|
|
118
|
-
expect(result.status).toBe("pass");
|
|
119
|
-
expect(result.summary).toBe("1 passed");
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it("empty stdout → status error, no crash", async () => {
|
|
123
|
-
const result = await parser.parse(makeCtx(""));
|
|
124
|
-
expect(result.status).toBe("error");
|
|
125
|
-
});
|
|
126
|
-
});
|
|
@@ -1,118 +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 "./rubocop-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(), "rubocop-test-"));
|
|
10
|
-
const stdoutPath = path.join(dir, "stdout");
|
|
11
|
-
fs.writeFileSync(stdoutPath, stdout);
|
|
12
|
-
return {
|
|
13
|
-
command: "rubocop lint_check.rb --format json",
|
|
14
|
-
argv: ["rubocop", "lint_check.rb", "--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("rubocop-json parser", () => {
|
|
24
|
-
it("multiple offenses → correct file, line, message, rule, status fail", async () => {
|
|
25
|
-
const stdout = JSON.stringify({
|
|
26
|
-
metadata: {},
|
|
27
|
-
files: [
|
|
28
|
-
{
|
|
29
|
-
path: "lint_check.rb",
|
|
30
|
-
offenses: [
|
|
31
|
-
{
|
|
32
|
-
severity: "warning",
|
|
33
|
-
message: "Lint/UselessAssignment: Useless assignment to variable - `discount`.",
|
|
34
|
-
cop_name: "Lint/UselessAssignment",
|
|
35
|
-
corrected: false,
|
|
36
|
-
location: { start_line: 2, start_column: 3, line: 2, column: 3 },
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
severity: "convention",
|
|
40
|
-
message:
|
|
41
|
-
"Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.",
|
|
42
|
-
cop_name: "Style/StringLiterals",
|
|
43
|
-
corrected: false,
|
|
44
|
-
location: { start_line: 6, start_column: 20, line: 6, column: 20 },
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
summary: { offense_count: 2 },
|
|
50
|
-
});
|
|
51
|
-
const result = await parser.parse(makeCtx(stdout));
|
|
52
|
-
expect(result.status).toBe("fail");
|
|
53
|
-
expect(result.summary).toBe("2 lint errors");
|
|
54
|
-
expect(result.failures).toHaveLength(2);
|
|
55
|
-
expect(result.failures![0]).toMatchObject({
|
|
56
|
-
file: "lint_check.rb",
|
|
57
|
-
line: 2,
|
|
58
|
-
message: "Useless assignment to variable - `discount`.",
|
|
59
|
-
rule: "Lint/UselessAssignment",
|
|
60
|
-
});
|
|
61
|
-
expect(result.failures![1].rule).toBe("Style/StringLiterals");
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("no offenses → status pass", async () => {
|
|
65
|
-
const stdout = JSON.stringify({
|
|
66
|
-
metadata: {},
|
|
67
|
-
files: [{ path: "clean.rb", offenses: [] }],
|
|
68
|
-
summary: { offense_count: 0 },
|
|
69
|
-
});
|
|
70
|
-
const result = await parser.parse(makeCtx(stdout));
|
|
71
|
-
expect(result.status).toBe("pass");
|
|
72
|
-
expect(result.failures).toHaveLength(0);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("empty stdout → status pass", async () => {
|
|
76
|
-
const result = await parser.parse(makeCtx(""));
|
|
77
|
-
expect(result.status).toBe("pass");
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("absolute file paths → relativized to cwd", async () => {
|
|
81
|
-
const stdout = JSON.stringify({
|
|
82
|
-
metadata: {},
|
|
83
|
-
files: [
|
|
84
|
-
{
|
|
85
|
-
path: "/project/src/foo.rb",
|
|
86
|
-
offenses: [
|
|
87
|
-
{ severity: "warning", message: "Lint/Foo: bar", cop_name: "Lint/Foo", location: { line: 1, column: 1 } },
|
|
88
|
-
],
|
|
89
|
-
},
|
|
90
|
-
],
|
|
91
|
-
summary: { offense_count: 1 },
|
|
92
|
-
});
|
|
93
|
-
const result = await parser.parse(makeCtx(stdout, "/project"));
|
|
94
|
-
expect(result.failures![0].file).toBe("src/foo.rb");
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("strips cop_name prefix from message", async () => {
|
|
98
|
-
const stdout = JSON.stringify({
|
|
99
|
-
metadata: {},
|
|
100
|
-
files: [
|
|
101
|
-
{
|
|
102
|
-
path: "foo.rb",
|
|
103
|
-
offenses: [
|
|
104
|
-
{
|
|
105
|
-
severity: "convention",
|
|
106
|
-
message: "Style/FrozenStringLiteralComment: Missing frozen string literal comment.",
|
|
107
|
-
cop_name: "Style/FrozenStringLiteralComment",
|
|
108
|
-
location: { line: 1, column: 1 },
|
|
109
|
-
},
|
|
110
|
-
],
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
|
-
summary: { offense_count: 1 },
|
|
114
|
-
});
|
|
115
|
-
const result = await parser.parse(makeCtx(stdout));
|
|
116
|
-
expect(result.failures![0].message).toBe("Missing frozen string literal comment.");
|
|
117
|
-
});
|
|
118
|
-
});
|
|
@@ -1,57 +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 "./ruff-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(), "ruff-test-"));
|
|
10
|
-
const stdoutPath = path.join(dir, "stdout");
|
|
11
|
-
fs.writeFileSync(stdoutPath, stdout);
|
|
12
|
-
return {
|
|
13
|
-
command: "ruff check . --output-format=json",
|
|
14
|
-
argv: ["ruff", "check", ".", "--output-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("ruff-json parser", () => {
|
|
24
|
-
it("multiple errors across multiple files → correct relative paths, rule code mapped to rule, status fail", async () => {
|
|
25
|
-
const cwd = "/project";
|
|
26
|
-
const stdout = JSON.stringify([
|
|
27
|
-
{ filename: "/project/src/foo.py", code: "F401", message: "`os` imported but unused", location: { row: 1 } },
|
|
28
|
-
{ filename: "/project/src/foo.py", code: "E741", message: "Ambiguous variable name: `l`", location: { row: 5 } },
|
|
29
|
-
{
|
|
30
|
-
filename: "/project/src/bar.py",
|
|
31
|
-
code: "F841",
|
|
32
|
-
message: "Local variable `x` is assigned to but never used",
|
|
33
|
-
location: { row: 3 },
|
|
34
|
-
},
|
|
35
|
-
]);
|
|
36
|
-
const result = await parser.parse(makeCtx(stdout, cwd));
|
|
37
|
-
expect(result.status).toBe("fail");
|
|
38
|
-
expect(result.failures).toHaveLength(3);
|
|
39
|
-
expect(result.failures![0].file).toBe("src/foo.py");
|
|
40
|
-
expect(result.failures![2].file).toBe("src/bar.py");
|
|
41
|
-
expect(result.failures![0].file).not.toContain("/project");
|
|
42
|
-
expect(result.failures![0].rule).toBe("F401");
|
|
43
|
-
expect(result.failures![1].rule).toBe("E741");
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("no errors → empty failures, status pass", async () => {
|
|
47
|
-
const result = await parser.parse(makeCtx(JSON.stringify([])));
|
|
48
|
-
expect(result.status).toBe("pass");
|
|
49
|
-
expect(result.failures).toHaveLength(0);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("empty stdout → no crash, status pass", async () => {
|
|
53
|
-
const result = await parser.parse(makeCtx(""));
|
|
54
|
-
expect(result.status).toBe("pass");
|
|
55
|
-
expect(result.failures).toHaveLength(0);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,110 +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 "./shellcheck-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(), "shellcheck-test-"));
|
|
10
|
-
const stdoutPath = path.join(dir, "stdout");
|
|
11
|
-
fs.writeFileSync(stdoutPath, stdout);
|
|
12
|
-
return {
|
|
13
|
-
command: "shellcheck lint_check.sh --format=json",
|
|
14
|
-
argv: ["shellcheck", "lint_check.sh", "--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("shellcheck-json parser", () => {
|
|
24
|
-
it("multiple lint errors → correct file, line, message, rule, status fail", async () => {
|
|
25
|
-
const stdout = JSON.stringify([
|
|
26
|
-
{
|
|
27
|
-
file: "lint_check.sh",
|
|
28
|
-
line: 4,
|
|
29
|
-
endLine: 4,
|
|
30
|
-
column: 6,
|
|
31
|
-
endColumn: 15,
|
|
32
|
-
level: "info",
|
|
33
|
-
code: 2086,
|
|
34
|
-
message: "Double quote to prevent globbing and word splitting.",
|
|
35
|
-
fix: null,
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
file: "lint_check.sh",
|
|
39
|
-
line: 6,
|
|
40
|
-
endLine: 6,
|
|
41
|
-
column: 10,
|
|
42
|
-
endColumn: 21,
|
|
43
|
-
level: "error",
|
|
44
|
-
code: 2045,
|
|
45
|
-
message: "Iterating over ls output is fragile. Use globs.",
|
|
46
|
-
fix: null,
|
|
47
|
-
},
|
|
48
|
-
]);
|
|
49
|
-
const result = await parser.parse(makeCtx(stdout));
|
|
50
|
-
expect(result.status).toBe("fail");
|
|
51
|
-
expect(result.summary).toBe("2 lint errors");
|
|
52
|
-
expect(result.failures).toHaveLength(2);
|
|
53
|
-
expect(result.failures![0]).toMatchObject({
|
|
54
|
-
file: "lint_check.sh",
|
|
55
|
-
line: 4,
|
|
56
|
-
message: "Double quote to prevent globbing and word splitting.",
|
|
57
|
-
rule: "SC2086",
|
|
58
|
-
});
|
|
59
|
-
expect(result.failures![1]).toMatchObject({
|
|
60
|
-
file: "lint_check.sh",
|
|
61
|
-
line: 6,
|
|
62
|
-
message: "Iterating over ls output is fragile. Use globs.",
|
|
63
|
-
rule: "SC2045",
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("no errors (empty array) → status pass", async () => {
|
|
68
|
-
const result = await parser.parse(makeCtx("[]"));
|
|
69
|
-
expect(result.status).toBe("pass");
|
|
70
|
-
expect(result.summary).toBe("no lint errors");
|
|
71
|
-
expect(result.failures).toHaveLength(0);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("empty stdout → status pass", async () => {
|
|
75
|
-
const result = await parser.parse(makeCtx(""));
|
|
76
|
-
expect(result.status).toBe("pass");
|
|
77
|
-
expect(result.failures).toHaveLength(0);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("absolute file paths → relativized to cwd", async () => {
|
|
81
|
-
const stdout = JSON.stringify([
|
|
82
|
-
{
|
|
83
|
-
file: "/project/scripts/deploy.sh",
|
|
84
|
-
line: 10,
|
|
85
|
-
column: 5,
|
|
86
|
-
level: "warning",
|
|
87
|
-
code: 2034,
|
|
88
|
-
message: "foo appears unused.",
|
|
89
|
-
},
|
|
90
|
-
]);
|
|
91
|
-
const result = await parser.parse(makeCtx(stdout, "/project"));
|
|
92
|
-
expect(result.failures![0].file).toBe("scripts/deploy.sh");
|
|
93
|
-
expect(result.failures![0].file).not.toContain("/project");
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it("rule code is prefixed with SC", async () => {
|
|
97
|
-
const stdout = JSON.stringify([
|
|
98
|
-
{
|
|
99
|
-
file: "test.sh",
|
|
100
|
-
line: 1,
|
|
101
|
-
column: 1,
|
|
102
|
-
level: "info",
|
|
103
|
-
code: 2035,
|
|
104
|
-
message: "Use ./*glob* or -- *glob* so names with dashes won't become options.",
|
|
105
|
-
},
|
|
106
|
-
]);
|
|
107
|
-
const result = await parser.parse(makeCtx(stdout));
|
|
108
|
-
expect(result.failures![0].rule).toBe("SC2035");
|
|
109
|
-
});
|
|
110
|
-
});
|