Skip to content

Commit

Permalink
Port msautotest to pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Jan 19, 2020
1 parent ce90aea commit 8c07a69
Show file tree
Hide file tree
Showing 17 changed files with 331 additions and 449 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AUTOTEST_OPTS?=-strict -q
AUTOTEST_OPTS?=--strict
PHP_MAPSCRIPT=build/mapscript/php/php_mapscript.so
PYTHON_MAPSCRIPT_PATH=build/mapscript/python
JAVA_MAPSCRIPT_PATH=build/mapscript/java
Expand All @@ -22,22 +22,22 @@ warning:
$(error "This Makefile is used to run the \"test\" target")

wxs-testcase:
cd msautotest/wxs && chmod 777 tmp && rm -f result/* && export PATH=$(BUILDPATH):$(PATH) && ./run_test.py $(AUTOTEST_OPTS)
cd msautotest/wxs && chmod 777 tmp && rm -f result/* && export PATH=$(BUILDPATH):$(PATH) && (./run_test.py $(AUTOTEST_OPTS) || /bin/true)

renderers-testcase:
cd msautotest/renderers && rm -f result/* && export PATH=$(BUILDPATH):$(PATH) && ./run_test.py $(AUTOTEST_OPTS)
cd msautotest/renderers && rm -f result/* && export PATH=$(BUILDPATH):$(PATH) && (./run_test.py $(AUTOTEST_OPTS) || /bin/true)

misc-testcase:
cd msautotest/misc && rm -f result/* && export PATH=$(BUILDPATH):$(PATH) && ./run_test.py $(AUTOTEST_OPTS)
cd msautotest/misc && rm -f result/* && export PATH=$(BUILDPATH):$(PATH) && (./run_test.py $(AUTOTEST_OPTS) || /bin/true)

gdal-testcase:
cd msautotest/gdal && rm -f result/* && export PATH=$(BUILDPATH):$(PATH) && ./run_test.py $(AUTOTEST_OPTS)
cd msautotest/gdal && rm -f result/* && export PATH=$(BUILDPATH):$(PATH) && (./run_test.py $(AUTOTEST_OPTS) || /bin/true)

query-testcase:
cd msautotest/query && rm -f result/* && export PATH=$(BUILDPATH):$(PATH) && ./run_test.py $(AUTOTEST_OPTS)
cd msautotest/query && rm -f result/* && export PATH=$(BUILDPATH):$(PATH) && (./run_test.py $(AUTOTEST_OPTS) || /bin/true)

sld-testcase:
cd msautotest/sld && rm -f result/* && export PATH=$(BUILDPATH):$(PATH) && ./run_test.py $(AUTOTEST_OPTS)
cd msautotest/sld && rm -f result/* && export PATH=$(BUILDPATH):$(PATH) && (./run_test.py $(AUTOTEST_OPTS) || /bin/true)

mspython-testcase:
test -f "$(PYTHON_MAPSCRIPT_PATH)/_mapscript.so" && (export PYTHONPATH="../../$(PYTHON_MAPSCRIPT_PATH)" && cd msautotest/mspython && python run_all_tests.py)
Expand Down
2 changes: 1 addition & 1 deletion ci/travis/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if [ "$BUILD_NAME" = "PHP_7.2_WITH_ASAN" ]; then
sudo rm /usr/local/include/proj.h
# -DNDEBUG to avoid issues with cairo cleanup
make cmakebuild MFLAGS="-j2" CMAKE_C_FLAGS="-g -fsanitize=address -DNDEBUG -DPROJ_RENAME_SYMBOLS -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H" CMAKE_CXX_FLAGS="-g -fsanitize=address -DNDEBUG -DPROJ_RENAME_SYMBOLS -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H" EXTRA_CMAKEFLAGS="-DCMAKE_BUILD_TYPE=None -DCMAKE_EXE_LINKER_FLAGS=-fsanitize=address -DPROJ_INCLUDE_DIR=/usr/local/include -DPROJ_LIBRARY=/usr/local/lib/libproj.so.15"
export AUTOTEST_OPTS="-q -strict -run_under_asan"
export AUTOTEST_OPTS="--strict --run_under_asan"
# Only run tests that only involve mapserv/shp2img binaries. mspython, etc would require LD_PREOLOAD'ing the asan shared object
make -j4 asan_compatible_tests
elif [ "$BUILD_NAME" = "PHP_7.3_WITH_PROJ6" ]; then
Expand Down
35 changes: 34 additions & 1 deletion msautotest/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,43 @@
# coding: utf-8
import os
import pytest
import sys

# Put the pymod dir on the path, so modules can `import pmstestlib`
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "pymod"))

# These files may be non-importable, and don't contain tests anyway.
# So we skip searching them during test collection.
collect_ignore = []
collect_ignore = [ 'pymod/msautotest_viewer.py' ]


def pytest_addoption(parser):
parser.addoption(
"--strict_mode",
action="store_true",
default=False,
help="Strict mode",
)

parser.addoption(
"--valgrind",
action="store_true",
default=False,
help="Run under valgrind",
)

parser.addoption(
"--run_under_asan",
action="store_true",
default=False,
help="Run under ASAN",
)

parser.addoption(
"--renderer",
default=None
)

@pytest.fixture
def extra_args(request):
return request.config
Empty file added msautotest/gdal/__init__.py
Empty file.
29 changes: 8 additions & 21 deletions msautotest/gdal/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,23 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
###############################################################################
#
# $Log$
# Revision 1.5 2003/03/05 15:28:50 frank
# use shared mstestlib.py
#
# Revision 1.4 2003/03/02 19:54:03 frank
# auto create result directory if missing
#
# Revision 1.3 2003/01/23 22:47:50 frank
# removed python2.2 use of st_size
#
# Revision 1.2 2002/12/21 21:47:20 frank
# preserved failed results
#
# Revision 1.1 2002/11/22 21:13:19 frank
# New
#

import os
import pytest
import sys

sys.path.append( '../pymod' )

import mstestlib

@pytest.mark.parametrize('map,out_file,command', mstestlib.get_pytests(os.path.dirname(os.path.abspath(__file__))))
def test(map, out_file, command, extra_args):
mstestlib.run_pytest(map, out_file, command, extra_args)


###############################################################################
# main()

if __name__ == '__main__':
mstestlib.run_tests( sys.argv[1:] )



sys.argv[0] = 'run_test.py'
sys.exit(pytest.main())
Empty file added msautotest/misc/__init__.py
Empty file.
17 changes: 8 additions & 9 deletions msautotest/misc/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,23 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
###############################################################################
#
# $Log$
# Revision 1.4 2003/03/05 15:30:09 frank
# use shared mstestlib
#

import os
import pytest
import sys

sys.path.append( '../pymod' )

import mstestlib

@pytest.mark.parametrize('map,out_file,command', mstestlib.get_pytests(os.path.dirname(os.path.abspath(__file__))))
def test(map, out_file, command, extra_args):
mstestlib.run_pytest(map, out_file, command, extra_args)


###############################################################################
# main()

if __name__ == '__main__':
mstestlib.run_tests( sys.argv[1:] )



sys.argv[0] = 'run_test.py'
sys.exit(pytest.main())
Loading

0 comments on commit 8c07a69

Please sign in to comment.