Merge branch 'dont_run_slow_tests' into 'master'

Dont run slow tests

See merge request jschoeberl/netgen!226
This commit is contained in:
Matthias Hochsteger 2019-08-29 16:58:33 +00:00
commit 48086d343c
3 changed files with 49 additions and 6 deletions

View File

@ -103,7 +103,14 @@ build_ubuntu_debug:
script: script:
- docker build -t netgen_${CI_PIPELINE_ID}:${UBUNTU_VERSION} -f tests/dockerfile . - docker build -t netgen_${CI_PIPELINE_ID}:${UBUNTU_VERSION} -f tests/dockerfile .
- rm -f netgen_${CI_PIPELINE_ID}_$UBUNTU_VERSION.id - rm -f netgen_${CI_PIPELINE_ID}_$UBUNTU_VERSION.id
- docker run --cidfile netgen_${CI_PIPELINE_ID}_${UBUNTU_VERSION}.id -e CCACHE_DIR=/ccache -v /mnt/ccache:/ccache netgen_${CI_PIPELINE_ID}:${UBUNTU_VERSION} bash /root/src/netgen/tests/build_debug.sh - >-
docker run
--cidfile netgen_${CI_PIPELINE_ID}_${UBUNTU_VERSION}.id
-e CCACHE_DIR=/ccache
-e RUN_SLOW_TESTS=${RUN_SLOW_TESTS}
-v /mnt/ccache:/ccache
netgen_${CI_PIPELINE_ID}:${UBUNTU_VERSION}
bash /root/src/netgen/tests/build_debug.sh
- docker commit `cat netgen_${CI_PIPELINE_ID}_${UBUNTU_VERSION}.id` netgen_${CI_PIPELINE_ID}_installed:${UBUNTU_VERSION} - docker commit `cat netgen_${CI_PIPELINE_ID}_${UBUNTU_VERSION}.id` netgen_${CI_PIPELINE_ID}_installed:${UBUNTU_VERSION}
- rm netgen_${CI_PIPELINE_ID}_${UBUNTU_VERSION}.id - rm netgen_${CI_PIPELINE_ID}_${UBUNTU_VERSION}.id
@ -113,7 +120,14 @@ build_ubuntu_mpi:
script: script:
- docker build -t netgen_mpi_${CI_PIPELINE_ID}:${UBUNTU_VERSION} -f tests/dockerfile_mpi . - docker build -t netgen_mpi_${CI_PIPELINE_ID}:${UBUNTU_VERSION} -f tests/dockerfile_mpi .
- rm -f netgen_mpi_${CI_PIPELINE_ID}_$UBUNTU_VERSION.id_mpi - rm -f netgen_mpi_${CI_PIPELINE_ID}_$UBUNTU_VERSION.id_mpi
- docker run --cidfile netgen_mpi_${CI_PIPELINE_ID}_${UBUNTU_VERSION}.id -e CCACHE_DIR=/ccache -v /mnt/ccache:/ccache netgen_mpi_${CI_PIPELINE_ID}:${UBUNTU_VERSION} bash /root/src/netgen/tests/build_mpi.sh - >-
docker run>-
--cidfile netgen_mpi_${CI_PIPELINE_ID}_${UBUNTU_VERSION}.id>-
-e CCACHE_DIR=/ccache
-e RUN_SLOW_TESTS=${RUN_SLOW_TESTS}
-v /mnt/ccache:/ccache
netgen_mpi_${CI_PIPELINE_ID}:${UBUNTU_VERSION}
bash /root/src/netgen/tests/build_mpi.sh
- docker commit `cat netgen_mpi_${CI_PIPELINE_ID}_${UBUNTU_VERSION}.id` netgen_mpi_${CI_PIPELINE_ID}_installed:${UBUNTU_VERSION} - docker commit `cat netgen_mpi_${CI_PIPELINE_ID}_${UBUNTU_VERSION}.id` netgen_mpi_${CI_PIPELINE_ID}_installed:${UBUNTU_VERSION}
- rm netgen_mpi_${CI_PIPELINE_ID}_${UBUNTU_VERSION}.id - rm netgen_mpi_${CI_PIPELINE_ID}_${UBUNTU_VERSION}.id
@ -123,6 +137,7 @@ test_ubuntu_debug:
script: script:
- >- - >-
docker run docker run
-e RUN_SLOW_TESTS=${RUN_SLOW_TESTS}
-e NETGENDIR=/opt/netgen/bin -e NETGENDIR=/opt/netgen/bin
-e PYTHONPATH=/opt/netgen/lib/python3/dist-packages -e PYTHONPATH=/opt/netgen/lib/python3/dist-packages
netgen_${CI_PIPELINE_ID}_installed:${UBUNTU_VERSION} netgen_${CI_PIPELINE_ID}_installed:${UBUNTU_VERSION}
@ -135,6 +150,7 @@ test_ubuntu_mpi:
script: script:
- >- - >-
docker run docker run
-e RUN_SLOW_TESTS=${RUN_SLOW_TESTS}
-e NETGENDIR=/opt/netgen/bin -e NETGENDIR=/opt/netgen/bin
-e PYTHONPATH=/opt/netgen/lib/python3/dist-packages -e PYTHONPATH=/opt/netgen/lib/python3/dist-packages
netgen_mpi_${CI_PIPELINE_ID}_installed:${UBUNTU_VERSION} netgen_mpi_${CI_PIPELINE_ID}_installed:${UBUNTU_VERSION}

20
tests/pytest/conftest.py Normal file
View File

@ -0,0 +1,20 @@
"""
Pytest configuration file to run slow test only if pytest is started with option --runslow or if
environment variable RUN_SLOW_TESTS is set.
"""
import pytest, os
def pytest_addoption(parser):
parser.addoption("--runslow", action="store_true", default=False, help="run slow tests")
def pytest_configure(config):
config.addinivalue_line("markers", "slow: mark test as slow to run")
def pytest_collection_modifyitems(config, items):
if not (('RUN_SLOW_TESTS' in os.environ and os.environ['RUN_SLOW_TESTS']) or config.getoption("--runslow")):
skip_slow = pytest.mark.skip(reason="need --runslow option to run")
for item in items:
if "slow" in item.keywords:
item.add_marker(skip_slow)

View File

@ -1,7 +1,6 @@
import os, pytest import os, pytest
from netgen.meshing import meshsize, MeshingParameters, SetMessageImportance from netgen.meshing import meshsize, MeshingParameters, SetMessageImportance
import netgen.gui
import netgen.csg as csg import netgen.csg as csg
import netgen.stl as stl import netgen.stl as stl
try: try:
@ -46,12 +45,10 @@ def getMeshingparameters(filename):
return standard[3:] # coarser meshes don't work here return standard[3:] # coarser meshes don't work here
return standard return standard
# TODO: step files do not respect gui meshsizes yet.
_geofiles = [f for f in getFiles(".geo")] + [f for f in getFiles(".stl")] _geofiles = [f for f in getFiles(".geo")] + [f for f in getFiles(".stl")]
if has_occ: if has_occ:
_geofiles += [f for f in getFiles(".step")] _geofiles += [f for f in getFiles(".step")]
def generateMesh(filename, mp): def generateMesh(filename, mp):
if filename.endswith(".geo"): if filename.endswith(".geo"):
geo = csg.CSGeometry(os.path.join("..","..","tutorials", filename)) geo = csg.CSGeometry(os.path.join("..","..","tutorials", filename))
@ -61,7 +58,17 @@ def generateMesh(filename, mp):
geo = occ.OCCGeometry(os.path.join("..","..","tutorials", filename)) geo = occ.OCCGeometry(os.path.join("..","..","tutorials", filename))
return geo.GenerateMesh(**mp) return geo.GenerateMesh(**mp)
@pytest.mark.parametrize("filename, checkFunc", [(f, getCheckFunc(f)) for f in _geofiles]) def isSlowTest(filename):
return filename in ["cubemcyl.geo", "frame.step", "revolution.geo", "manyholes.geo", "torus.geo",
"cubemsphere.geo", "manyholes2.geo", "matrix.geo", "trafo.geo", "ellipticcone.geo",
"period.geo", "shaft.geo", "cubeandring.geo", "ellipticcyl.geo",
"ellipsoid.geo", "cone.geo"]
def getParamForTest(filename):
return pytest.param(filename, getCheckFunc(filename), marks=pytest.mark.slow) if isSlowTest(filename) \
else (filename, getCheckFunc(filename))
@pytest.mark.parametrize(("filename, checkFunc"), [getParamForTest(f) for f in _geofiles])
def test_geoFiles(filename, checkFunc): def test_geoFiles(filename, checkFunc):
for i, mp in enumerate(getMeshingparameters(filename)): for i, mp in enumerate(getMeshingparameters(filename)):
print("load geo", filename) print("load geo", filename)