Added logging for testing different VASSAL+VASL combinations.

master
Pacman Ghost 6 months ago
parent bb075ef0da
commit fdaf2f0cde
  1. 35
      vasl_templates/webapp/tests/test_vassal.py

@ -1,6 +1,7 @@
""" Test VASSAL integration. """
import os
import traceback
import re
import json
import base64
@ -877,14 +878,32 @@ def run_vassal_tests( webapp, func, vasl_extns_type=None,
assert False, "Can't find a valid combination of VASSAL and VASL."
# run the test for each VASSAL+VASL
for vassal_version in vassal_versions:
for vasl_version in vasl_versions:
if not VassalShim.is_compatible_version( vassal_version, vasl_version ):
continue
webapp.control_tests \
.set_vassal_version( vassal_version ) \
.set_vasl_version( vasl_version, vasl_extns_type )
func()
log_fname = os.environ.get( "RUN_VASSAL_TESTS_LOG" ) # nb: define this to log activity
log_file = open( log_fname, "w", encoding="utf-8" ) if log_fname else None #pylint: disable=consider-using-with
def log( fmt, *args, **kwargs ):
if log_file:
print( fmt.format( *args, **kwargs ), file=log_file )
log_file.flush()
try:
for vassal_version in vassal_versions:
for vasl_version in vasl_versions:
if not VassalShim.is_compatible_version( vassal_version, vasl_version ):
continue
log( "Running tests for VASSAL {}, VASL {}...", vassal_version, vasl_version )
webapp.control_tests \
.set_vassal_version( vassal_version ) \
.set_vasl_version( vasl_version, vasl_extns_type )
try:
func()
log ( "- OK.\n" )
except Exception as exc: #pylint: disable=broad-except
log( "- Failed: {}\n{}", exc,
re.sub( "^", " ", traceback.format_exc(), flags=re.MULTILINE )
)
#raise
finally:
if log_file:
log_file.close()
# ---------------------------------------------------------------------

Loading…
Cancel
Save