mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[Test] Add option to skip slow (Python) tests
Use to speed up CI coverage testing
This commit is contained in:
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -115,7 +115,7 @@ jobs:
|
||||
- name: Build Cantera
|
||||
run: |
|
||||
python3 `which scons` build blas_lapack_libs=lapack,blas coverage=y \
|
||||
optimize=n no_optimize_flags=-DNDEBUG env_vars=all -j2 --debug=time
|
||||
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
|
||||
env:
|
||||
|
||||
@@ -664,7 +664,13 @@ config_options = [
|
||||
"fast_fail_tests",
|
||||
"""If enabled, tests will exit at the first failure.""",
|
||||
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)
|
||||
]
|
||||
|
||||
opts.AddVariables(*config_options)
|
||||
|
||||
@@ -88,6 +88,7 @@ class converterTestCommon:
|
||||
self.assertNear(ref_kf[i], gas_kf[i], rtol=tol, msg='kf' + message)
|
||||
self.assertNear(ref_kr[i], gas_kr[i], rtol=tol, msg='kr' + message)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_gri30(self):
|
||||
output = self.convert('gri30.inp', thermo='gri30_thermo.dat',
|
||||
transport='gri30_tran.dat', output='gri30_test')
|
||||
@@ -283,6 +284,7 @@ class converterTestCommon:
|
||||
with self.assertRaisesRegex(self.InputError, 'Unparsable'):
|
||||
self.convert('invalid-equation.inp', thermo='dummy-thermo.dat')
|
||||
|
||||
@utilities.slow_test
|
||||
def test_reaction_units(self):
|
||||
out_def = self.convert('units-default.inp', thermo='dummy-thermo.dat')
|
||||
out_cus = self.convert('units-custom.inp', thermo='dummy-thermo.dat')
|
||||
@@ -470,6 +472,7 @@ class ck2yamlTest(converterTestCommon, utilities.CanteraTest):
|
||||
transport_file=transport, surface_file=surface, out_name=output,
|
||||
extra_file=extra, quiet=quiet, permissive=permissive)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_extra(self):
|
||||
self.convert('gri30.inp', thermo='gri30_thermo.dat',
|
||||
transport='gri30_tran.dat', output='gri30_extra',
|
||||
@@ -539,6 +542,7 @@ class CtmlConverterTest(utilities.CanteraTest):
|
||||
self.assertNear(anode_bulk['electron'].X, 1.0)
|
||||
self.assertNear(oxide_a.density_mole, 17.6)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_diamond(self):
|
||||
gas, solid = ct.import_phases('diamond.cti', ['gas','diamond'])
|
||||
face = ct.Interface('diamond.cti', 'diamond_100', [gas, solid])
|
||||
@@ -668,6 +672,7 @@ class cti2yamlTest(utilities.CanteraTest):
|
||||
message = 'dkm for species {0} at T = {1}'.format(i, T)
|
||||
self.assertNear(Dkm_cti[i], Dkm_yaml[i], msg=message)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_gri30(self):
|
||||
cti2yaml.convert(Path(self.cantera_data).joinpath('gri30.cti'),
|
||||
Path(self.test_work_dir).joinpath('gri30.yaml'))
|
||||
@@ -697,6 +702,7 @@ class cti2yamlTest(utilities.CanteraTest):
|
||||
self.checkThermo(ctiSurf, yamlSurf, [400, 800, 1600])
|
||||
self.checkKinetics(ctiSurf, yamlSurf, [500, 1200], [1e4, 3e5])
|
||||
|
||||
@utilities.slow_test
|
||||
def test_ptcombust_motzwise(self):
|
||||
cti2yaml.convert(Path(self.test_data_dir).joinpath('ptcombust-motzwise.cti'),
|
||||
Path(self.test_work_dir).joinpath('ptcombust-motzwise.yaml'))
|
||||
@@ -732,6 +738,7 @@ class cti2yamlTest(utilities.CanteraTest):
|
||||
ctiMetal.electric_potential = yamlMetal.electric_potential = 4
|
||||
self.checkKinetics(cti_tpb, yaml_tpb, [900, 1000, 1100], [1e5])
|
||||
|
||||
@utilities.slow_test
|
||||
def test_liquidvapor(self):
|
||||
output_file = Path(self.test_work_dir).joinpath('liquidvapor.yaml')
|
||||
cti2yaml.convert(Path(self.cantera_data).joinpath('liquidvapor.cti'),
|
||||
@@ -753,6 +760,7 @@ class cti2yamlTest(utilities.CanteraTest):
|
||||
yamlGas.TP = ctiGas.TP = 300, P
|
||||
self.checkThermo(ctiGas, yamlGas, [300, 400, 500])
|
||||
|
||||
@utilities.slow_test
|
||||
def test_Redlich_Kwong_ndodecane(self):
|
||||
cti2yaml.convert(Path(self.cantera_data).joinpath('nDodecane_Reitz.cti'),
|
||||
Path(self.test_work_dir).joinpath('nDodecane_Reitz.yaml'))
|
||||
@@ -889,6 +897,7 @@ class ctml2yamlTest(utilities.CanteraTest):
|
||||
message = 'dkm for species {0} at T = {1}'.format(i, T)
|
||||
self.assertNear(Dkm_ctml[i], Dkm_yaml[i], msg=message)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_gri30(self):
|
||||
ctml2yaml.convert(
|
||||
Path(self.cantera_data).joinpath('gri30.xml'),
|
||||
@@ -986,6 +995,7 @@ class ctml2yamlTest(utilities.CanteraTest):
|
||||
yamlGas.TP = ctmlGas.TP = 300, P
|
||||
self.checkThermo(ctmlGas, yamlGas, [300, 400, 500])
|
||||
|
||||
@utilities.slow_test
|
||||
def test_Redlich_Kwong_ndodecane(self):
|
||||
ctml2yaml.convert(
|
||||
Path(self.cantera_data).joinpath('nDodecane_Reitz.xml'),
|
||||
|
||||
@@ -155,6 +155,7 @@ class TestKOH_Equil(utilities.CanteraTest):
|
||||
|
||||
self.compare(data, pjoin(self.test_data_dir, 'koh-equil-TP.csv'))
|
||||
|
||||
@utilities.slow_test
|
||||
def test_equil_HP(self):
|
||||
temperatures = range(350, 5000, 300)
|
||||
data = np.zeros((len(temperatures), self.mix.n_species+2))
|
||||
@@ -208,9 +209,11 @@ class TestEquil_GasCarbon(utilities.CanteraTest):
|
||||
|
||||
self.compare(data, pjoin(self.test_data_dir, 'gas-carbon-equil.csv'))
|
||||
|
||||
@utilities.slow_test
|
||||
def test_gibbs(self):
|
||||
self.solve('gibbs')
|
||||
|
||||
@utilities.slow_test
|
||||
def test_vcs(self):
|
||||
self.solve('vcs')
|
||||
|
||||
|
||||
@@ -181,6 +181,7 @@ class TestFreeFlame(utilities.CanteraTest):
|
||||
self.assertNear(self.sim.fixed_temperature, tfixed)
|
||||
self.assertNear(self.sim.fixed_temperature_location, zfixed)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_auto_width(self):
|
||||
Tin = 300
|
||||
p = ct.one_atm
|
||||
@@ -211,6 +212,7 @@ class TestFreeFlame(utilities.CanteraTest):
|
||||
self.assertLess(self.sim.grid[-1], 2.0) # grid should not be too wide
|
||||
|
||||
|
||||
@utilities.slow_test
|
||||
def test_converge_adiabatic(self):
|
||||
# Test that the adiabatic flame temperature and species profiles
|
||||
# converge to the correct equilibrium values as the grid is refined
|
||||
@@ -354,24 +356,31 @@ class TestFreeFlame(utilities.CanteraTest):
|
||||
def test_mixture_averaged_case1(self):
|
||||
self.run_mix(phi=0.65, T=300, width=0.03, p=1.0, refine=True)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_mixture_averaged_case2(self):
|
||||
self.run_mix(phi=0.5, T=300, width=2.0, p=1.0, refine=False)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_mixture_averaged_case3(self):
|
||||
self.run_mix(phi=0.5, T=500, width=0.05, p=1.0, refine=False)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_mixture_averaged_case4(self):
|
||||
self.run_mix(phi=0.7, T=400, width=2.0, p=5.0, refine=False)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_mixture_averaged_case5(self):
|
||||
self.run_mix(phi=1.0, T=300, width=2.0, p=5.0, refine=False)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_mixture_averaged_case6(self):
|
||||
self.run_mix(phi=1.5, T=300, width=0.2, p=1.0, refine=True)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_mixture_averaged_case7(self):
|
||||
self.run_mix(phi=1.5, T=500, width=2.0, p=0.1, refine=False)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_mixture_averaged_case8(self):
|
||||
self.run_mix(phi=2.0, T=400, width=2.0, p=5.0, refine=False)
|
||||
|
||||
@@ -454,6 +463,7 @@ class TestFreeFlame(utilities.CanteraTest):
|
||||
self.sim.soret_enabled = True
|
||||
self.sim.solve(loglevel=0, auto=False)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_soret_with_auto(self):
|
||||
# Test that auto solving with Soret enabled works
|
||||
self.create_sim(101325, 300, 'H2:2.0, O2:1.0')
|
||||
@@ -561,6 +571,7 @@ class TestFreeFlame(utilities.CanteraTest):
|
||||
else:
|
||||
getattr(self.sim, attr)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_save_restore_add_species(self):
|
||||
reactants = 'H2:1.1, O2:1, AR:5'
|
||||
p = 2 * ct.one_atm
|
||||
@@ -589,6 +600,7 @@ class TestFreeFlame(utilities.CanteraTest):
|
||||
k2 = gas2.species_index(species)
|
||||
self.assertArrayNear(Y1[k1], Y2[k2])
|
||||
|
||||
@utilities.slow_test
|
||||
def test_save_restore_remove_species(self):
|
||||
reactants = 'H2:1.1, O2:1, AR:5'
|
||||
p = 2 * ct.one_atm
|
||||
@@ -757,6 +769,7 @@ class TestDiffusionFlame(utilities.CanteraTest):
|
||||
self.assertTrue(self.sim.energy_enabled)
|
||||
self.assertEqual(self.sim.transport_model, 'Mix')
|
||||
|
||||
@utilities.slow_test
|
||||
def test_mixture_averaged(self, saveReference=False):
|
||||
referenceFile = pjoin(self.test_data_dir, 'DiffusionFlameTest-h2-mix.csv')
|
||||
self.create_sim(p=ct.one_atm)
|
||||
@@ -830,24 +843,31 @@ class TestDiffusionFlame(utilities.CanteraTest):
|
||||
def test_extinction_case1(self):
|
||||
self.run_extinction(mdot_fuel=0.5, mdot_ox=3.0, T_ox=300, width=0.018, P=1.0)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_extinction_case2(self):
|
||||
self.run_extinction(mdot_fuel=0.5, mdot_ox=1.0, T_ox=300, width=0.01, P=5.0)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_extinction_case3(self):
|
||||
self.run_extinction(mdot_fuel=1.0, mdot_ox=0.5, T_ox=500, width=0.02, P=5.0)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_extinction_case4(self):
|
||||
self.run_extinction(mdot_fuel=1.0, mdot_ox=3.0, T_ox=400, width=0.05, P=2.0)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_extinction_case5(self):
|
||||
self.run_extinction(mdot_fuel=1.0, mdot_ox=3.0, T_ox=300, width=0.1, P=1.0)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_extinction_case6(self):
|
||||
self.run_extinction(mdot_fuel=0.5, mdot_ox=0.5, T_ox=600, width=0.2, P=0.05)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_extinction_case7(self):
|
||||
self.run_extinction(mdot_fuel=0.2, mdot_ox=2.0, T_ox=600, width=0.2, P=0.05)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_restart(self):
|
||||
self.run_extinction(mdot_fuel=0.5, mdot_ox=3.0, T_ox=300, width=0.018, P=1.0)
|
||||
|
||||
@@ -1013,21 +1033,27 @@ class TestCounterflowPremixedFlame(utilities.CanteraTest):
|
||||
self.assertTrue(all(sim.spread_rate >= -1e-9))
|
||||
return sim
|
||||
|
||||
@utilities.slow_test
|
||||
def test_solve_case1(self):
|
||||
self.run_case(phi=0.4, T=400, width=0.05, P=10.0)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_solve_case2(self):
|
||||
self.run_case(phi=0.5, T=500, width=0.03, P=2.0)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_solve_case3(self):
|
||||
self.run_case(phi=0.7, T=300, width=0.05, P=2.0)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_solve_case4(self):
|
||||
self.run_case(phi=1.5, T=400, width=0.03, P=0.02)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_solve_case5(self):
|
||||
self.run_case(phi=2.0, T=300, width=0.2, P=0.2)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_restart(self):
|
||||
sim = self.run_case(phi=2.0, T=300, width=0.2, P=0.2)
|
||||
|
||||
@@ -1055,15 +1081,19 @@ class TestBurnerFlame(utilities.CanteraTest):
|
||||
def test_case1(self):
|
||||
self.solve(phi=0.5, T=500, width=2.0, P=0.1)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_case2(self):
|
||||
self.solve(phi=2.0, T=400, width=0.05, P=1.0)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_case3(self):
|
||||
self.solve(phi=1.7, T=300, width=0.05, P=1.0)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_case4(self):
|
||||
self.solve(phi=0.5, T=300, width=1.0, P=5.0)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_case5(self):
|
||||
self.solve(phi=1.0, T=400, width=0.2, P=0.01)
|
||||
|
||||
@@ -1150,9 +1180,11 @@ class TestImpingingJet(utilities.CanteraTest):
|
||||
def test_reacting_surface_case1(self):
|
||||
self.run_reacting_surface(xch4=0.095, tsurf=900.0, mdot=0.06, width=0.1)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_reacting_surface_case2(self):
|
||||
self.run_reacting_surface(xch4=0.07, tsurf=1200.0, mdot=0.2, width=0.05)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_reacting_surface_case3(self):
|
||||
self.run_reacting_surface(xch4=0.2, tsurf=800.0, mdot=0.1, width=0.2)
|
||||
|
||||
@@ -1213,6 +1245,7 @@ class TestTwinFlame(utilities.CanteraTest):
|
||||
|
||||
|
||||
class TestIonFreeFlame(utilities.CanteraTest):
|
||||
@utilities.slow_test
|
||||
def test_ion_profile(self):
|
||||
reactants = 'CH4:0.216, O2:2'
|
||||
p = ct.one_atm
|
||||
|
||||
@@ -1288,9 +1288,11 @@ class TestReactorSensitivities(utilities.CanteraTest):
|
||||
def test_parameter_order1a(self):
|
||||
self._test_parameter_order1(ct.IdealGasReactor)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_parameter_order1b(self):
|
||||
self._test_parameter_order1(ct.IdealGasConstPressureReactor)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_parameter_order2(self):
|
||||
# Multiple reactors, changing the order in which parameters are added
|
||||
gas = ct.Solution('h2o2.yaml', transport_model=None)
|
||||
@@ -1352,6 +1354,7 @@ class TestReactorSensitivities(utilities.CanteraTest):
|
||||
self.assertArrayNear(S[1][:N], S[3][N:], 1e-5, 1e-5)
|
||||
self.assertArrayNear(S[1][N:], S[3][:N], 1e-5, 1e-5)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_parameter_order3(self):
|
||||
# Test including reacting surfaces
|
||||
gas1 = ct.Solution('diamond.xml', 'gas')
|
||||
|
||||
@@ -280,6 +280,7 @@ class TestThermoPhase(utilities.CanteraTest):
|
||||
self.phase.Y = np.array([])
|
||||
self.assertArrayNear(self.phase.X, X0)
|
||||
|
||||
@utilities.slow_test
|
||||
def test_set_equivalence_ratio_stoichiometric(self):
|
||||
gas = ct.Solution('gri30.xml')
|
||||
for fuel in ('C2H6', 'H2:0.7, CO:0.3', 'NH3:0.4, CH3OH:0.6'):
|
||||
|
||||
@@ -8,6 +8,7 @@ import unittest
|
||||
import errno
|
||||
import cantera
|
||||
|
||||
slow_test = unittest.skipIf(os.environ.get("CT_SKIP_SLOW", "0") == "1", "slow test")
|
||||
|
||||
class CanteraTest(unittest.TestCase):
|
||||
@classmethod
|
||||
|
||||
@@ -139,6 +139,8 @@ def addPythonTest(testname, subdir, script, interpreter, outfile,
|
||||
cmdargs = args.split()
|
||||
if env["fast_fail_tests"]:
|
||||
cmdargs.insert(0, "fast_fail")
|
||||
if env["skip_slow_tests"]:
|
||||
environ["CT_SKIP_SLOW"] = "1"
|
||||
|
||||
code = subprocess.call(
|
||||
[env.subst(interpreter), source[0].abspath] + cmdargs,
|
||||
|
||||
Reference in New Issue
Block a user