Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
aac37c11
Commit
aac37c11
authored
Sep 13, 2021
by
Kirill Smelkov
2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X zdata: Introduce T to start removing duplication in tests
parent
f07502fc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
46 deletions
+41
-46
wcfs/internal/zdata/δftail_test.go
wcfs/internal/zdata/δftail_test.go
+41
-46
No files found.
wcfs/internal/zdata/δftail_test.go
View file @
aac37c11
...
...
@@ -64,6 +64,15 @@ type setStr = set.Str
const
ø
=
"ø"
// T is environment for doing ΔFtail tests.
//
// it is based on xbtreetest.T .
type
T
struct
{
*
xbtreetest
.
T
}
// ΔFTestEntry represents one entry in ΔFtail tests.
type
ΔFTestEntry
struct
{
δblkTab
map
[
int64
]
string
// changes in tree part {} #blk -> ZBlk<name>
...
...
@@ -181,7 +190,7 @@ func TestΔFtailRandom(t *testing.T) {
// testΔFtail verifies ΔFtail on sequence of testcases coming from testq.
func
testΔFtail
(
t_
*
testing
.
T
,
testq
chan
ΔFTestEntry
)
{
t
:=
xbtreetest
.
N
ewT
(
t_
)
t
:=
n
ewT
(
t_
)
X
:=
exc
.
Raiseif
// data built via applying changes from testq
...
...
@@ -272,26 +281,6 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
retrack
()
// δfstr/vδfstr converts δf/vδf to string taking symbolic at into account
δfstr
:=
func
(
δf
*
ΔFile
)
string
{
s
:=
fmt
.
Sprintf
(
"@%s·%s"
,
t
.
AtSymb
(
δf
.
Rev
),
δf
.
Blocks
)
if
δf
.
Epoch
{
s
+=
"E"
}
if
δf
.
Size
{
s
+=
"S"
}
return
s
}
vδfstr
:=
func
(
vδf
[]
*
ΔFile
)
string
{
var
s
[]
string
for
_
,
δf
:=
range
vδf
{
s
=
append
(
s
,
δfstr
(
δf
))
}
return
fmt
.
Sprintf
(
"%s"
,
s
)
}
i
:=
1
// matches t1
delfilePrev
:=
false
for
test
:=
range
testq
{
...
...
@@ -554,7 +543,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
vδf_ok
:=
vδf
[
j
:
k
+
1
]
// [j,k]
vδf_
:=
δFtail
.
SliceByFileRev
(
zfile
,
lo
,
hi
)
if
!
reflect
.
DeepEqual
(
vδf_
,
vδf_ok
)
{
t
.
Errorf
(
"slice (@%s,@%s]:
\n
have: %v
\n
want: %v"
,
t
.
AtSymb
(
lo
),
t
.
AtSymb
(
hi
),
vδfstr
(
vδf_
),
vδfstr
(
vδf_ok
))
t
.
Errorf
(
"slice (@%s,@%s]:
\n
have: %v
\n
want: %v"
,
t
.
AtSymb
(
lo
),
t
.
AtSymb
(
hi
),
t
.
vδfstr
(
vδf_
),
t
.
vδfstr
(
vδf_ok
))
}
}
}
...
...
@@ -611,7 +600,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
// we verify that no change to untracked block is missed, if any change to that
// block is ever present in returned slice.
func
TestΔFtailSliceUntrackedUniform
(
t_
*
testing
.
T
)
{
t
:=
xbtreetest
.
N
ewT
(
t_
)
t
:=
n
ewT
(
t_
)
X
:=
exc
.
Raiseif
at0
:=
t
.
Head
()
.
At
...
...
@@ -664,26 +653,6 @@ func TestΔFtailSliceUntrackedUniform(t_ *testing.T) {
δFtail
.
Track
(
zfile
,
blk
,
path
,
zblk
)
}
// δfstr/vδfstr converts δf/vδf to string taking symbolic at into account
// XXX dup
δfstr
:=
func
(
δf
*
ΔFile
)
string
{
s
:=
fmt
.
Sprintf
(
"@%s·%s"
,
t
.
AtSymb
(
δf
.
Rev
),
δf
.
Blocks
)
if
δf
.
Epoch
{
s
+=
"E"
}
if
δf
.
Size
{
s
+=
"S"
}
return
s
}
vδfstr
:=
func
(
vδf
[]
*
ΔFile
)
string
{
var
s
[]
string
for
_
,
δf
:=
range
vδf
{
s
=
append
(
s
,
δfstr
(
δf
))
}
return
fmt
.
Sprintf
(
"%s"
,
s
)
}
// track 0, but do not track 1 and 2.
// blktab[1] becomes noticed by δBtail because both 0 and 1 are in the same bucket and both are changed @at2.
// blktab[2] remains unnoticed because it is not changed past at1.
...
...
@@ -699,7 +668,7 @@ func TestΔFtailSliceUntrackedUniform(t_ *testing.T) {
&
ΔFile
{
Rev
:
t4
.
At
,
Blocks
:
b
(
1
),
Size
:
false
},
}
if
!
reflect
.
DeepEqual
(
vδf
,
vδf_ok
)
{
t
.
Errorf
(
"slice (@%s,@%s]:
\n
have: %v
\n
want: %v"
,
t
.
AtSymb
(
lo
),
t
.
AtSymb
(
hi
),
vδfstr
(
vδf
),
vδfstr
(
vδf_ok
))
t
.
Errorf
(
"slice (@%s,@%s]:
\n
have: %v
\n
want: %v"
,
t
.
AtSymb
(
lo
),
t
.
AtSymb
(
hi
),
t
.
vδfstr
(
vδf
),
t
.
vδfstr
(
vδf_ok
))
}
...
...
@@ -710,7 +679,7 @@ func TestΔFtailSliceUntrackedUniform(t_ *testing.T) {
&
ΔFile
{
Rev
:
t3
.
At
,
Blocks
:
b
(
0
),
Size
:
false
},
}
if
!
reflect
.
DeepEqual
(
vδf
,
vδf_ok
)
{
t
.
Errorf
(
"slice (@%s,@%s]:
\n
have: %v
\n
want: %v"
,
t
.
AtSymb
(
lo
),
t
.
AtSymb
(
hi
),
vδfstr
(
vδf
),
vδfstr
(
vδf_ok
))
t
.
Errorf
(
"slice (@%s,@%s]:
\n
have: %v
\n
want: %v"
,
t
.
AtSymb
(
lo
),
t
.
AtSymb
(
hi
),
t
.
vδfstr
(
vδf
),
t
.
vδfstr
(
vδf_ok
))
}
// (at3, at4] -> changes to only 0, ----/----
...
...
@@ -718,7 +687,7 @@ func TestΔFtailSliceUntrackedUniform(t_ *testing.T) {
vδf
=
δFtail
.
SliceByFileRev
(
zfile
,
lo
,
hi
)
vδf_ok
=
[]
*
ΔFile
(
nil
)
if
!
reflect
.
DeepEqual
(
vδf
,
vδf_ok
)
{
t
.
Errorf
(
"slice (@%s,@%s]:
\n
have: %v
\n
want: %v"
,
t
.
AtSymb
(
lo
),
t
.
AtSymb
(
hi
),
vδfstr
(
vδf
),
vδfstr
(
vδf_ok
))
t
.
Errorf
(
"slice (@%s,@%s]:
\n
have: %v
\n
want: %v"
,
t
.
AtSymb
(
lo
),
t
.
AtSymb
(
hi
),
t
.
vδfstr
(
vδf
),
t
.
vδfstr
(
vδf_ok
))
}
}
...
...
@@ -747,6 +716,32 @@ func dataTabTxt(dataTab map[string]string) string {
}
// newT creates new T.
func
newT
(
t
*
testing
.
T
)
*
T
{
return
&
T
{
xbtreetest
.
NewT
(
t
)}
}
// δfstr/vδfstr convert δf/vδf to string taking symbolic at into account.
func
(
t
*
T
)
δfstr
(
δf
*
ΔFile
)
string
{
s
:=
fmt
.
Sprintf
(
"@%s·%s"
,
t
.
AtSymb
(
δf
.
Rev
),
δf
.
Blocks
)
if
δf
.
Epoch
{
s
+=
"E"
}
if
δf
.
Size
{
s
+=
"S"
}
return
s
}
func
(
t
*
T
)
vδfstr
(
vδf
[]
*
ΔFile
)
string
{
var
s
[]
string
for
_
,
δf
:=
range
vδf
{
s
=
append
(
s
,
t
.
δfstr
(
δf
))
}
return
fmt
.
Sprintf
(
"%s"
,
s
)
}
// b is shorthand to create setI64(blocks).
func
b
(
blocks
...
int64
)
setI64
{
s
:=
setI64
{}
...
...
Kirill Smelkov
@kirr
mentioned in commit
23d8da82
·
Oct 27, 2021
mentioned in commit
23d8da82
mentioned in commit 23d8da82b89134b00ae8dafeb0a5c7348dd8b4fe
Toggle commit list
Kirill Smelkov
@kirr
mentioned in commit
f980471f
·
Oct 28, 2021
mentioned in commit
f980471f
mentioned in commit f980471f6bd466f7da6fbe6753a7a14b1d3c8151
Toggle commit list
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