From ba8a2d425b6a4d0c1501785b86f78aaa7f4d6fc6 Mon Sep 17 00:00:00 2001 From: Taka Date: Mon, 14 Mar 2022 21:18:50 +1100 Subject: [PATCH] Tightened up how the test suite skips certain versions of VASL. Also added 6.6.3.1 to the list of supported versions. --- .../webapp/tests/control_tests_servicer.py | 2 +- vasl_templates/webapp/tests/test_counters.py | 9 +++++- vasl_templates/webapp/tests/test_vassal.py | 28 ++++++++++++++----- vasl_templates/webapp/utils.py | 5 ++-- vasl_templates/webapp/vasl_mod.py | 4 +-- vasl_templates/webapp/vassal.py | 2 +- 6 files changed, 36 insertions(+), 14 deletions(-) diff --git a/vasl_templates/webapp/tests/control_tests_servicer.py b/vasl_templates/webapp/tests/control_tests_servicer.py index 915ae26..14b4646 100644 --- a/vasl_templates/webapp/tests/control_tests_servicer.py +++ b/vasl_templates/webapp/tests/control_tests_servicer.py @@ -98,7 +98,7 @@ class ControlTestsServicer( BaseControlTestsServicer ): #pylint: disable=too-man for fname in glob.glob( fspec ): # FUDGE! We assume that the version number is part of the filename (we can do this # since we are only used for running tests i.e. in a controlled environment). - mo = re.search( r"\d+\.\d+\.\d+", os.path.basename(fname) ) + mo = re.search( r"\d+\.\d+\.\d+(\.\d+)?", os.path.basename(fname) ) self._vasl_mods[ mo.group() ] = fname for key,val in self._vasl_mods.items(): _logger.debug( "- %s -> %s", key, val ) diff --git a/vasl_templates/webapp/tests/test_counters.py b/vasl_templates/webapp/tests/test_counters.py index aeaa638..0766b3a 100644 --- a/vasl_templates/webapp/tests/test_counters.py +++ b/vasl_templates/webapp/tests/test_counters.py @@ -65,6 +65,11 @@ def test_counter_images( webapp, webdriver ): #pylint: disable=too-many-locals shutil.rmtree( save_dir ) os.makedirs( save_dir ) + # load the VASL version aliases + fname = os.path.join( os.path.dirname( __file__ ), "../data/vasl-version-aliases.json" ) + with open( fname, "r", encoding="utf-8" ) as fp: + aliases = json.load( fp ) + # test each VASL version failed = False vasl_versions = webapp.control_tests.get_vasl_versions() @@ -77,7 +82,9 @@ def test_counter_images( webapp, webdriver ): #pylint: disable=too-many-locals init_webapp( webapp, webdriver ) # figure out what we're expecting to see - fname = os.path.join( check_dir, "vasl-pieces-{}.txt".format( vasl_version ) ) + fname = os.path.join( check_dir, "vasl-pieces-{}.txt".format( + aliases.get( vasl_version, vasl_version ) + ) ) with open( fname, "r", encoding="utf-8" ) as fp: expected_vasl_pieces = fp.read() diff --git a/vasl_templates/webapp/tests/test_vassal.py b/vasl_templates/webapp/tests/test_vassal.py index 84db041..318a6d3 100644 --- a/vasl_templates/webapp/tests/test_vassal.py +++ b/vasl_templates/webapp/tests/test_vassal.py @@ -433,10 +433,10 @@ def test_update_legacy_labels( webapp, webdriver ): # so I suspect the code is trying to deserialize something it no longers knows about :-/ # The tests here are for handling legacy labels, which was an issue quite a long time ago # in vasl-templates years, so we just ignore this problem... - run_vassal_tests( webapp, lambda: do_test(True), max_vasl_version="6.6.2" ) + run_vassal_tests( webapp, lambda: do_test(True), ignore_vasl_versions=["6.6.3"] ) # run the test again (once) with no Chapter H vehicle/ordnance notes - run_vassal_tests( webapp, lambda: do_test(False), all_combos=False, max_vasl_version="6.6.2" ) + run_vassal_tests( webapp, lambda: do_test(False), all_combos=False, ignore_vasl_versions=["6.6.3"] ) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -749,7 +749,7 @@ def test_vo_entry_selection_for_theater( webapp, webdriver ): # --------------------------------------------------------------------- def run_vassal_tests( webapp, func, vasl_extns_type=None, - all_combos=None, min_vasl_version=None, max_vasl_version=None + all_combos=None, min_vasl_version=None, max_vasl_version=None, ignore_vasl_versions=None ): """Run the test function for each combination of VASSAL + VASL. @@ -759,7 +759,25 @@ def run_vassal_tests( webapp, func, vasl_extns_type=None, # get the available VASSAL and VASL versions vassal_versions = webapp.control_tests.get_vassal_versions() + assert len( vassal_versions ) > 0, "Can't find any VASSAL versions." vasl_versions = webapp.control_tests.get_vasl_versions() + if min_vasl_version: + vasl_versions = [ + v for v in vasl_versions + if compare_version_strings( v, min_vasl_version ) >= 0 + ] + if max_vasl_version: + vasl_versions = [ + v for v in vasl_versions + if compare_version_strings( v, max_vasl_version ) <= 0 + ] + if ignore_vasl_versions: + assert isinstance( ignore_vasl_versions, list ) + vasl_versions = [ + v for v in vasl_versions + if v not in ignore_vasl_versions + ] + assert len( vasl_versions ) > 0, "Can't find any VASL versions." # check if we want to test all VASSAL+VASL combinations (nb: if not, we test against only one combination, # and since they all should give the same results, it doesn't matter which one. @@ -779,10 +797,6 @@ def run_vassal_tests( webapp, func, vasl_extns_type=None, # run the test for each VASSAL+VASL for vassal_version in vassal_versions: for vasl_version in vasl_versions: - if min_vasl_version and compare_version_strings( vasl_version, min_vasl_version ) < 0: - continue - if max_vasl_version and compare_version_strings( vasl_version, max_vasl_version ) > 0: - continue if not VassalShim.is_compatible_version( vassal_version, vasl_version ): continue webapp.control_tests \ diff --git a/vasl_templates/webapp/utils.py b/vasl_templates/webapp/utils.py index 41a97d1..a22df40 100644 --- a/vasl_templates/webapp/utils.py +++ b/vasl_templates/webapp/utils.py @@ -287,8 +287,9 @@ def is_windows(): def compare_version_strings( lhs, rhs ): """Compare two version strings.""" def parse( val ): #pylint: disable=missing-docstring - mo = re.search( r"^(\d+)\.(\d+)\.(\d+)$", val ) - return ( int(mo.group(1)), int(mo.group(2)), int(mo.group(3)) ) + mo = re.search( r"^(\d+)\.(\d+)\.(\d+)(.\d+)?$", val ) + last = int( mo.group(4)[1:] ) if mo.group(4) else 0 + return ( int(mo.group(1)), int(mo.group(2)), int(mo.group(3)), last ) lhs, rhs = parse(lhs), parse(rhs) if lhs < rhs: return -1 diff --git a/vasl_templates/webapp/vasl_mod.py b/vasl_templates/webapp/vasl_mod.py index 3e21c47..7c98954 100644 --- a/vasl_templates/webapp/vasl_mod.py +++ b/vasl_templates/webapp/vasl_mod.py @@ -16,8 +16,8 @@ from vasl_templates.webapp.config.constants import DATA_DIR from vasl_templates.webapp.vo import get_vo_listings from vasl_templates.webapp.utils import compare_version_strings -SUPPORTED_VASL_MOD_VERSIONS = [ "6.6.0", "6.6.1", "6.6.2", "6.6.3" ] -SUPPORTED_VASL_MOD_VERSIONS_DISPLAY = "6.6.0-.3" +SUPPORTED_VASL_MOD_VERSIONS = [ "6.6.0", "6.6.1", "6.6.2", "6.6.3", "6.6.3.1" ] +SUPPORTED_VASL_MOD_VERSIONS_DISPLAY = "6.6.0-.3, 6.6.3.1" _zip_file_lock = threading.Lock() diff --git a/vasl_templates/webapp/vassal.py b/vasl_templates/webapp/vassal.py index 51d8ef6..9d35ede 100644 --- a/vasl_templates/webapp/vassal.py +++ b/vasl_templates/webapp/vassal.py @@ -40,7 +40,7 @@ SUPPORTED_VASSAL_VERSIONS = { "3.4.2": [ "6.6.0", "6.6.1" ], "3.4.6": [ "6.6.0", "6.6.1" ], "3.5.5": [ "6.6.0", "6.6.1", "6.6.2" ], - "3.5.8": [ "6.6.0", "6.6.1", "6.6.2", "6.6.3" ], + "3.5.8": [ "6.6.0", "6.6.1", "6.6.2", "6.6.3", "6.6.3.1" ], } SUPPORTED_VASSAL_VERSIONS_DISPLAY = "3.4.2, 3.4.6, 3.5.5, 3.5.8"