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
085049f6
Commit
085049f6
authored
Jun 29, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
f67bb046
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
4 deletions
+27
-4
go/xcommon/tracing/cmd/gotrace/gotrace_test.go
go/xcommon/tracing/cmd/gotrace/gotrace_test.go
+27
-4
No files found.
go/xcommon/tracing/cmd/gotrace/gotrace_test.go
View file @
085049f6
package
main
import
(
"bytes"
"go/build"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"syscall"
"testing"
"lab.nexedi.com/kirr/go123/exc"
...
...
@@ -63,13 +66,15 @@ func prepareTestTree(src, dst string, mode TreePrepareMode) error {
switch
mode
{
case
TreePrepareGolden
:
// no removed files in golden tree
// ok files are written as is
// no removed files
if
isRm
{
return
nil
}
case
TreePrepareWork
:
// no ok files initially
in work tree
// no ok files initially
if
isOk
{
return
nil
}
...
...
@@ -93,6 +98,20 @@ func xprepareTree(src, dst string, mode TreePrepareMode) {
exc
.
Raiseif
(
err
)
}
// diffR compares two directories recursively
func
diffR
(
patha
,
pathb
string
)
(
diff
string
,
err
error
)
{
out
:=
&
bytes
.
Buffer
{}
cmd
:=
exec
.
Command
(
"diff"
,
"-urN"
,
patha
,
pathb
)
cmd
.
Stdout
=
out
err
=
cmd
.
Run
()
if
e
,
ok
:=
err
.
(
*
exec
.
ExitError
);
ok
&&
e
.
Sys
()
.
(
syscall
.
WaitStatus
)
.
ExitStatus
()
==
1
{
err
=
nil
// diff signals with 1 just a difference - problem exit code is 2
}
return
out
.
String
(),
err
}
func
TestGoTraceGen
(
t
*
testing
.
T
)
{
tmp
,
err
:=
ioutil
.
TempDir
(
""
,
"t-gotrace"
)
if
err
!=
nil
{
...
...
@@ -124,9 +143,13 @@ func TestGoTraceGen(t *testing.T) {
t
.
Errorf
(
"%v: %v"
,
tpkg
,
err
)
}
err
:=
diffR
(
good
+
"/"
+
tpkg
,
work
+
"/"
+
tpkg
)
diff
,
err
:=
diffR
(
good
+
"/"
+
tpkg
,
work
+
"/"
+
tpkg
)
if
err
!=
nil
{
t
.
Errorf
(
"%v: %v"
,
tpkg
,
err
)
t
.
Fatalf
(
"%v: %v"
,
tpkg
,
err
)
}
if
diff
!=
""
{
t
.
Errorf
(
"%v: gold & work differ:
\n
%s"
,
tpkg
,
diff
)
}
}
}
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