Skip to content

Commit

Permalink
Merge pull request #165 from zeroasiccorp/lint-pytest
Browse files Browse the repository at this point in the history
add pytest with slang linting
  • Loading branch information
gadfort authored Aug 29, 2024
2 parents 208fbc9 + 831f4e0 commit 2e82aaa
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,27 @@ jobs:

- name: pytest
run: |
python3 -m venv venv
. venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install -e .[test]
pytest -m "switchboard" -n auto
python_ci:
name: "Python + Tools CI"
runs-on: ubuntu-latest
container:
image: ghcr.io/siliconcompiler/sc_tools:latest
timeout-minutes: 10

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: pytest
run: |
python3 -m venv venv
. venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install -e .[test]
pytest -m "not switchboard" -n auto
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ markers = [
"switchboard: this test requires switchboard to run"
]
testpaths = [
"tests",
"umi/sumi/tests"
]
timeout = "300"
18 changes: 18 additions & 0 deletions tests/conftest.py
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)
41 changes: 41 additions & 0 deletions tests/test_lint.py
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

0 comments on commit 2e82aaa

Please sign in to comment.