Skip to content

Commit

Permalink
Change to single lib name
Browse files Browse the repository at this point in the history
  • Loading branch information
ed-xmos committed Jul 27, 2023
1 parent 1c8fe55 commit b90cbe2
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 36 deletions.
2 changes: 1 addition & 1 deletion test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def pytest_collection_modifyitems(config, items):

def pytest_addoption(parser):
parser.addoption("--nightly", action="store_true")
parser.addoption("--lib_names", action="store", default=[], help="Optional list of libs to verify the output from")
parser.addoption("--lib_name", action="store", default=[], help="Optional lib to verify the output from")


@pytest.fixture
Expand Down
4 changes: 3 additions & 1 deletion test/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ tests_end=`date +%s`
#****************************
# Check results
#****************************
pytest test_verify_results.py --lib_names '${hil_test_libs[*]'}
for lib in ${hil_test_libs[@]}; do
pytest test_verify_results.py --lib_name ${lib}
done

#****************************
# Display time results
Expand Down
67 changes: 33 additions & 34 deletions test/test_verify_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,36 @@


@pytest.fixture(scope="session")
def lib_names(pytestconfig):
lib_names = pytestconfig.getoption("lib_names").split()
return lib_names

def test_results(lib_names):

for lib in lib_names:
result_fname = f"test_results_{lib}.xml"
tree = ET.parse(result_fname)
root = tree.getroot()
tsuite = root.find("testsuite")

acceptable_outcomes = ("skipped",)


# There should at least be some tests in here. Assert that this is the case.
assert len(tsuite) > 0

for testcase in tsuite.iter("testcase"):

# Test passed if there are no children
if len(testcase) == 0:
if "name" in testcase.attrib:
print(testcase.attrib['name'], "passed")
continue
# Otherwise, test was either skipped, errored, or failed. The testcase
# will have a child with a relevant tag - skipped, error, or failure.
# If the tag is acceptable then carry on, or otherwise assert failure.
else:
for child in testcase:
assert (
child.tag in acceptable_outcomes
), f"A test reports as {child.tag}, which is not accepted."
print(testcase.attrib['name'], child.tag )
def lib_name(pytestconfig):
lib_name = pytestconfig.getoption("lib_name").split()
return lib_name

def test_results(lib_name):
lib = lib_name[0]
result_fname = f"test_results_{lib}.xml"
tree = ET.parse(result_fname)
root = tree.getroot()
tsuite = root.find("testsuite")

acceptable_outcomes = ("skipped",)


# There should at least be some tests in here. Assert that this is the case.
assert len(tsuite) > 0

for testcase in tsuite.iter("testcase"):

# Test passed if there are no children
if len(testcase) == 0:
if "name" in testcase.attrib:
print(testcase.attrib['name'], "passed")
continue
# Otherwise, test was either skipped, errored, or failed. The testcase
# will have a child with a relevant tag - skipped, error, or failure.
# If the tag is acceptable then carry on, or otherwise assert failure.
else:
for child in testcase:
assert (
child.tag in acceptable_outcomes
), f"A test reports as {child.tag}, which is not accepted."
print(testcase.attrib['name'], child.tag )

0 comments on commit b90cbe2

Please sign in to comment.