Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
e330c753
Commit
e330c753
authored
Dec 24, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
e8cfd4db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
8 deletions
+29
-8
go/internal/xtracing/tracetest/example_test.go
go/internal/xtracing/tracetest/example_test.go
+29
-8
No files found.
go/internal/xtracing/tracetest/example_test.go
View file @
e330c753
...
...
@@ -28,6 +28,7 @@ import (
"fmt"
"os"
"os/exec"
"regexp"
"strings"
"sync"
"testing"
...
...
@@ -179,6 +180,18 @@ func verifyInSubprocess(t *testing.T, f func(t *testing.T), targvExtra ...string
if
!
ok
{
panic
(
fmt
.
Sprintf
(
"testExpectMap[%q] not defined"
,
t
.
Name
()))
}
outputOK
:=
regexp
.
QuoteMeta
(
expectOK
.
output
)
// empty line -> kind of "<BLANKLINE>"
for
{
__
:=
strings
.
ReplaceAll
(
outputOK
,
"
\n\n
"
,
"
\n\\
s*
\n
"
)
if
__
==
outputOK
{
break
}
outputOK
=
__
}
outputOK
=
strings
.
ReplaceAll
(
outputOK
,
"<TIME>"
,
".+s"
)
outputOK
=
strings
.
ReplaceAll
(
outputOK
,
"<LINE>"
,
"[0-9]+"
)
outputRe
:=
regexp
.
MustCompile
(
outputOK
)
argv
:=
[]
string
{
"-test.run="
+
t
.
Name
()}
argv
=
append
(
argv
,
targvExtra
...
)
cmd
:=
exec
.
Command
(
os
.
Args
[
0
],
argv
...
)
...
...
@@ -207,8 +220,8 @@ func verifyInSubprocess(t *testing.T, f func(t *testing.T), targvExtra ...string
badf
(
"exit code: %d ; expected: %d"
,
ecode
,
expectOK
.
exitCode
)
}
if
out
!=
expectOK
.
outputRe
{
// XXX match with re
badf
(
"unexpected output:
\n
%s
\n
want:
%s
\n
"
,
out
,
expectOK
.
outputRe
)
if
!
outputRe
.
MatchString
(
out
)
{
badf
(
"unexpected output:
\n
%s
\n
want:
~
\n
%s
\n
"
,
out
,
expectOK
.
output
)
}
if
bad
!=
""
{
...
...
@@ -219,19 +232,27 @@ func verifyInSubprocess(t *testing.T, f func(t *testing.T), targvExtra ...string
// testExpect describes what result to expect from a test.
type
testExpect
struct
{
exitCode
int
output
Re
string
output
string
}
// testExpectMap maps <test name> -> testExpect.
var
testExpectMap
=
map
[
string
]
testExpect
{
"Test2ThreadsOK"
:
{
0
,
""
},
"TestDeadlock"
:
{
1
,
`
--- FAIL: TestDeadlock (.+s)
example_test.go:159: t2: recv: deadlock waiting for *tracetest_test.eventHi
example_test.go:159: test shutdown: #streams: 2, #(pending events): 1
"TestDeadlock"
:
{
1
,
`--- FAIL: TestDeadlock (<TIME>)
example_test.go:161: t2: recv: deadlock waiting for *tracetest_test.eventHi
example_test.go:161: test shutdown: #streams: 2, #(pending events): 1
t1 <- tracetest_test.eventHi T1·A
# t2
tracetest.go:<LINE>: t1: send: canceled (test failed)
`
},
"TestDeadlockQQQ"
:
{
1
,
`
--- FAIL: TestDeadlock \(.+s\)
example_test.go:161: t2: recv: deadlock waiting for *tracetest_test.eventHi
example_test.go:161: test shutdown: #streams: 2, #(pending events): 1
t1 <- tracetest_test.eventHi T1·A
# t2
tracetest.go:175: t1: send: canceled (test failed)
...
`
},
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment