Skip to content

Commit 517787c

Browse files
committed
Revert "Drop control characters from output"
This reverts commit bc70670.
1 parent 2409244 commit 517787c

File tree

4 files changed

+5
-30
lines changed

4 files changed

+5
-30
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
@@ -65,7 +54,7 @@ func (o *Output) Contains(id int) bool {
6554
func (o *Output) Get(id int) []string {
6655
var lines []string
6756
for _, line := range o.m[id] {
68-
lines = append(lines, line.SafeText())
57+
lines = append(lines, line.Text)
6958
}
7059
return lines
7160
}
@@ -82,7 +71,7 @@ func (o *Output) GetAll(ids ...int) []string {
8271
})
8372
var lines []string
8473
for _, line := range output {
85-
lines = append(lines, line.SafeText())
74+
lines = append(lines, line.Text)
8675
}
8776
return lines
8877
}

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)