Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
reprotest
Manage
Activity
Members
Labels
Plan
Issues
9
Issue boards
Milestones
Code
Merge requests
4
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Reproducible Builds
reprotest
Commits
0c17de77
Commit
0c17de77
authored
3 years ago
by
Frédéric Pierret
Committed by
Holger Levsen
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
test_reprotest: add spaces and regorganize functions
Signed-off-by:
Holger Levsen
<
holger@layer-acht.org
>
parent
4ac84ed5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_reprotest.py
+15
-6
15 additions, 6 deletions
tests/test_reprotest.py
with
15 additions
and
6 deletions
tests/test_reprotest.py
+
15
−
6
View file @
0c17de77
...
@@ -4,10 +4,10 @@
...
@@ -4,10 +4,10 @@
import
contextlib
import
contextlib
import
logging
import
logging
import
os
import
os
import
pytest
import
subprocess
import
subprocess
import
sys
import
sys
import
pytest
import
reprotest
import
reprotest
from
reprotest.build
import
VariationSpec
,
Variations
,
VARIATIONS
from
reprotest.build
import
VariationSpec
,
Variations
,
VARIATIONS
...
@@ -20,6 +20,7 @@ if REPROTEST_TEST_DONTVARY:
...
@@ -20,6 +20,7 @@ if REPROTEST_TEST_DONTVARY:
TEST_VARIATIONS
=
frozenset
(
VARIATIONS
.
keys
())
-
frozenset
(
REPROTEST_TEST_DONTVARY
)
TEST_VARIATIONS
=
frozenset
(
VARIATIONS
.
keys
())
-
frozenset
(
REPROTEST_TEST_DONTVARY
)
def
check_reproducibility
(
command
,
virtual_server
,
reproducible
):
def
check_reproducibility
(
command
,
virtual_server
,
reproducible
):
result
=
reprotest
.
check
(
result
=
reprotest
.
check
(
reprotest
.
TestArgs
.
of
(
command
,
'
tests
'
,
'
artifact
'
),
reprotest
.
TestArgs
.
of
(
command
,
'
tests
'
,
'
artifact
'
),
...
@@ -27,6 +28,7 @@ def check_reproducibility(command, virtual_server, reproducible):
...
@@ -27,6 +28,7 @@ def check_reproducibility(command, virtual_server, reproducible):
Variations
.
of
(
VariationSpec
.
default
(
TEST_VARIATIONS
)))
Variations
.
of
(
VariationSpec
.
default
(
TEST_VARIATIONS
)))
assert
result
==
reproducible
assert
result
==
reproducible
def
check_command_line
(
command_line
,
code
=
None
):
def
check_command_line
(
command_line
,
code
=
None
):
try
:
try
:
retcode
=
0
retcode
=
0
...
@@ -41,6 +43,7 @@ def check_command_line(command_line, code=None):
...
@@ -41,6 +43,7 @@ def check_command_line(command_line, code=None):
else
:
else
:
assert
(
retcode
in
code
)
assert
(
retcode
in
code
)
@pytest.fixture
(
scope
=
'
module
'
,
params
=
REPROTEST_TEST_SERVERS
)
@pytest.fixture
(
scope
=
'
module
'
,
params
=
REPROTEST_TEST_SERVERS
)
def
virtual_server
(
request
):
def
virtual_server
(
request
):
if
request
.
param
==
'
null
'
:
if
request
.
param
==
'
null
'
:
...
@@ -52,11 +55,6 @@ def virtual_server(request):
...
@@ -52,11 +55,6 @@ def virtual_server(request):
else
:
else
:
raise
ValueError
(
request
.
param
)
raise
ValueError
(
request
.
param
)
def
test_simple_builds
(
virtual_server
):
check_reproducibility
(
'
python3 mock_build.py
'
,
virtual_server
,
True
)
with
pytest
.
raises
(
Exception
):
check_reproducibility
(
'
python3 mock_failure.py
'
,
virtual_server
)
check_reproducibility
(
'
python3 mock_build.py irreproducible
'
,
virtual_server
,
False
)
@contextlib.contextmanager
@contextlib.contextmanager
def
setup_logging
(
debug
):
def
setup_logging
(
debug
):
...
@@ -82,6 +80,14 @@ def setup_logging(debug):
...
@@ -82,6 +80,14 @@ def setup_logging(debug):
logger
.
removeHandler
(
ch
)
logger
.
removeHandler
(
ch
)
logger
.
setLevel
(
oldLevel
)
logger
.
setLevel
(
oldLevel
)
def
test_simple_builds
(
virtual_server
):
check_reproducibility
(
'
python3 mock_build.py
'
,
virtual_server
,
True
)
with
pytest
.
raises
(
Exception
):
check_reproducibility
(
'
python3 mock_failure.py
'
,
virtual_server
)
check_reproducibility
(
'
python3 mock_build.py irreproducible
'
,
virtual_server
,
False
)
# TODO: test all variations that we support
# TODO: test all variations that we support
@pytest.mark.parametrize
(
'
captures
'
,
list
(
VARIATIONS
.
keys
()))
@pytest.mark.parametrize
(
'
captures
'
,
list
(
VARIATIONS
.
keys
()))
def
test_variations
(
virtual_server
,
captures
):
def
test_variations
(
virtual_server
,
captures
):
...
@@ -89,6 +95,7 @@ def test_variations(virtual_server, captures):
...
@@ -89,6 +95,7 @@ def test_variations(virtual_server, captures):
with
setup_logging
(
False
):
with
setup_logging
(
False
):
check_reproducibility
(
'
python3 mock_build.py
'
+
captures
,
virtual_server
,
expected
)
check_reproducibility
(
'
python3 mock_build.py
'
+
captures
,
virtual_server
,
expected
)
@pytest.mark.need_builddeps
@pytest.mark.need_builddeps
def
test_self_build
(
virtual_server
):
def
test_self_build
(
virtual_server
):
# at time of writing (2016-09-23) these are not expected to reproduce;
# at time of writing (2016-09-23) these are not expected to reproduce;
...
@@ -98,6 +105,7 @@ def test_self_build(virtual_server):
...
@@ -98,6 +105,7 @@ def test_self_build(virtual_server):
assert
(
1
==
subprocess
.
call
(
REPROTEST
+
[
'
python3 setup.py bdist
'
,
'
dist/*.tar.gz
'
]
+
virtual_server
))
assert
(
1
==
subprocess
.
call
(
REPROTEST
+
[
'
python3 setup.py bdist
'
,
'
dist/*.tar.gz
'
]
+
virtual_server
))
assert
(
1
==
subprocess
.
call
(
REPROTEST
+
[
'
python3 setup.py sdist
'
,
'
dist/*.tar.gz
'
]
+
virtual_server
))
assert
(
1
==
subprocess
.
call
(
REPROTEST
+
[
'
python3 setup.py sdist
'
,
'
dist/*.tar.gz
'
]
+
virtual_server
))
def
test_command_lines
():
def
test_command_lines
():
test_args
,
_
,
_
=
check_command_line
(
"
.
"
.
split
(),
0
)
test_args
,
_
,
_
=
check_command_line
(
"
.
"
.
split
(),
0
)
assert
test_args
.
artifact_pattern
is
not
None
assert
test_args
.
artifact_pattern
is
not
None
...
@@ -128,6 +136,7 @@ def test_command_lines():
...
@@ -128,6 +136,7 @@ def test_command_lines():
_
,
testbed_args
,
_
=
check_command_line
(
"
. -- schroot unstable-amd64-sbuild
"
.
split
(),
0
)
_
,
testbed_args
,
_
=
check_command_line
(
"
. -- schroot unstable-amd64-sbuild
"
.
split
(),
0
)
assert
testbed_args
.
virtual_server_args
==
[
'
schroot
'
,
'
unstable-amd64-sbuild
'
]
assert
testbed_args
.
virtual_server_args
==
[
'
schroot
'
,
'
unstable-amd64-sbuild
'
]
# TODO: don't call it if we don't have debian/, e.g. for other distros
# TODO: don't call it if we don't have debian/, e.g. for other distros
@pytest.mark.need_builddeps
@pytest.mark.need_builddeps
def
test_debian_build
(
virtual_server
):
def
test_debian_build
(
virtual_server
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment