Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update default pytest output #1034

Merged
merged 5 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ jobs:
- name: Build Cantera
run: python3 `which scons` build env_vars=all -j2 debug=n --debug=time
- name: Test Cantera
run: python3 `which scons` test --debug=time
run:
python3 `which scons` test show_long_tests=yes verbose_tests=yes --debug=time
env:
GITHUB_ACTIONS: "true"

Expand Down Expand Up @@ -83,7 +84,8 @@ jobs:
- name: Build Cantera
run: python3 `which scons` build env_vars=all -j3 debug=n --debug=time
- name: Test Cantera
run: python3 `which scons` test --debug=time
run:
python3 `which scons` test show_long_tests=yes verbose_tests=yes --debug=time
env:
GITHUB_ACTIONS: "true"

Expand Down Expand Up @@ -117,7 +119,8 @@ jobs:
python3 `which scons` build blas_lapack_libs=lapack,blas coverage=y \
optimize=n skip_slow_tests=y no_optimize_flags=-DNDEBUG env_vars=all -j2 --debug=time
- name: Test Cantera
run: python3 `which scons` test --debug=time
run:
python3 `which scons` test show_long_tests=yes verbose_tests=yes --debug=time
env:
GITHUB_ACTIONS: "true"
- name: Upload Coverage to Codecov
Expand Down Expand Up @@ -246,7 +249,7 @@ jobs:
extra_lib_dirs=$CONDA_PREFIX/lib system_fmt=y system_eigen=y system_yamlcpp=y \
system_sundials=y blas_lapack_libs='lapack,blas' -j2 VERBOSE=True debug=n
- name: Test Cantera
run: scons test
run: scons test show_long_tests=yes verbose_tests=yes

cython-latest:
name: Test pre-release version of Cython
Expand All @@ -272,7 +275,7 @@ jobs:
- name: Build Cantera
run: python3 `which scons` build blas_lapack_libs=lapack,blas python_package='full' -j2 debug=n
- name: Test Cantera
run: python3 `which scons` test
run: python3 `which scons` test show_long_tests=yes verbose_tests=yes

windows:
name: ${{ matrix.os }}, MSVC ${{ matrix.vs-toolset }}, Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -338,6 +341,6 @@ jobs:
msvc_version=${{ matrix.vs-toolset }} f90_interface=n --debug=time
shell: cmd
- name: Test Cantera
run: scons test --debug=time
run: scons test show_long_tests=yes verbose_tests=yes --debug=time
env:
GITHUB_ACTIONS: "true"
15 changes: 11 additions & 4 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ config_options = [
To install to the current user's 'site-packages' directory, use
'python_prefix=USER'.""",
defaults.python_prefix, PathVariable.PathAccept),
EnumVariable(
EnumVariable(
'matlab_toolbox',
"""This variable controls whether the MATLAB toolbox will be built. If
set to 'y', you will also need to set the value of the 'matlab_path'
Expand Down Expand Up @@ -663,14 +663,21 @@ config_options = [
BoolVariable(
"fast_fail_tests",
"""If enabled, tests will exit at the first failure.""",
False,
),
False),
BoolVariable(
"skip_slow_tests",
"""If enabled, skip a subset of tests that are known to have long runtimes.
Skipping these may be desirable when running with options that cause tests
to run slowly, like disabling optimization or activating code profiling.""",
False)
False),
BoolVariable(
"show_long_tests",
"""If enabled, duration of slowest tests will be shown.""",
False),
BoolVariable(
"verbose_tests",
"""If enabled, verbose test output will be shown.""",
False),
]

opts.AddVariables(*config_options)
Expand Down
5 changes: 5 additions & 0 deletions test/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import subprocess
from xml.etree import ElementTree
from os.path import join as pjoin
import time
import sys
bryanwweber marked this conversation as resolved.
Show resolved Hide resolved

from buildutils import *

Expand Down Expand Up @@ -141,6 +142,10 @@ def addPythonTest(testname, subdir, script, interpreter, outfile,
cmdargs = args.split()
if env["fast_fail_tests"]:
cmdargs.insert(0, "fast_fail")
if env["show_long_tests"]:
cmdargs.insert(0, "show_long")
if env["verbose_tests"]:
cmdargs.insert(0, "verbose")
if env["skip_slow_tests"]:
environ["CT_SKIP_SLOW"] = "1"

Expand Down
25 changes: 19 additions & 6 deletions test/python/runCythonTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,19 @@ def addError(self, test, err):
print('* INFO: Git commit:', cantera.__git_commit__, '\n')
sys.stdout.flush()

if len(sys.argv) > 1 and sys.argv[1] == "fast_fail":
subset_start = 1
fast_fail = False
show_long = False
verbose = False
if "fast_fail" in sys.argv:
fast_fail = True
subset_start = 2
else:
fast_fail = False
subset_start = 1
subset_start += 1
if "show_long" in sys.argv:
show_long = True
subset_start += 1
if "verbose" in sys.argv:
verbose = True
subset_start += 1

if pytest is not None:
base = Path(cantera.__file__).parent.joinpath('test')
Expand All @@ -84,9 +91,15 @@ def addError(self, test, err):
if not subsets:
subsets.append(str(base))

pytest_args = ["-raP", "--durations=50", "--junitxml=pytest.xml"]
pytest_args = ["-raP", "--junitxml=pytest.xml"]
if show_long:
pytest_args += ["--durations=50"]
if fast_fail:
pytest_args.insert(0, "-x")
if verbose:
pytest_args.insert(0, "-v")
else:
pytest_args.append("--log-level=ERROR")

ret_code = pytest.main(pytest_args + subsets)
sys.exit(ret_code)
Expand Down