Skip to content

Commit

Permalink
Revert "Drop control characters from output"
Browse files Browse the repository at this point in the history
This reverts commit bc70670.
  • Loading branch information
janisz committed Aug 16, 2022
1 parent 76a76d7 commit 7eac4f5
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 39 deletions.
17 changes: 3 additions & 14 deletions parser/gotest/internal/collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,13 @@ package collector

import (
"sort"
"strings"
"time"
"unicode"
)

// line is a single line of output captured at some point in time.
type line struct {
Timestamp time.Time
text string
}

func (l line) SafeText() string {
return strings.Map(func(r rune) rune {
if unicode.IsControl(r) && !unicode.IsSpace(r) {
return -1
}
return r
}, l.text)
Text string
}

// Output stores output lines grouped by id. Output can be retrieved for one or
Expand Down Expand Up @@ -55,7 +44,7 @@ func (o *Output) Contains(id int) bool {
func (o *Output) Get(id int) []string {
var lines []string
for _, line := range o.m[id] {
lines = append(lines, line.SafeText())
lines = append(lines, line.Text)
}
return lines
}
Expand All @@ -72,7 +61,7 @@ func (o *Output) GetAll(ids ...int) []string {
})
var lines []string
for _, line := range output {
lines = append(lines, line.SafeText())
lines = append(lines, line.Text)
}
return lines
}
Expand Down
9 changes: 0 additions & 9 deletions parser/gotest/internal/collector/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,3 @@ func TestMerge(t *testing.T) {
t.Errorf("Get(2) after Merge(2, 1) incorrect (-want +got):\n%s", diff)
}
}

func TestSafeText(t *testing.T) {
l := line{text: "\tx\x00y\x1bz\n"}
got := l.SafeText()
want := "\txyz\n"
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("SafeText() for %q incorrect (-want +got):\n%s", l.text, diff)
}
}
12 changes: 2 additions & 10 deletions testdata/035-report.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="11">
<testsuite name="package/whitespace" tests="11" failures="0" errors="0" id="0" hostname="hostname" time="0.001" timestamp="2022-01-01T00:00:00Z">
<testsuites tests="9">
<testsuite name="package/whitespace" tests="9" failures="0" errors="0" id="0" hostname="hostname" time="0.001" timestamp="2022-01-01T00:00:00Z">
<properties>
<property name="go.version" value="1.0"></property>
</properties>
Expand Down Expand Up @@ -45,10 +45,6 @@ one-newline
two-newlines
two-newlines
two-newlines]]></system-out>
</testcase>
<testcase name="TestControl" classname="package/whitespace" time="0.000">
<system-out><![CDATA[ whitespace_test.go:49: log control
printf control]]></system-out>
</testcase>
<testcase name="TestSubTests" classname="package/whitespace" time="0.000"></testcase>
<testcase name="TestSubTests/TestFlat" classname="package/whitespace" time="0.000">
Expand Down Expand Up @@ -93,9 +89,5 @@ two-newlines
two-newlines
two-newlines]]></system-out>
</testcase>
<testcase name="TestSubTests/TestControl" classname="package/whitespace" time="0.000">
<system-out><![CDATA[ whitespace_test.go:49: log control
printf control]]></system-out>
</testcase>
</testsuite>
</testsuites>
Binary file modified testdata/035-whitespace.txt
Binary file not shown.
6 changes: 0 additions & 6 deletions testdata/src/whitespace/whitespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,9 @@ func TestWithNewlinesFlat(t *testing.T) {
fmt.Println("two-newlines\ntwo-newlines\ntwo-newlines")
}

func TestControl(t *testing.T) {
t.Logf("log\x00 control")
fmt.Printf("printf\x00 control\n")
}

func TestSubTests(t *testing.T) {
t.Run("TestFlat", TestFlat)
t.Run("TestWithSpace", TestWithSpace)
t.Run("TestWithTab", TestWithTab)
t.Run("TestWithNewlinesFlat", TestWithNewlinesFlat)
t.Run("TestControl", TestControl)
}

0 comments on commit 7eac4f5

Please sign in to comment.