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

msautotest: use Pytest #5984

Merged
merged 5 commits into from
Feb 5, 2020
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
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
10 changes: 10 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ require 'socket'
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

$set_environment_variables = <<SCRIPT
tee "/etc/profile.d/myvars.sh" > "/dev/null" <<EOF
export LD_LIBRARY_PATH=/vagrant/install-vagrant-proj-6/lib
EOF
SCRIPT

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
vm_ram = ENV['VAGRANT_VM_RAM'] || 2048
vm_cpu = ENV['VAGRANT_VM_CPU'] || 2
Expand Down Expand Up @@ -37,4 +43,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision "shell", path: "scripts/vagrant/proj6.sh"
config.vm.provision "shell", path: "scripts/vagrant/mapserver.sh"

config.vm.provision "shell", inline: $set_environment_variables, run: "always"

end


1 change: 1 addition & 0 deletions ci/travis/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ sudo apt-get install --allow-unauthenticated libmono-system-drawing4.0-cil mono-
sudo apt-get install --allow-unauthenticated php5-dev || sudo apt-get install --allow-unauthenticated php7-dev
sudo apt-get install --allow-unauthenticated libperl-dev
sudo pip install cpp-coveralls
sudo pip install -U -r msautotest/requirements.txt
# install swig 3.0.12 (defaults to 2.0.11 on trusty)
wget http://prdownloads.sourceforge.net/swig/swig-3.0.12.tar.gz
export CC="ccache gcc"
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
43 changes: 43 additions & 0 deletions msautotest/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +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 = [ '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.
28 changes: 7 additions & 21 deletions msautotest/gdal/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,22 @@
# 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.exit(mstestlib.pytest_main())
Empty file added msautotest/misc/__init__.py
Empty file.
16 changes: 7 additions & 9 deletions msautotest/misc/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,22 @@
# 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.exit(mstestlib.pytest_main())
28 changes: 7 additions & 21 deletions msautotest/mspython/run_all_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#
# Project: MapServer
# Purpose: Test executive for Python MapScript based autotests.
# Author: Frank Warmerdam, warmerdam@pobox.com
# Author: Even Rouault
#
###############################################################################
# Copyright (c) 2004, Frank Warmerdam <warmerdam@pobox.com>
# Copyright (c) 2020, Even Rouault,<even.rouault at spatialys.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
Expand All @@ -28,27 +28,13 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
###############################################################################
#
# $Log$
# Revision 1.1 2004/05/13 03:01:33 frank
# New
#
#

import sys

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

import pmstestlib
# This is mostly the same as the 'pytest' launcher

import sys

###############################################################################
# main()
from pytest import main

if __name__ == '__main__':
pmstestlib.setup_run( 'all' )
pmstestlib.run_all( '.', sys.argv[1:] )
errors = pmstestlib.summarize()
sys.exit(errors)


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