Skip to content

Commit

Permalink
fix: linebreak on win
Browse files Browse the repository at this point in the history
  • Loading branch information
zxch3n committed Apr 6, 2022
1 parent 31a04a2 commit abaeb04
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
16 changes: 9 additions & 7 deletions src/pure/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class TestRunner {
cwd: workspacePath,
stdio: ["ignore", "pipe", "pipe"],
env,
shell: isWindows ? 'powershell' : false,
shell: isWindows ? "powershell" : false,
});

for await (const line of chunksToLinesAsync(child.stdout)) {
Expand All @@ -127,19 +127,21 @@ export class TestRunner {
async function handleError() {
const prefix = `\n` +
`( Vitest should be configured to be able to run from project root )\n\n` +
`Error when running\n` +
`Error when running\r\n` +
` ${command + " " + args.join(" ")}\n\n` +
`cwd: ${workspacePath}\n` +
`node: ${await getNodeVersion()}\n` +
`env.PATH: ${env.PATH}\n`;
`cwd: ${workspacePath}\r\n` +
`node: ${await getNodeVersion()}\r\n` +
`env.PATH: ${env.PATH}\r\n`;
if (error) {
console.error("scheduleRun error", error.toString());
console.error(error.stack);
const e = error;
error = new Error(prefix + "\n" + error.toString());
error = new Error(prefix + "\r\n" + error.toString());
error.stack = e.stack;
} else {
error = new Error(prefix + "\n\n------\n\nLog:\n" + outputs.join("\n"));
error = new Error(
prefix + "\n\n------\n\nLog:\n" + outputs.join("\r\n"),
);
}

console.error(outputs.join("\n"));
Expand Down
14 changes: 7 additions & 7 deletions src/runHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ async function runTest(
case "failed":
run.failed(
child,
new vscode.TestMessage(result.failureMessages.join("\n")),
new vscode.TestMessage(result.failureMessages.join("\r\n")),
);
return;
}
Expand All @@ -202,9 +202,9 @@ async function runTest(
run.errored(
testCase,
new vscode.TestMessage(
`Test result not found. \n` +
`Can you run vitest successfully on this file? Does it need custom option to run?\n` +
`Does this file contain test case with the same name? \n`,
`Test result not found. \r\n` +
`Can you run vitest successfully on this file? Does it need custom option to run?\r\n` +
`Does this file contain test case with the same name? \r\n`,
),
);
run.appendOutput(`Cannot find test ${testCase.id}`);
Expand Down Expand Up @@ -263,9 +263,9 @@ async function debugTest(
console.log("DISCONNECTED");
setTimeout(async () => {
if (!existsSync(outputFilePath)) {
const prefix = `When running:\n` +
` ${config.program + " " + config.args.join(" ")}\n` +
`cwd: ${workspaceFolder.uri.fsPath}\n` +
const prefix = `When running:\r\n` +
` ${config.program + " " + config.args.join(" ")}\r\n` +
`cwd: ${workspaceFolder.uri.fsPath}\r\n` +
`node: ${await getNodeVersion()}` +
`env.PATH: ${process.env.PATH}`;
reject(new Error(prefix));
Expand Down

0 comments on commit abaeb04

Please sign in to comment.