Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolved formatting issues in test command output #281

Merged
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
34 changes: 17 additions & 17 deletions cmd/scip/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,38 +134,38 @@ func TestSCIPTests(t *testing.T) {
{"roles",
autogold.Expect("✓ passes.repro (3 assertions)\n"),
autogold.Expect(`✗ fails-wrong-role.repro
Failure - row: 0, column: 13
Failure [Ln: 1, Col: 13]
Expected: 'reference reprolang repro_manager roles 1.0.0 fails-wrong-role.repro/hello().'
Actual:
- 'definition reprolang repro_manager roles 1.0.0 fails-wrong-role.repro/hello().'✗ fails-wrong-symbol.repro
Failure - row: 0, column: 13
Actual: 'definition reprolang repro_manager roles 1.0.0 fails-wrong-role.repro/hello().'
✗ fails-wrong-symbol.repro
Failure [Ln: 1, Col: 13]
Expected: 'definition reprolang repro_manager roles 1.0.0 fails-wrong-role.repro/hello2().'
Actual:
- 'definition reprolang repro_manager roles 1.0.0 fails-wrong-symbol.repro/hello().'`),
Actual: 'definition reprolang repro_manager roles 1.0.0 fails-wrong-symbol.repro/hello().'
`),
},
{"ranges",
autogold.Expect("✓ passes.repro (3 assertions)\n"),
autogold.Expect(`✗ fails.repro
Failure - row: 0, column: 10
Failure [Ln: 1, Col: 10]
Expected: 'definition passes.repro/hello().'
Actual:
- No attributes found`),
Actual: <no attributes found>
`),
},
{"diagnostics",
autogold.Expect("✓ passes.repro (2 assertions)\n"),
autogold.Expect(`✗ fails-incorrect-diagnostic.repro
Failure - row: 0, column: 11
Failure [Ln: 1, Col: 11]
Expected: 'diagnostic Warning:'
'THIS IS NOT CORRECT'
Actual:
- 'definition reprolang repro_manager diagnostics 1.0.0 fails-incorrect-diagnostic.repro/deprecatedMethod.'
- 'diagnostic Warning'
'deprecated identifier'✗ fails-no-diagnostic.repro
Failure - row: 0, column: 11
Actual: * 'definition reprolang repro_manager diagnostics 1.0.0 fails-incorrect-diagnostic.repro/deprecatedMethod.'
* 'diagnostic Warning'
'deprecated identifier'
✗ fails-no-diagnostic.repro
Failure [Ln: 1, Col: 11]
Expected: 'diagnostic Warning:'
'deprecated identifier'
Actual:
- 'definition reprolang repro_manager diagnostics 1.0.0 fails-no-diagnostic.repro/hello().'`),
Actual: 'definition reprolang repro_manager diagnostics 1.0.0 fails-no-diagnostic.repro/hello().'
`),
},
}

Expand Down
24 changes: 17 additions & 7 deletions cmd/scip/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func testMain(
red.Fprintf(output, "✗ %s\n", document.RelativePath)

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

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

failureDesc = append(failureDesc, " Actual:")
if (len(attributesAtLine)) == 0 {
failureDesc = append(failureDesc, " - No attributes found")
failureDesc = append(failureDesc, " Actual: <no attributes found>")
} else {
for _, attr := range attributesAtLine {
failureDesc = append(failureDesc, fmt.Sprintf(" - '%s %s'", attr.kind, attr.data))
for i, attr := range attributesAtLine {
prefix := " "
if i == 0 {
prefix = "Actual:"
}

if len(attributesAtLine) > 1 {
prefix += " *"
} else {
prefix += " "
}

failureDesc = append(failureDesc, fmt.Sprintf(" %s '%s %s'", prefix, attr.kind, attr.data))
for _, add := range attr.additionalData {
failureDesc = append(failureDesc, indent(fmt.Sprintf("'%s'", add), 6))
failureDesc = append(failureDesc, indent(fmt.Sprintf("'%s'", add), 12))
}
}
}
Expand Down
Loading