-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(tapac): add test to tapa.verilog.xilinx.module
- Loading branch information
Showing
11 changed files
with
151 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"""Custom rule to test Python modules with pytest.""" | ||
|
||
# Copyright (c) 2025 RapidStream Design Automation, Inc. and contributors. | ||
# All rights reserved. The contributor(s) of this file has/have agreed to the | ||
# RapidStream Contributor License Agreement. | ||
|
||
load("@rules_python//python:defs.bzl", _py_test = "py_test") | ||
load("@tapa_deps//:requirements.bzl", "requirement") | ||
|
||
def py_test(name, srcs, deps = [], args = [], **kwargs): | ||
_py_test( | ||
name = name, | ||
main = "//bazel:pytest_wrapper.py", | ||
srcs = srcs + ["//bazel:pytest_wrapper.py"], | ||
deps = deps + [requirement("pytest")], | ||
args = args + ["$(location %s)" % x for x in srcs], | ||
**kwargs | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import sys | ||
|
||
import pytest | ||
|
||
__copyright__ = """ | ||
Copyright (c) 2025 RapidStream Design Automation, Inc. and contributors. | ||
All rights reserved. The contributor(s) of this file has/have agreed to the | ||
RapidStream Contributor License Agreement. | ||
""" | ||
|
||
if __name__ == "__main__": | ||
sys.exit(pytest.main(sys.argv[1:])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ coloredlogs | |
jinja2 | ||
nuitka | ||
psutil | ||
pytest | ||
pyverilog | ||
pyyaml | ||
toposort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Unit tests for tapa.verilog.xilinx.module.""" | ||
|
||
__copyright__ = """ | ||
Copyright (c) 2025 RapidStream Design Automation, Inc. and contributors. | ||
All rights reserved. The contributor(s) of this file has/have agreed to the | ||
RapidStream Contributor License Agreement. | ||
""" | ||
|
||
import pytest | ||
|
||
from tapa.verilog.xilinx.module import Module | ||
|
||
|
||
def test_invalid_module() -> None: | ||
with pytest.raises(ValueError, match="`files` and `name` cannot both be empty"): | ||
Module() | ||
|
||
|
||
def test_empty_module() -> None: | ||
"""An empty module can be constructed from a name. | ||
This is used to create placeholders before Verilog is parsed, and to create | ||
skeleton FSM modules. | ||
""" | ||
module = Module(name="foo") | ||
|
||
assert module.name == "foo" | ||
assert not module.ports |