Skip to content

Commit

Permalink
ci: split pytest script into multiple files
Browse files Browse the repository at this point in the history
  • Loading branch information
umarcor committed Jan 28, 2021
1 parent 1beee2f commit 9b3842c
Show file tree
Hide file tree
Showing 9 changed files with 311 additions and 200 deletions.
70 changes: 61 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,27 @@ jobs:
run: echo "$(pwd)/.github/bin" >> $GITHUB_PATH

- name: '🚧 Run tests'
run: dockerRun ghdl/cosim:xyce python3 -m pytest -v -s -ra test.py::TestExamples::test_vhpidirect_vffi_xyce --color=yes
run: |
dockerRun ghdl/cosim:xyce \
python3 -m pytest -v -s -ra \
tests/test_vhpidirect_vffi.py::TestVFFI::test_xyce \
--color=yes
lin-docker:
name: '🛳️ ghdl/cosim:matplotlib'
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 3
matrix:
test:
- vhpidirect_quickstart
- vhpidirect_grt
- vhpidirect_shared
- vhpidirect_arrays
- vhpidirect_vffi
- vpi_quickstart
name: '🛳️ ghdl/cosim:matplotlib · ${{ matrix.test }}'
env:
DOCKER_BUILDKIT: 1
steps:
Expand All @@ -43,12 +58,27 @@ jobs:
run: echo "$(pwd)/.github/bin" >> $GITHUB_PATH

- name: '🚧 Run tests'
run: dockerRun ghdl/cosim:matplotlib python3 -m pytest -v -s -ra test.py --color=yes
run: |
dockerRun ghdl/cosim:matplotlib \
python3 -m pytest -v -s -ra \
tests/test_${{ matrix.test }}.py \
--color=yes
lin-setup:
name: '🐧Ubuntu · nightly LLVM'
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 3
matrix:
test:
- vhpidirect_quickstart
- vhpidirect_grt
- vhpidirect_shared
- vhpidirect_arrays
- vhpidirect_vffi
- vpi_quickstart
name: '🐧 Ubuntu LLVM · ${{ matrix.test }}'
steps:

- name: '🧰 Checkout'
Expand All @@ -72,12 +102,23 @@ jobs:
python -m pip install --progress-bar off pytest vunit_hdl matplotlib numpy
- name: '🚧 Run tests'
run: python -m pytest -v -s -ra test.py --color=yes
run: python -m pytest -v -s -ra tests/test_${{ matrix.test }}.py --color=yes


win-setup:
name: '🟪 MSYS2 · nightly LLVM'
runs-on: windows-latest
strategy:
fail-fast: false
max-parallel: 3
matrix:
test:
- vhpidirect_quickstart
- vhpidirect_grt
- vhpidirect_shared
- vhpidirect_arrays
- vhpidirect_vffi
- vpi_quickstart
name: '🟪 MSYS2 nightly · ${{ matrix.test }}'
defaults:
run:
shell: msys2 {0}
Expand Down Expand Up @@ -107,12 +148,23 @@ jobs:
run: python -m pip install --progress-bar off pytest vunit_hdl

- name: '🚧 Run tests'
run: python -m pytest -v -s -ra test.py --color=yes
run: python -m pytest -v -s -ra tests/test_${{ matrix.test }}.py --color=yes


win-msys:
name: '🟪 MSYS2 · pacman LLVM'
runs-on: windows-latest
strategy:
fail-fast: false
max-parallel: 3
matrix:
test:
- vhpidirect_quickstart
- vhpidirect_grt
- vhpidirect_shared
- vhpidirect_arrays
- vhpidirect_vffi
- vpi_quickstart
name: '🟪 MSYS2 pacman · ${{ matrix.test }}'
defaults:
run:
shell: msys2 {0}
Expand All @@ -138,7 +190,7 @@ jobs:
run: python -m pip install --progress-bar off pytest vunit_hdl

- name: '🚧 Run tests'
run: python -m pytest -v -s -ra test.py --color=yes
run: python -m pytest -v -s -ra tests/test_${{ matrix.test }}.py --color=yes

#--

Expand Down
191 changes: 0 additions & 191 deletions test.py

This file was deleted.

56 changes: 56 additions & 0 deletions tests/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""
Verify that all example run scripts work correctly
"""

import sys
from sys import executable, platform
from pathlib import Path
from subprocess import check_call, STDOUT
from shutil import which
from unittest import TestCase


isWin = platform == 'win32'


class TestExamples(TestCase):
"""
Verify that example run scripts work correctly
"""

def __init__(self, name):
super().__init__(name)
self.shell = [which('bash')] if platform == 'win32' else []
self.root = Path(__file__).parent.parent


def setUp(self):
print('\n::group::Log')
sys.stdout.flush()

def tearDown(self):
print('\n::endgroup::')
sys.stdout.flush()


def _sh(self, args):
check_call(self.shell + args, stderr=STDOUT)

def _py(self, args):
check_call([executable] + args, stderr=STDOUT)


class TestVHPIDIRECT(TestExamples):

def __init__(self, name):
super().__init__(name)
self.vhpidirect = self.root / 'vhpidirect'
self.output_path = self.root / 'examples_run_out'
self.report_file = self.output_path / 'xunit.xml'


class TestVPI(TestExamples):

def __init__(self, name):
super().__init__(name)
self.vpi = self.root / 'vpi'
Loading

0 comments on commit 9b3842c

Please sign in to comment.