-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from zeroasiccorp/lint-pytest
add pytest with slang linting
- Loading branch information
Showing
4 changed files
with
81 additions
and
0 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
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 @@ | ||
import pytest | ||
import os | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def test_wrapper(tmp_path): | ||
''' | ||
Fixture that automatically runs each test in a test-specific temporary | ||
directory to avoid clutter. | ||
''' | ||
|
||
topdir = os.getcwd() | ||
os.chdir(tmp_path) | ||
|
||
# Run the test. | ||
yield | ||
|
||
os.chdir(topdir) |
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,41 @@ | ||
from siliconcompiler import Chip | ||
from siliconcompiler.flows import lintflow | ||
import glob | ||
import pytest | ||
import umi | ||
import shutil | ||
from pathlib import Path | ||
|
||
|
||
@pytest.fixture | ||
def slang_chip(): | ||
chip = Chip('lint') | ||
chip.use(lintflow, tool='slang') | ||
|
||
chip.use(umi) | ||
chip.set('option', 'flow', 'lintflow') | ||
|
||
return chip | ||
|
||
|
||
@pytest.fixture | ||
def slang(): | ||
if shutil.which('slang') is None: | ||
pytest.skip('slang is not installed') | ||
|
||
|
||
def __filelist(): | ||
return glob.glob(str(Path(umi.__file__).parent / '**' / 'rtl' / '*.v')) | ||
|
||
|
||
@pytest.mark.parametrize('file', __filelist()) | ||
def test_lint_slang(slang_chip, file): | ||
slang_chip.set('option', 'entrypoint', Path(file).stem) | ||
|
||
if slang_chip.get('option', 'entrypoint') == 'umi_packet_merge_greedy': | ||
pytest.skip(reason='File is outdaded and will be cleaned up later') | ||
|
||
slang_chip.input(file) | ||
slang_chip.run() | ||
|
||
assert slang_chip.get('record', 'toolexitcode', step='lint', index='0') == 0 |