port tools/run_all_tests.cmd to Python
Now uses the same list of Python environments as used by 'tools/setup_base_environments.py' stored inside the project's main configuration file 'setup.cfg'. Updated todo list.
This commit is contained in:
parent
9bbc373837
commit
62977f5969
13
HACKING.rst
13
HACKING.rst
|
@ -356,17 +356,18 @@ Examples of such issues:
|
|||
* Some specific older Python versions (e.g. 2.4.3) have no SSL support and so
|
||||
have to reuse installations downloaded by other Python versions.
|
||||
|
||||
Running the project tests - ``tools/run_all_tests.cmd`` script
|
||||
--------------------------------------------------------------
|
||||
Running the project tests - ``tools/run_all_tests.py`` script
|
||||
-------------------------------------------------------------
|
||||
|
||||
``tools/run_all_tests.cmd`` script is a basic *poor man's tox* development
|
||||
script that can be used for running the full project test suite using multiple
|
||||
Python interpreter versions on a Windows development machine.
|
||||
``tools/run_all_tests.py`` script is a basic *poor man's tox* development script
|
||||
that can be used for running the full project test suite using multiple Python
|
||||
interpreter versions on a development machine.
|
||||
|
||||
Intended to be replaced by a more portable ``tox`` based or similar automated
|
||||
testing solution some time in the future.
|
||||
|
||||
Can be configured by tweaking the script's sources directly:
|
||||
Can be configured by tweaking the main project Python configuration file
|
||||
``setup.cfg``:
|
||||
|
||||
* List of target Python environments.
|
||||
* Each target Python environment's invocation command.
|
||||
|
|
26
TODO.txt
26
TODO.txt
|
@ -1340,17 +1340,23 @@ PRIORITIZED:
|
|||
(+) tools/setup_base_environments.py, e.g. with regards to setting up the
|
||||
(+) project's testing requirement packages (argparse, colorama, py, pytest).
|
||||
|
||||
(27.05.2014.)
|
||||
(29.05.2014.)
|
||||
|
||||
* (Jurko) Internal project development cleanup.
|
||||
* Re-implement the existing run_all_tests.cmd Windows batch script for
|
||||
running a full suds test suite on multiple Python versions in Python.
|
||||
* Read the list of target Python environments from the project's
|
||||
setup.cfg configuration file.
|
||||
* Make sure the prepared Python script runs using any of the suds
|
||||
project supported Python versions.
|
||||
* Add support for disabling testing a specific Python platform.
|
||||
* Update HACKING.rst documentation.
|
||||
(+) * (Jurko) Internal project development cleanup.
|
||||
(+) * Re-implement the existing run_all_tests.cmd Windows batch script for
|
||||
(+) running a full suds test suite on multiple Python versions in Python.
|
||||
(+) * Read the list of target Python environments from the project's
|
||||
(+) setup.cfg configuration file.
|
||||
(+) * Make sure the prepared Python script runs using any of the suds
|
||||
(+) project supported Python versions.
|
||||
(+) * Add support for disabling testing a specific Python platform.
|
||||
(+) * YAGNI for now. Can be done by commenting out appropriate
|
||||
(+) environment definition sections in the main project 'setup.py'
|
||||
(+) configuration file and will be affected later on by porting
|
||||
(+) our testing system over to use the tox project.
|
||||
(+) * Update HACKING.rst documentation.
|
||||
|
||||
(30.05.2014.)
|
||||
|
||||
* (Jurko) Look at the Spyne project and its suds usage.
|
||||
* Try running Spyne's test suite using the suds-jurko fork.
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::
|
||||
:: "poor man's tox" development script used on Windows to run the full
|
||||
:: suds-jurko test suite using multiple Python interpreter versions.
|
||||
::
|
||||
:: Intended to be used as a general 'all tests passed' check. To see more
|
||||
:: detailed information on specific failures, run the failed test group
|
||||
:: manually, configured for greater verbosity than is done here.
|
||||
::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
@setlocal
|
||||
|
||||
:: Process script environment.
|
||||
@for %%i in ("%~f0\..\..") do @set PROJECT_FOLDER=%%~fi
|
||||
@cd /d "%PROJECT_FOLDER%"
|
||||
|
||||
:: Used pytest command-line options.
|
||||
@set PYTEST_OPTIONS=-m pytest -q -x --tb=short
|
||||
|
||||
@call :test "3.4.1 x64" "py341" || goto :fail
|
||||
@call :test "2.4.3 x86" "py243" || goto :fail
|
||||
@call :test "2.7.6 x64" "py276" || goto :fail
|
||||
@call :test "3.4.1 x86" "py341_x86" || goto :fail
|
||||
@call :test "2.4.4 x86" "py244" || goto :fail
|
||||
@call :test "3.3.3 x86" "py333_x86" || goto :fail
|
||||
@call :test "3.2.5 x64" "py325" || goto :fail
|
||||
@call :test "3.3.3 x64" "py333" || goto :fail
|
||||
@call :test "3.3.5 x64" "py335" || goto :fail
|
||||
@call :test "2.5.4 x86" "py254_x86" || goto :fail
|
||||
@call :test "2.5.4 x64" "py254" || goto :fail
|
||||
@call :test "2.6.6 x86" "py266_x86" || goto :fail
|
||||
@call :test "2.6.6 x64" "py266" || goto :fail
|
||||
@call :test "2.7.6 x86" "py276_x86" || goto :fail
|
||||
@call :test "3.1.3 x64" "py313" || goto :fail
|
||||
@call :test "3.2.5 x86" "py325_x86" || goto :fail
|
||||
@call :test "3.3.5 x86" "py335_x86" || goto :fail
|
||||
@call :test "3.4.0 x64" "py340" || goto :fail
|
||||
@call :test "3.4.0 x86" "py340_x86" || goto :fail
|
||||
|
||||
@echo All tests passed.
|
||||
@exit /b 0
|
||||
|
||||
|
||||
:fail
|
||||
@echo.
|
||||
@echo Test failed.
|
||||
@exit /b -2
|
||||
|
||||
|
||||
:test
|
||||
@setlocal
|
||||
@set TITLE=%~1
|
||||
@set PYTHON="%~2"
|
||||
@if "%TITLE:~0,1%" == "2" goto :test__skip_build
|
||||
@echo ---------------------------------------------------------------
|
||||
@echo --- Building suds for Python %TITLE%
|
||||
@echo ---------------------------------------------------------------
|
||||
@if exist "build\" (rd /s /q build || exit /b -2)
|
||||
:test__skip_build
|
||||
:: Install the project into the target Python environment in editable mode.
|
||||
:: This will actually build Python 3 sources in case we are using a Python 3
|
||||
:: environment.
|
||||
@call %PYTHON% setup.py -q develop || exit /b -2
|
||||
@cd tests
|
||||
@echo.
|
||||
@echo ---------------------------------------------------------------
|
||||
@echo --- Testing suds with Python %TITLE%
|
||||
@echo ---------------------------------------------------------------
|
||||
@call %PYTHON% %PYTEST_OPTIONS% %LOCATION% || exit /b -2
|
||||
@echo.
|
||||
@echo ---------------------------------------------------------------
|
||||
@echo --- Testing suds with Python %TITLE% - no assertions
|
||||
@echo ---------------------------------------------------------------
|
||||
@call %PYTHON% -O %PYTEST_OPTIONS% %LOCATION% || exit /b -2
|
||||
@echo.
|
||||
@exit /b 0
|
|
@ -0,0 +1,136 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the (LGPL) GNU Lesser General Public License as published by the
|
||||
# Free Software Foundation; either version 3 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU Library Lesser General Public License
|
||||
# for more details at ( http://www.gnu.org/licenses/lgpl.html ).
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# written by: Jurko Gospodnetiæ ( jurko.gospodnetic@pke.hr )
|
||||
|
||||
"""
|
||||
"poor man's tox" development script used on Windows to run the full suds-jurko
|
||||
test suite using multiple Python interpreter versions.
|
||||
|
||||
Intended to be used as a general 'all tests passed' check. To see more detailed
|
||||
information on specific failures, run the failed test group manually,
|
||||
configured for greater verbosity than done here.
|
||||
|
||||
"""
|
||||
|
||||
import os.path
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
from suds_devel.configuration import BadConfiguration, Config, configparser
|
||||
from suds_devel.environment import BadEnvironment
|
||||
import suds_devel.utility as utility
|
||||
|
||||
|
||||
class MyConfig(Config):
|
||||
|
||||
def __init__(self, script, project_folder, ini_file):
|
||||
"""
|
||||
Initialize new script configuration.
|
||||
|
||||
External configuration parameters may be specified relative to the
|
||||
following folders:
|
||||
* script - relative to the current working folder
|
||||
* project_folder - relative to the script folder
|
||||
* ini_file - relative to the project folder
|
||||
|
||||
"""
|
||||
super(MyConfig, self).__init__(script, project_folder, ini_file)
|
||||
try:
|
||||
self._read_environment_configuration()
|
||||
except configparser.Error:
|
||||
raise BadConfiguration(sys.exc_info()[1].message)
|
||||
|
||||
|
||||
def _prepare_configuration():
|
||||
# We know we are a regular stand-alone script file and not an imported
|
||||
# module (either frozen, imported from disk, zip-file, external database or
|
||||
# any other source). That means we can safely assume we have the __file__
|
||||
# attribute available.
|
||||
global config
|
||||
config = MyConfig(__file__, "..", "setup.cfg")
|
||||
|
||||
|
||||
def _print_title(env, message_fmt):
|
||||
separator = "-" * 63
|
||||
print("")
|
||||
print(separator)
|
||||
print("--- " + message_fmt % (env.name(),))
|
||||
print(separator)
|
||||
|
||||
|
||||
def _report_startup_information():
|
||||
print("Running in folder: '%s'" % (os.getcwd(),))
|
||||
|
||||
|
||||
def _run_tests(env):
|
||||
if env.sys_version_info >= (3,):
|
||||
_print_title(env, "Building suds for Python %s")
|
||||
build_folder = os.path.join(config.project_folder, "build")
|
||||
if os.path.isdir(build_folder):
|
||||
shutil.rmtree(build_folder)
|
||||
|
||||
# Install the project into the target Python environment in editable mode.
|
||||
# This will actually build Python 3 sources in case we are using a Python 3
|
||||
# environment.
|
||||
setup_cmd = ["setup.py", "-q", "develop"]
|
||||
_, _, return_code = env.execute(setup_cmd, cwd=config.project_folder)
|
||||
if return_code != 0:
|
||||
return False
|
||||
|
||||
test_folder = os.path.join(config.project_folder, "tests")
|
||||
pytest_cmd = ["-m", "pytest", "-q", "-x", "--tb=short"]
|
||||
|
||||
_print_title(env, "Testing suds with Python %s")
|
||||
_, _, return_code = env.execute(pytest_cmd, cwd=test_folder)
|
||||
if return_code != 0:
|
||||
return False
|
||||
|
||||
_print_title(env, "Testing suds with Python %s - no assertions")
|
||||
pytest_cmd.insert(0, "-O")
|
||||
_, _, return_code = env.execute(pytest_cmd, cwd=test_folder)
|
||||
return return_code == 0
|
||||
|
||||
|
||||
def _run_tests_in_all_environments():
|
||||
if not config.python_environments:
|
||||
raise BadConfiguration("No Python environments configured.")
|
||||
for env in config.python_environments:
|
||||
if not env.initial_scan_completed:
|
||||
_print_title(env, "Scanning environment Python %s")
|
||||
env.run_initial_scan()
|
||||
if not _run_tests(env):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
_report_startup_information()
|
||||
_prepare_configuration()
|
||||
success = _run_tests_in_all_environments()
|
||||
except (BadConfiguration, BadEnvironment):
|
||||
utility.report_error(sys.exc_info()[1])
|
||||
return -2
|
||||
print("")
|
||||
if not success:
|
||||
print("Test failed.")
|
||||
return -3
|
||||
print("All tests passed.")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
Loading…
Reference in New Issue