amaranth/tests/test_examples.py
whitequark 67b957d4f4 tests: move out of the main package.
Compared to tests in the repository root, tests in the package have
many downsides:
  * Unless explicitly excluded in find_packages(), tests and their
    support code effectively become a part of public API.
    This, unfortunately, happened with FHDLTestCase, which was never
    intended for downstream use.
  * Even if explicitly excluded from the setuptools package, using
    an editable install, or setting PYTHONPATH still allows accessing
    the tests.
  * Having a sub-package that is present in the source tree but not
    exported (or, worse, exported only sometimes) is confusing.
  * The name `nmigen.test` cannot be used for anything else, such as
    testing utilities that *are* intended for downstream use.
2020-08-27 00:33:31 +00:00

34 lines
1.2 KiB
Python

import sys
import subprocess
from pathlib import Path
from .utils import *
def example_test(name):
path = (Path(__file__).parent / ".." / "examples" / name).resolve()
def test_function(self):
subprocess.check_call([sys.executable, str(path), "generate", "-t", "v"],
stdout=subprocess.DEVNULL)
return test_function
class ExamplesTestCase(FHDLTestCase):
test_alu = example_test("basic/alu.py")
test_alu_hier = example_test("basic/alu_hier.py")
test_arst = example_test("basic/arst.py")
test_cdc = example_test("basic/cdc.py")
test_ctr = example_test("basic/ctr.py")
test_ctr_en = example_test("basic/ctr_en.py")
test_fsm = example_test("basic/fsm.py")
test_gpio = example_test("basic/gpio.py")
test_inst = example_test("basic/inst.py")
test_mem = example_test("basic/mem.py")
test_pmux = example_test("basic/pmux.py")
test_por = example_test("basic/por.py")
def test_uart(self):
path = (Path(__file__).parent / ".." / "examples" / "basic" / "uart.py").resolve()
subprocess.check_call([sys.executable, str(path), "generate"],
stdout=subprocess.DEVNULL)