Skip to content

Commit

Permalink
[SCons] Remove unittest specific code
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Jan 14, 2022
1 parent 5403f95 commit 06a14a5
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions test/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,19 @@ def addTestProgram(subdir, progName, env_vars={}):
[], [Delete(passedFile.abspath)]))


def addPythonTest(testname, subdir, script, interpreter, outfile,
args='', dependencies=(), env_vars={}, optional=False):
def addPythonTest(testname, subdir, script, interpreter,
args="", dependencies=(), env_vars={}, optional=False):
"""
Create targets for running and resetting a test script.
"""
def scriptRunner(target, source, env):
unittest_outfile = File("#test/work/python-results.txt").abspath
pytest_outfile = File("#test/work/pytest.xml").abspath
"""Scons Action to run a test script using the specified interpreter"""
workDir = Dir('#test/work').abspath
passedFile = target[0]
test_results.tests.pop(passedFile.name, None)
if not os.path.isdir(workDir):
os.mkdir(workDir)
if os.path.exists(unittest_outfile):
os.remove(unittest_outfile)
if os.path.exists(pytest_outfile):
os.remove(pytest_outfile)

Expand Down Expand Up @@ -163,16 +160,7 @@ def addPythonTest(testname, subdir, script, interpreter, outfile,
sys.exit(1)

failures = 0
if os.path.exists(unittest_outfile):
# Determine individual test status
for line in open(outfile):
status, name = line.strip().split(': ', 1)
if status == 'PASS':
test_results.passed[':'.join((testname,name))] = 1
elif status in ('FAIL', 'ERROR'):
test_results.failed[':'.join((testname,name))] = 1
failures += 1
elif os.path.exists(pytest_outfile):
if os.path.exists(pytest_outfile):
results = ElementTree.parse(pytest_outfile)
for test in results.findall('.//testcase'):
class_name = test.get('classname')
Expand Down Expand Up @@ -309,7 +297,6 @@ if localenv['python_package'] == 'full':
name, 'python', 'runCythonTests.py',
args=subset,
interpreter='$python_cmd',
outfile=File('#test/work/python-results.txt').abspath,
dependencies=(localenv['python_module'] + localenv['python_extension'] +
multi_glob(localenv, test_root, 'py')),
optional=bool(subset))
Expand Down

0 comments on commit 06a14a5

Please sign in to comment.