|
| 1 | +import unittest |
| 2 | +import os.path |
| 3 | +import sys |
| 4 | +import subprocess |
| 5 | + |
| 6 | + |
| 7 | +def _make_test_method(name, foldername): |
| 8 | + def test_method(self): |
| 9 | + filename = name + ".py" |
| 10 | + example_path = os.path.abspath( |
| 11 | + os.path.join(os.path.dirname(__file__), "..", "..", "examples")) |
| 12 | + filepath = os.path.join(example_path, foldername, filename) |
| 13 | + subprocess.check_call( |
| 14 | + [sys.executable, filepath], |
| 15 | + stdout=subprocess.DEVNULL |
| 16 | + ) |
| 17 | + |
| 18 | + return test_method |
| 19 | + |
| 20 | + |
| 21 | +class TestExamplesSim(unittest.TestCase): |
| 22 | + pass |
| 23 | + |
| 24 | +for name in ("abstract_transactions_wb", |
| 25 | + "basic1", |
| 26 | + "basic2", |
| 27 | + "dataflow", |
| 28 | + # skip "fir" as it depends on SciPy |
| 29 | + # "fir", |
| 30 | + "memory"): |
| 31 | + setattr(TestExamplesSim, "test_" + name, |
| 32 | + _make_test_method(name, "sim")) |
| 33 | + |
| 34 | + |
| 35 | +class TestExamplesBasic(unittest.TestCase): |
| 36 | + pass |
| 37 | + |
| 38 | +for name in ("arrays", |
| 39 | + "complex", |
| 40 | + "fsm", |
| 41 | + "graycounter", |
| 42 | + "hamming", |
| 43 | + "local_cd", |
| 44 | + "memory", |
| 45 | + "namer", |
| 46 | + "psync", |
| 47 | + "record", |
| 48 | + "reslice", |
| 49 | + "simple_gpio", |
| 50 | + "tristate", |
| 51 | + "two_dividers"): |
| 52 | + setattr(TestExamplesBasic, "test_" + name, |
| 53 | + _make_test_method(name, "basic")) |
| 54 | + |
| 55 | + |
| 56 | +class TestDataflow(unittest.TestCase): |
| 57 | + pass |
| 58 | + |
| 59 | +for name in ("dma", |
| 60 | + "misc", |
| 61 | + # skip "structuring" as it depends on networkx, SciPy |
| 62 | + # "structuring", |
| 63 | + ): |
| 64 | + setattr(TestDataflow, "test_" + name, |
| 65 | + _make_test_method(name, "dataflow")) |
0 commit comments