Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
c19cd1a7
Commit
c19cd1a7
authored
Mar 14, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X zodbdump/go test passes
parent
d72d2f34
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
6 deletions
+26
-6
t/neo/zodb/cmd/zodbdump/testdata/1.zdump.pyok
t/neo/zodb/cmd/zodbdump/testdata/1.zdump.pyok
+0
-0
t/neo/zodb/cmd/zodbdump/zodbdump_test.go
t/neo/zodb/cmd/zodbdump/zodbdump_test.go
+26
-6
No files found.
t/neo/zodb/cmd/zodbdump/testdata/1.zdump.ok
→
t/neo/zodb/cmd/zodbdump/testdata/1.zdump.
py
ok
View file @
c19cd1a7
No preview for this file type
t/neo/zodb/cmd/zodbdump/zodbdump_test.go
View file @
c19cd1a7
...
@@ -2,11 +2,12 @@
...
@@ -2,11 +2,12 @@
package
main
package
main
//go:generate sh -c "python2 -m zodbtool.zodbdump testdata/1.conf >testdata/1.zdump.ok"
//go:generate sh -c "python2 -m zodbtool.zodbdump testdata/1.conf >testdata/1.zdump.
py
ok"
import
(
import
(
"bytes"
"bytes"
"io/ioutil"
"io/ioutil"
"regexp"
"testing"
"testing"
"../../../storage/fs1"
"../../../storage/fs1"
...
@@ -16,12 +17,35 @@ import (
...
@@ -16,12 +17,35 @@ import (
"lab.nexedi.com/kirr/go123/exc"
"lab.nexedi.com/kirr/go123/exc"
)
)
// diff computes difference for two strings a and b
func
diff
(
a
,
b
string
)
string
{
func
diff
(
a
,
b
string
)
string
{
dmp
:=
diffmatchpatch
.
New
()
dmp
:=
diffmatchpatch
.
New
()
diffv
:=
dmp
.
DiffMain
(
a
,
b
,
/*checklines=*/
false
)
diffv
:=
dmp
.
DiffMain
(
a
,
b
,
/*checklines=*/
false
)
return
dmp
.
DiffPrettyText
(
diffv
)
return
dmp
.
DiffPrettyText
(
diffv
)
}
}
// loadZdumpPy loads a zdump file and normalizes escaped strings to the way go
// would escape them
func
loadZdumpPy
(
t
*
testing
.
T
,
path
string
)
string
{
dump
,
err
:=
ioutil
.
ReadFile
(
path
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
// python qoutes "\v" as "\x0b", go as "\v"; same for "\f" vs "\x0c"
// XXX this is a bit hacky. We could compare quoted strings as decoded,
// but this would need zdump format parser which could contain other
// bugs. Here we want to compare output ideally bit-to-bit but those
// \v vs \x0b glitches prevents that to be done directly. So here we
// are with this ugly hack:
r0b
:=
regexp
.
MustCompile
(
`\\x0b`
)
r0c
:=
regexp
.
MustCompile
(
`\\x0c`
)
dump
=
r0b
.
ReplaceAllLiteral
(
dump
,
[]
byte
(
`\v`
))
dump
=
r0c
.
ReplaceAllLiteral
(
dump
,
[]
byte
(
`\f`
))
return
string
(
dump
)
}
func
TestZodbDump
(
t
*
testing
.
T
)
{
func
TestZodbDump
(
t
*
testing
.
T
)
{
buf
:=
bytes
.
Buffer
{}
buf
:=
bytes
.
Buffer
{}
fs
,
err
:=
fs1
.
Open
(
"../../../storage/fs1/testdata/1.fs"
)
// XXX read-only, path?
fs
,
err
:=
fs1
.
Open
(
"../../../storage/fs1/testdata/1.fs"
)
// XXX read-only, path?
...
@@ -36,11 +60,7 @@ func TestZodbDump(t *testing.T) {
...
@@ -36,11 +60,7 @@ func TestZodbDump(t *testing.T) {
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
__
,
err
:=
ioutil
.
ReadFile
(
"testdata/1.zdump.ok"
)
dumpOk
:=
loadZdumpPy
(
t
,
"testdata/1.zdump.pyok"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
dumpOk
:=
string
(
__
)
if
dumpOk
!=
buf
.
String
()
{
if
dumpOk
!=
buf
.
String
()
{
t
.
Errorf
(
"dump different:
\n
%v"
,
diff
(
dumpOk
,
buf
.
String
()))
t
.
Errorf
(
"dump different:
\n
%v"
,
diff
(
dumpOk
,
buf
.
String
()))
...
...
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