test: move stage-tests into test/run and test/data
Move the stage-tests over to the new test-infrastructure. This moves the test invocation into `./test/run/test_stages.py`, so it is invoked as part of the runtime-tests. Secondly, the test-data is stored in ./test/data/stages/ so the path is relative to TestBase.locate_test_data(). While at it, this also drops the dynamic class modifications and instead uses subTest(). This simplifies the code quite a bit and avoids dynamically creating python code.
This commit is contained in:
parent
e8445da3d9
commit
d584a1e225
47 changed files with 13 additions and 40 deletions
22
.github/workflows/runtime-tests.yml
vendored
22
.github/workflows/runtime-tests.yml
vendored
|
|
@ -46,25 +46,3 @@ jobs:
|
||||||
run: pip install jsonschema
|
run: pip install jsonschema
|
||||||
- name: "Run Assembler Tests"
|
- name: "Run Assembler Tests"
|
||||||
run: sudo env "PATH=$PATH" python3 -m unittest -v test.test_assemblers
|
run: sudo env "PATH=$PATH" python3 -m unittest -v test.test_assemblers
|
||||||
|
|
||||||
stage_tests:
|
|
||||||
name: "Stage Tests"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: "Clone Repository"
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: "Install Dependencies"
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get -y install \
|
|
||||||
systemd-container \
|
|
||||||
tar \
|
|
||||||
yum
|
|
||||||
- name: "Set up Python"
|
|
||||||
uses: actions/setup-python@v1
|
|
||||||
with:
|
|
||||||
python-version: 3.7
|
|
||||||
- name: Install Python Packages
|
|
||||||
run: pip install jsonschema
|
|
||||||
- name: "Run Stage Tests"
|
|
||||||
run: sudo env "PATH=$PATH" python3 -m unittest -v test.test_stages
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
#
|
||||||
|
# Runtime tests for the individual stages.
|
||||||
|
#
|
||||||
|
|
||||||
import difflib
|
import difflib
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
@ -5,10 +9,12 @@ import pprint
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from . import test
|
from .. import test
|
||||||
|
|
||||||
|
|
||||||
class TestDescriptions(test.TestBase):
|
@unittest.skipUnless(test.TestBase.have_test_data(), "no test-data access")
|
||||||
|
@unittest.skipUnless(test.TestBase.have_tree_diff(), "tree-diff missing")
|
||||||
|
class TestStages(test.TestBase):
|
||||||
|
|
||||||
def assertTreeDiffsEqual(self, tree_diff1, tree_diff2):
|
def assertTreeDiffsEqual(self, tree_diff1, tree_diff2):
|
||||||
"""
|
"""
|
||||||
|
|
@ -113,19 +119,8 @@ class TestDescriptions(test.TestBase):
|
||||||
|
|
||||||
self.assertTreeDiffsEqual(expected_diff, actual_diff)
|
self.assertTreeDiffsEqual(expected_diff, actual_diff)
|
||||||
|
|
||||||
|
def test_stages(self):
|
||||||
def generate_test_case(path):
|
path = os.path.join(self.locate_test_data(), "stages")
|
||||||
@unittest.skipUnless(test.TestBase.have_tree_diff(), "tree-diff missing")
|
for name in os.listdir(path):
|
||||||
def test_case(self):
|
with self.subTest(stage=name):
|
||||||
self.run_stage_test(path)
|
self.run_stage_test(os.path.join(path, name))
|
||||||
|
|
||||||
return test_case
|
|
||||||
|
|
||||||
|
|
||||||
def init_tests():
|
|
||||||
test_dir = 'test/stages_tests'
|
|
||||||
for name in os.listdir(test_dir):
|
|
||||||
setattr(TestDescriptions, f"test_{name}", generate_test_case(f"{test_dir}/{name}"))
|
|
||||||
|
|
||||||
|
|
||||||
init_tests()
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue