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
bdecaf11
Commit
bdecaf11
authored
Jan 17, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
508b7d5f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
19 deletions
+87
-19
go/internal/xtesting/xtesting.go
go/internal/xtesting/xtesting.go
+82
-0
go/zodb/storage/fs1/filestorage_test.go
go/zodb/storage/fs1/filestorage_test.go
+2
-2
go/zodb/storage/fs1/index_test.go
go/zodb/storage/fs1/index_test.go
+3
-17
No files found.
go/internal/xtesting/xtesting.go
0 → 100644
View file @
bdecaf11
// Copyright (C) 2017-2019 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// Package xtesting provides addons to std package testing.
package
xtesting
import
(
"os/exec"
"sync"
"testing"
)
var
(
pyMu
sync
.
Mutex
pyHave
=
map
[
string
]
bool
{}
// {} pymod -> y/n ; ".python" indicates python presence
)
// NeedPy skips current test if python and specified modules are not available.
//
// For example
//
// xtesting.NeedPy(t)
//
// would check for python presence, and
//
// xtesting.NeedPy(t, "ZODB", "golang.strconv")
//
// would check if all python and ZODB and golang.strconv python modules are available.
func
NeedPy
(
t
testing
.
TB
,
modules
...
string
)
{
pyMu
.
Lock
()
defer
pyMu
.
Unlock
()
// verify if python is present
havePy
,
know
:=
pyHave
[
".python"
]
if
!
know
{
cmd
:=
exec
.
Command
(
"python2"
,
"-c"
,
"0"
)
err
:=
cmd
.
Run
()
havePy
=
(
err
==
nil
)
pyHave
[
".python"
]
=
havePy
}
if
!
havePy
{
t
.
Skipf
(
"skipping: python is not availble"
)
}
var
donthave
[]
string
for
_
,
pymod
:=
range
modules
{
have
,
know
:=
pyHave
[
pymod
]
if
!
know
{
cmd
:=
exec
.
Command
(
"python2"
,
"-c"
,
"import "
+
pymod
)
err
:=
cmd
.
Run
()
have
=
(
err
==
nil
)
pyHave
[
pymod
]
=
have
}
if
!
have
{
donthave
=
append
(
donthave
,
pymod
)
}
}
if
len
(
donthave
)
!=
0
{
t
.
Skipf
(
"skipping: the following python modules are not available: %s"
,
donthave
)
}
// we verified everything - now it is ok not to skip.
return
}
go/zodb/storage/fs1/filestorage_test.go
View file @
bdecaf11
...
...
@@ -32,6 +32,7 @@ import (
"github.com/pkg/errors"
"lab.nexedi.com/kirr/neo/go/internal/xtesting"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/go123/exc"
...
...
@@ -359,8 +360,7 @@ func BenchmarkIterate(b *testing.B) {
func
TestWatch
(
t
*
testing
.
T
)
{
X
:=
exc
.
Raiseif
//xtesting.NeedPy(t, "zodbtools")
needZODBPy
(
t
)
xtesting
.
NeedPy
(
t
,
"zodbtools"
)
workdir
:=
xworkdir
(
t
)
tfs
:=
workdir
+
"/t.fs"
...
...
go/zodb/storage/fs1/index_test.go
View file @
bdecaf11
...
...
@@ -32,6 +32,7 @@ import (
"strings"
"testing"
"lab.nexedi.com/kirr/neo/go/internal/xtesting"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb/storage/fs1/fsb"
)
...
...
@@ -201,7 +202,7 @@ func TestIndexLoadFromPy(t *testing.T) {
// test zodb/py can read index data as saved by us
func
TestIndexSaveToPy
(
t
*
testing
.
T
)
{
needZODBPy
(
t
)
xtesting
.
NeedPy
(
t
,
"ZODB"
)
workdir
:=
xworkdir
(
t
)
err
:=
_1fs_index
.
SaveFile
(
workdir
+
"/1.fs.index"
)
...
...
@@ -289,19 +290,11 @@ func BenchmarkIndexGet(b *testing.B) {
}
}
var
haveZODBPy
=
false
var
workRoot
string
func
TestMain
(
m
*
testing
.
M
)
{
// check whether we have zodb/py XXX + zodbtools -> needPy(modv)
cmd
:=
exec
.
Command
(
"python2"
,
"-c"
,
"import ZODB"
)
err
:=
cmd
.
Run
()
if
err
==
nil
{
haveZODBPy
=
true
}
// setup work root for all tests
workRoot
,
err
=
ioutil
.
TempDir
(
""
,
"t-index"
)
workRoot
,
err
:
=
ioutil
.
TempDir
(
""
,
"t-index"
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
...
...
@@ -313,13 +306,6 @@ func TestMain(m *testing.M) {
os
.
Exit
(
exit
)
}
func
needZODBPy
(
t
*
testing
.
T
)
{
if
haveZODBPy
{
return
}
t
.
Skipf
(
"skipping: zodb/py is not available"
)
}
// create temp dir inside workRoot
func
xworkdir
(
t
testing
.
TB
)
string
{
work
,
err
:=
ioutil
.
TempDir
(
workRoot
,
""
)
...
...
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