Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10078,7 +10078,7 @@ async function main() {
actionsCommand.issueCommand(
diag.severity,
{
file: diag.file,
file: workingDirectory ? path2.relative(workingDirectory, diag.file) : diag.file,
line: line + 1,
col: col + 1
},
Expand Down
79 changes: 79 additions & 0 deletions src/__snapshots__/main.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1570,3 +1570,82 @@ exports[`with overridden flags > pyproject.toml bad toml > process.chdir 1`] = `
],
]
`;

exports[`working-directory > relative paths > command.issueCommand 1`] = `
[
[
"error",
{
"col": 1,
"file": "file1.py",
"line": 1,
},
"some error",
],
]
`;

exports[`working-directory > relative paths > core.error 1`] = `[]`;

exports[`working-directory > relative paths > core.info 1`] = `
[
[
"pyright 1.1.240, node v20.8.1, pyright-action 1.1.0",
],
[
"Working directory: /some/wd",
],
[
"Running: /path/to/node /path/to/pyright/dist/index.js --outputjson",
],
[
"/some/wd/file1.py:1:1 - error: some error",
],
[
"1 error, 0 warnings, 0 informations",
],
]
`;

exports[`working-directory > relative paths > core.setFailed 1`] = `
[
[
"1 error",
],
]
`;

exports[`working-directory > relative paths > core.warning 1`] = `[]`;

exports[`working-directory > relative paths > cp.spawnSync 1`] = `
[
[
"/path/to/node",
[
"/path/to/pyright/dist/index.js",
"--outputjson",
],
{
"encoding": "utf8",
"maxBuffer": 104857600,
"stdio": [
"ignore",
"pipe",
"inherit",
],
},
],
]
`;

exports[`working-directory > relative paths > fs.existsSync 1`] = `[]`;

exports[`working-directory > relative paths > fs.readFileSync 1`] = `[]`;

exports[`working-directory > relative paths > process.chdir 1`] = `
[
[
"/some/wd",
],
]
`;
43 changes: 43 additions & 0 deletions src/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,49 @@ describe("with overridden flags", () => {
});
});

describe("working-directory", () => {
test("relative paths", async () => {
const args = ["/path/to/pyright/dist/index.js", "--outputjson"];
const wd = "/some/wd";

mockedHelpers.getArgs.mockResolvedValue({
annotate: new Set(["error"]),
workingDirectory: wd,
pyrightVersion,
command: nodeExecPath,
args,
});

mockedCp.spawnSync.mockImplementation(() => ({
pid: -1,
output: [],
stdout: reportToString({
generalDiagnostics: [
{
file: "/some/wd/file1.py",
range: {
start: { line: 0, character: 0 },
end: { line: 1, character: 1 },
},
severity: "error",
message: "some error",
},
],
summary: {
errorCount: 1,
warningCount: 0,
informationCount: 0,
},
}) as any,
stderr: "" as any,
status: 1,
signal: null,
}));

await main();
});
});

function reportToString(report: Report): string {
return JSON.stringify(report);
}
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ export async function main() {
actionsCommand.issueCommand(
diag.severity,
{
file: diag.file,
file: workingDirectory
? path.relative(workingDirectory, diag.file)
: diag.file,
line: line + 1,
col: col + 1,
},
Expand Down