Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Kestrel Collaboration
Kestrel LiteX
migen
Commits
36e82d3f
Commit
36e82d3f
authored
7 years ago
by
William D. Jones
Browse files
Options
Download
Email Patches
Plain Diff
test/platform: Refactor tests as subTests.
parent
210c4fda
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
21 deletions
+13
-21
migen/test/test_platform.py
migen/test/test_platform.py
+13
-21
No files found.
migen/test/test_platform.py
View file @
36e82d3f
import
unittest
import
importlib
import
pkgutil
import
shut
il
import
tempf
il
e
from
migen
import
*
from
migen.genlib.cdc
import
MultiReg
import
migen.build.platforms
def
_make_platform_test_method
(
mod
,
name
):
def
platform_test_method
(
self
):
plat
=
importlib
.
import_module
(
mod
).
Platform
()
m
=
TestModulePlatform
(
plat
)
plat
.
build
(
m
,
run
=
False
,
build_name
=
name
,
build_dir
=
name
)
shutil
.
rmtree
(
name
)
return
platform_test_method
def
_find_platforms
(
mod_root
):
def
mk_name
(
mod
,
child
):
return
"."
.
join
([
mod
.
__name__
,
child
])
...
...
@@ -42,13 +32,15 @@ class TestModulePlatform(Module):
class
TestExamplesPlatform
(
unittest
.
TestCase
):
pass
for
mod
,
name
in
_find_platforms
(
migen
.
build
.
platforms
):
# Roach has no default clock, so expect failure.
if
name
==
"roach"
:
test_fcn
=
unittest
.
expectedFailure
(
_make_platform_test_method
(
mod
,
name
))
else
:
test_fcn
=
_make_platform_test_method
(
mod
,
name
)
setattr
(
TestExamplesPlatform
,
"test_"
+
name
,
test_fcn
)
def
test_platforms
(
self
):
for
mod
,
name
in
_find_platforms
(
migen
.
build
.
platforms
):
with
self
.
subTest
(
mod
=
mod
,
name
=
name
):
# Roach has no default clock, so expect failure/skip.
if
name
==
"roach"
:
pass
else
:
plat
=
importlib
.
import_module
(
mod
).
Platform
()
m
=
TestModulePlatform
(
plat
)
with
tempfile
.
TemporaryDirectory
(
name
)
as
temp_dir
:
plat
.
build
(
m
,
run
=
False
,
build_name
=
name
,
build_dir
=
temp_dir
)
This diff is collapsed.
Click to expand it.
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