Skip to content

Commit 7eac4f5

Browse files
committed
Revert "Drop control characters from output"
This reverts commit bc70670.
1 parent 76a76d7 commit 7eac4f5

File tree

5 files changed

+5
-39
lines changed

5 files changed

+5
-39
lines changed

parser/gotest/internal/collector/collector.go

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,13 @@ package collector
44

55
import (
66
"sort"
7-
"strings"
87
"time"
9-
"unicode"
108
)
119

1210
// line is a single line of output captured at some point in time.
1311
type line struct {
1412
Timestamp time.Time
15-
text string
16-
}
17-
18-
func (l line) SafeText() string {
19-
return strings.Map(func(r rune) rune {
20-
if unicode.IsControl(r) && !unicode.IsSpace(r) {
21-
return -1
22-
}
23-
return r
24-
}, l.text)
13+
Text string
2514
}
2615

2716
// Output stores output lines grouped by id. Output can be retrieved for one or
@@ -55,7 +44,7 @@ func (o *Output) Contains(id int) bool {
5544
func (o *Output) Get(id int) []string {
5645
var lines []string
5746
for _, line := range o.m[id] {
58-
lines = append(lines, line.SafeText())
47+
lines = append(lines, line.Text)
5948
}
6049
return lines
6150
}
@@ -72,7 +61,7 @@ func (o *Output) GetAll(ids ...int) []string {
7261
})
7362
var lines []string
7463
for _, line := range output {
75-
lines = append(lines, line.SafeText())
64+
lines = append(lines, line.Text)
7665
}
7766
return lines
7867
}

parser/gotest/internal/collector/collector_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,3 @@ func TestMerge(t *testing.T) {
8989
t.Errorf("Get(2) after Merge(2, 1) incorrect (-want +got):\n%s", diff)
9090
}
9191
}
92-
93-
func TestSafeText(t *testing.T) {
94-
l := line{text: "\tx\x00y\x1bz\n"}
95-
got := l.SafeText()
96-
want := "\txyz\n"
97-
if diff := cmp.Diff(want, got); diff != "" {
98-
t.Errorf("SafeText() for %q incorrect (-want +got):\n%s", l.text, diff)
99-
}
100-
}

testdata/035-report.xml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<testsuites tests="11">
3-
<testsuite name="package/whitespace" tests="11" failures="0" errors="0" id="0" hostname="hostname" time="0.001" timestamp="2022-01-01T00:00:00Z">
2+
<testsuites tests="9">
3+
<testsuite name="package/whitespace" tests="9" failures="0" errors="0" id="0" hostname="hostname" time="0.001" timestamp="2022-01-01T00:00:00Z">
44
<properties>
55
<property name="go.version" value="1.0"></property>
66
</properties>
@@ -45,10 +45,6 @@ one-newline
4545
two-newlines
4646
two-newlines
4747
two-newlines]]></system-out>
48-
</testcase>
49-
<testcase name="TestControl" classname="package/whitespace" time="0.000">
50-
<system-out><![CDATA[ whitespace_test.go:49: log control
51-
printf control]]></system-out>
5248
</testcase>
5349
<testcase name="TestSubTests" classname="package/whitespace" time="0.000"></testcase>
5450
<testcase name="TestSubTests/TestFlat" classname="package/whitespace" time="0.000">
@@ -93,9 +89,5 @@ two-newlines
9389
two-newlines
9490
two-newlines]]></system-out>
9591
</testcase>
96-
<testcase name="TestSubTests/TestControl" classname="package/whitespace" time="0.000">
97-
<system-out><![CDATA[ whitespace_test.go:49: log control
98-
printf control]]></system-out>
99-
</testcase>
10092
</testsuite>
10193
</testsuites>

testdata/035-whitespace.txt

-246 Bytes
Binary file not shown.

testdata/src/whitespace/whitespace_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,9 @@ func TestWithNewlinesFlat(t *testing.T) {
4545
fmt.Println("two-newlines\ntwo-newlines\ntwo-newlines")
4646
}
4747

48-
func TestControl(t *testing.T) {
49-
t.Logf("log\x00 control")
50-
fmt.Printf("printf\x00 control\n")
51-
}
52-
5348
func TestSubTests(t *testing.T) {
5449
t.Run("TestFlat", TestFlat)
5550
t.Run("TestWithSpace", TestWithSpace)
5651
t.Run("TestWithTab", TestWithTab)
5752
t.Run("TestWithNewlinesFlat", TestWithNewlinesFlat)
58-
t.Run("TestControl", TestControl)
5953
}

0 commit comments

Comments
 (0)