Skip to content

Commit 72e45aa

Browse files
Resolved formatting issues in test command output (#281)
1 parent a43c9c9 commit 72e45aa

File tree

2 files changed

+34
-24
lines changed

2 files changed

+34
-24
lines changed

cmd/scip/main_test.go

+17-17
Original file line numberDiff line numberDiff line change
@@ -134,38 +134,38 @@ func TestSCIPTests(t *testing.T) {
134134
{"roles",
135135
autogold.Expect("✓ passes.repro (3 assertions)\n"),
136136
autogold.Expect(`✗ fails-wrong-role.repro
137-
Failure - row: 0, column: 13
137+
Failure [Ln: 1, Col: 13]
138138
Expected: 'reference reprolang repro_manager roles 1.0.0 fails-wrong-role.repro/hello().'
139-
Actual:
140-
- 'definition reprolang repro_manager roles 1.0.0 fails-wrong-role.repro/hello().'✗ fails-wrong-symbol.repro
141-
Failure - row: 0, column: 13
139+
Actual: 'definition reprolang repro_manager roles 1.0.0 fails-wrong-role.repro/hello().'
140+
✗ fails-wrong-symbol.repro
141+
Failure [Ln: 1, Col: 13]
142142
Expected: 'definition reprolang repro_manager roles 1.0.0 fails-wrong-role.repro/hello2().'
143-
Actual:
144-
- 'definition reprolang repro_manager roles 1.0.0 fails-wrong-symbol.repro/hello().'`),
143+
Actual: 'definition reprolang repro_manager roles 1.0.0 fails-wrong-symbol.repro/hello().'
144+
`),
145145
},
146146
{"ranges",
147147
autogold.Expect("✓ passes.repro (3 assertions)\n"),
148148
autogold.Expect(`✗ fails.repro
149-
Failure - row: 0, column: 10
149+
Failure [Ln: 1, Col: 10]
150150
Expected: 'definition passes.repro/hello().'
151-
Actual:
152-
- No attributes found`),
151+
Actual: <no attributes found>
152+
`),
153153
},
154154
{"diagnostics",
155155
autogold.Expect("✓ passes.repro (2 assertions)\n"),
156156
autogold.Expect(`✗ fails-incorrect-diagnostic.repro
157-
Failure - row: 0, column: 11
157+
Failure [Ln: 1, Col: 11]
158158
Expected: 'diagnostic Warning:'
159159
'THIS IS NOT CORRECT'
160-
Actual:
161-
- 'definition reprolang repro_manager diagnostics 1.0.0 fails-incorrect-diagnostic.repro/deprecatedMethod.'
162-
- 'diagnostic Warning'
163-
'deprecated identifier'✗ fails-no-diagnostic.repro
164-
Failure - row: 0, column: 11
160+
Actual: * 'definition reprolang repro_manager diagnostics 1.0.0 fails-incorrect-diagnostic.repro/deprecatedMethod.'
161+
* 'diagnostic Warning'
162+
'deprecated identifier'
163+
✗ fails-no-diagnostic.repro
164+
Failure [Ln: 1, Col: 11]
165165
Expected: 'diagnostic Warning:'
166166
'deprecated identifier'
167-
Actual:
168-
- 'definition reprolang repro_manager diagnostics 1.0.0 fails-no-diagnostic.repro/hello().'`),
167+
Actual: 'definition reprolang repro_manager diagnostics 1.0.0 fails-no-diagnostic.repro/hello().'
168+
`),
169169
},
170170
}
171171

cmd/scip/test.go

+17-7
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func testMain(
142142
red.Fprintf(output, "✗ %s\n", document.RelativePath)
143143

144144
for _, failure := range failures {
145-
fmt.Fprintf(output, indent(failure, 4))
145+
fmt.Fprintf(output, indent(failure, 4)+"\n")
146146
}
147147
} else {
148148
green := color.New(color.FgGreen)
@@ -421,21 +421,31 @@ func (s symbolAttributeTestCase) check(attr symbolAttribute) bool {
421421

422422
func formatFailure(lineNumber int, testCase symbolAttributeTestCase, attributesAtLine []symbolAttribute) string {
423423
failureDesc := []string{
424-
fmt.Sprintf("Failure - row: %d, column: %d", lineNumber, testCase.attribute.start),
424+
fmt.Sprintf("Failure [Ln: %d, Col: %d]", lineNumber+1, testCase.attribute.start),
425425
fmt.Sprintf(" Expected: '%s %s'", testCase.attribute.kind, testCase.attribute.data),
426426
}
427427
for _, add := range testCase.attribute.additionalData {
428428
failureDesc = append(failureDesc, indent(fmt.Sprintf("'%s'", add), 12))
429429
}
430430

431-
failureDesc = append(failureDesc, " Actual:")
432431
if (len(attributesAtLine)) == 0 {
433-
failureDesc = append(failureDesc, " - No attributes found")
432+
failureDesc = append(failureDesc, " Actual: <no attributes found>")
434433
} else {
435-
for _, attr := range attributesAtLine {
436-
failureDesc = append(failureDesc, fmt.Sprintf(" - '%s %s'", attr.kind, attr.data))
434+
for i, attr := range attributesAtLine {
435+
prefix := " "
436+
if i == 0 {
437+
prefix = "Actual:"
438+
}
439+
440+
if len(attributesAtLine) > 1 {
441+
prefix += " *"
442+
} else {
443+
prefix += " "
444+
}
445+
446+
failureDesc = append(failureDesc, fmt.Sprintf(" %s '%s %s'", prefix, attr.kind, attr.data))
437447
for _, add := range attr.additionalData {
438-
failureDesc = append(failureDesc, indent(fmt.Sprintf("'%s'", add), 6))
448+
failureDesc = append(failureDesc, indent(fmt.Sprintf("'%s'", add), 12))
439449
}
440450
}
441451
}

0 commit comments

Comments
 (0)