Skip to content

Commit

Permalink
test/integration: fix Go Test Runner / parseOutput test on windows
Browse files Browse the repository at this point in the history
Windows file paths use \ as a path separator.
Use URI.fsPath to handle platform dependent URI to file system path
conversion.

Updates golang#2549

Change-Id: Iedfa2d51e214a114c6a20e42fa5503d3cd103d6d
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/459855
Reviewed-by: Jamal Carvalho <[email protected]>
Run-TryBot: Hyang-Ah Hana Kim <[email protected]>
TryBot-Result: kokoro <[email protected]>
  • Loading branch information
hyangah committed Jan 4, 2023
1 parent 5ec591d commit 560c8f4
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions test/integration/goTest.run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ suite('Go Test Runner', () => {
});
suiteTeardown(() => ctx.teardown());

const fileURI = Uri.parse('file:///path/to/mod/file.go');
const filePath = fileURI.fsPath;

function testParseOutput(output: string, expected: { file: string; line: number; msg: string }[]) {
const uri = Uri.parse('file:///path/to/mod/file.go');
const id = GoTest.id(uri, 'test', 'TestXXX');
const ti = { id, uri, range: new Range(1, 0, 100, 0) } as TestItem;
const id = GoTest.id(fileURI, 'test', 'TestXXX');
const ti = { id, uri: fileURI, range: new Range(1, 0, 100, 0) } as TestItem;
const testMsgs = testExplorer.runner.parseOutput(ti, [output]);
const got = testMsgs.map((m) => {
return {
Expand All @@ -37,20 +39,16 @@ suite('Go Test Runner', () => {
test('no line info ', () => testParseOutput(' foo \n', []));
test('file path without preceding space', () => testParseOutput('file.go:7: foo\n', [])); // valid test message starts with a space.
test('valid test message format', () =>
testParseOutput(' file.go:7: foo\n', [{ file: '/path/to/mod/file.go', line: 6, msg: 'foo\n' }]));
testParseOutput(' file.go:7: foo\n', [{ file: filePath, line: 6, msg: 'foo\n' }]));
test('message without ending newline', () =>
testParseOutput(
' file.go:7: foo ', // valid test message contains a new line.
[]
));
test('user print message before test message', () =>
testParseOutput('random print file.go:8: foo\n', [
{ file: '/path/to/mod/file.go', line: 7, msg: 'foo\n' }
]));
testParseOutput('random print file.go:8: foo\n', [{ file: filePath, line: 7, msg: 'foo\n' }]));
test('multiple file locs in one line', () =>
testParseOutput('file.go:1: line1 . file.go:2: line2 \n', [
{ file: '/path/to/mod/file.go', line: 1, msg: 'line2 \n' }
]));
testParseOutput('file.go:1: line1 . file.go:2: line2 \n', [{ file: filePath, line: 1, msg: 'line2 \n' }]));
});

suite('Profile', () => {
Expand Down

0 comments on commit 560c8f4

Please sign in to comment.