Added support for VASSAL 3.4.2-.7 and VASL 6.6.0-.1.

master
Pacman Ghost 4 years ago
parent 7e102744ca
commit 26722019be
  1. 1363
      vasl_templates/webapp/tests/fixtures/vasl-pieces-6.6.0.txt
  2. 1363
      vasl_templates/webapp/tests/fixtures/vasl-pieces-6.6.1.txt
  3. 2
      vasl_templates/webapp/tests/remote.py
  4. 31
      vasl_templates/webapp/tests/test_counters.py
  5. 34
      vasl_templates/webapp/tests/test_vassal.py
  6. 19
      vasl_templates/webapp/vasl_mod.py
  7. 30
      vasl_templates/webapp/vassal.py
  8. 1
      vassal-shim/Makefile
  9. BIN
      vassal-shim/release/vassal-shim.jar
  10. 24
      vassal-shim/src/vassal_shim/Main.java

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -243,6 +243,8 @@ class ControlTests:
dname = app.config[ "TEST_VASSAL_ENGINES" ]
vassal_engines = []
for root,_,fnames in os.walk( dname ):
if os.sep+"_disabled_"+os.sep in root:
continue
for fname in fnames:
if fname == "Vengine.jar":
if root.endswith( "/lib" ):

@ -10,7 +10,8 @@ import urllib.request
import pytest
import tabulate
from vasl_templates.webapp.vasl_mod import VaslMod, get_vo_gpids, compare_vasl_versions, SUPPORTED_VASL_MOD_VERSIONS
from vasl_templates.webapp.vassal import SUPPORTED_VASSAL_VERSIONS
from vasl_templates.webapp.vasl_mod import VaslMod, get_vo_gpids, compare_version_strings, SUPPORTED_VASL_MOD_VERSIONS
from vasl_templates.webapp.config.constants import DATA_DIR
from vasl_templates.webapp.vo import _kfw_listings #pylint: disable=protected-access
from vasl_templates.webapp.utils import change_extn
@ -18,6 +19,8 @@ from vasl_templates.webapp.tests.utils import init_webapp, select_tab, find_chil
from vasl_templates.webapp.tests.test_scenario_persistence import load_scenario
from vasl_templates.webapp.tests.remote import ControlTests
_EXPECTED_MISSING_GPIDS_EXCEPTIONS = [ "6.5.0", "6.5.1", "6.6.0", "6.6.1" ]
# ---------------------------------------------------------------------
@pytest.mark.skipif(
@ -98,11 +101,11 @@ def test_counter_images( webapp ):
expected_missing_gpids.remove( "1527" ) # FUDGE! this is a remapped GPID (12730)
def _do_check_front( gpid, code, data ):
if vasl_version not in ("6.5.0","6.5.1") and gpid in expected_missing_gpids:
if vasl_version not in _EXPECTED_MISSING_GPIDS_EXCEPTIONS and gpid in expected_missing_gpids:
return code == 404 and not data
return code == 200 and data
def _do_check_back( gpid, code, data ):
if vasl_version not in ("6.5.0","6.5.1") and gpid in expected_missing_gpids:
if vasl_version not in _EXPECTED_MISSING_GPIDS_EXCEPTIONS and gpid in expected_missing_gpids:
return code == 404 and not data
return (code == 200 and data) or (code == 404 and not data)
@ -253,6 +256,10 @@ def test_gpid_remapping( webapp, webdriver ):
return matches[0]
# run the tests using VASL 6.4.4 and 6.5.0
# NOTE: Versions of VASL prior to 6.6.0 are no longer officially supported (since they use Java 8),
# but we would still like to run these tests. See VassalShim._run_vassal_shim(), where we figure out
# which version of Java to use, and _run_tests() in test_vassal.py, where we check for invalid
# combinations of VASSAL and VASL. Sigh...
do_test( find_vasl_mod("6.4.4"), True )
do_test( find_vasl_mod("6.5.0"), True )
do_test( find_vasl_mod("6.5.1"), True )
@ -270,11 +277,19 @@ def test_gpid_remapping( webapp, webdriver ):
# ---------------------------------------------------------------------
def test_compare_vasl_versions():
"""Test comparing VASL version strings."""
def test_compare_version_strings():
"""Test comparing version strings."""
# test comparing VASSAL version strings
for i,vassal_version in enumerate( SUPPORTED_VASSAL_VERSIONS):
if i > 0:
assert compare_version_strings( SUPPORTED_VASSAL_VERSIONS[i-1], vassal_version ) < 0
assert compare_version_strings( SUPPORTED_VASSAL_VERSIONS[i], vassal_version ) == 0
if i < len(SUPPORTED_VASSAL_VERSIONS)-1:
assert compare_version_strings( vassal_version, SUPPORTED_VASSAL_VERSIONS[i+1] ) < 0
# test comparing VASL version strings
for i,vasl_version in enumerate(SUPPORTED_VASL_MOD_VERSIONS):
if i > 0:
assert compare_vasl_versions( SUPPORTED_VASL_MOD_VERSIONS[i-1], vasl_version ) < 0
assert compare_vasl_versions( vasl_version, vasl_version ) == 0
assert compare_version_strings( SUPPORTED_VASL_MOD_VERSIONS[i-1], vasl_version ) < 0
assert compare_version_strings( vasl_version, vasl_version ) == 0
if i < len(SUPPORTED_VASL_MOD_VERSIONS)-1:
assert compare_vasl_versions( vasl_version, SUPPORTED_VASL_MOD_VERSIONS[i+1] ) < 0
assert compare_version_strings( vasl_version, SUPPORTED_VASL_MOD_VERSIONS[i+1] ) < 0

@ -10,7 +10,7 @@ import typing.re #pylint: disable=import-error
import pytest
from vasl_templates.webapp.vassal import VassalShim
from vasl_templates.webapp.vasl_mod import compare_vasl_versions
from vasl_templates.webapp.vasl_mod import compare_version_strings
from vasl_templates.webapp.utils import TempFile, change_extn
from vasl_templates.webapp import globvars
from vasl_templates.webapp.tests.utils import \
@ -789,11 +789,35 @@ def _run_tests( control_tests, func, test_all, min_vasl_version=None ):
vasl_mods = control_tests.get_vasl_mods()
vassal_engines = control_tests.get_vassal_engines()
def is_valid_combo( vassal_engine, vasl_mod ):
"""Check if this is a valid combination of VASSAL and VASL."""
# NOTE: From 3.3, VASSAL no longer works with Java 8, and requires VASL 6.6.0 or later.
# FUDGE! We assume the version number is part of the VASSAL path, otherwise we would have to
# run the VASSAL shim to get the version number, and things are slow enough already :-/
mo = re.search( r"\d+\.\d+\.\d+", vassal_engine )
vassal_version = mo.group()
mo = re.search( r"\d+\.\d+\.\d+", vasl_mod )
vasl_version = mo.group()
if compare_version_strings( vassal_version, "3.3.0" ) >= 0:
if compare_version_strings( vasl_version, "6.6.0" ) < 0:
return False
else:
if compare_version_strings( vasl_version, "6.6.0" ) >= 0:
return False
return True
# 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.
if not test_all:
vasl_mods = [ random.choice( vasl_mods ) ]
vassal_engines = [ random.choice( vassal_engines ) ]
for _ in range(0,100):
vasl_mod = random.choice( vasl_mods )
vassal_engine = random.choice( vassal_engines )
if is_valid_combo( vassal_engine, vasl_mod ):
vasl_mods = [ vasl_mod ]
vassal_engines = [ vassal_engine ]
break
else:
assert False, "Can't find a valid combination of VASSAL and VASL."
# FUDGE! If we are running the tests against a remote server, we still need to be able to run
# the VASSAL shim locally (to dump VASSAL save files), so we need to set up things up enough
@ -810,9 +834,11 @@ def _run_tests( control_tests, func, test_all, min_vasl_version=None ):
# the vmod, extract the buildFile, parse the XML, etc. :-/
mo = re.search( r"\d+\.\d+\.\d+", vasl_mod )
vasl_version = mo.group()
if min_vasl_version and compare_vasl_versions( vasl_version, min_vasl_version ) < 0:
if min_vasl_version and compare_version_strings( vasl_version, min_vasl_version ) < 0:
continue
control_tests.set_vasl_mod( vmod=vasl_mod )
if not is_valid_combo( vassal_engine, vasl_mod ):
continue
func()
# ---------------------------------------------------------------------

@ -14,8 +14,8 @@ from vasl_templates.webapp import app, globvars
from vasl_templates.webapp.config.constants import DATA_DIR
from vasl_templates.webapp.vo import get_vo_listings
SUPPORTED_VASL_MOD_VERSIONS = [ "6.4.0", "6.4.1", "6.4.2", "6.4.3", "6.4.4", "6.5.0", "6.5.1" ]
SUPPORTED_VASL_MOD_VERSIONS_DISPLAY = "6.4.0-6.5.1"
SUPPORTED_VASL_MOD_VERSIONS = [ "6.6.0", "6.6.1" ]
SUPPORTED_VASL_MOD_VERSIONS_DISPLAY = "6.6.0-.1"
warnings = [] # nb: for the test suite
@ -445,9 +445,12 @@ def get_vo_gpids( vasl_mod ):
return gpids
def compare_vasl_versions( lhs, rhs ):
"""Compare two VASL version strings."""
# NOTE: We can do this with a simple string comparison, but see test_compare_vasl_versions().
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)) )
lhs, rhs = parse(lhs), parse(rhs)
if lhs < rhs:
return -1
elif lhs > rhs:
@ -507,8 +510,8 @@ def get_remapped_gpid( vasl_mod, gpid ):
for remappings in GPID_REMAPPINGS:
# FUDGE! Early versions of this code (pre-6.5.0) always applied the remappings for 6.4.3,
# even for versions of VASL earlier than that. For simplicity, we preserve that behavior.
if compare_vasl_versions( remappings[0], "6.5.0" ) < 0 \
or compare_vasl_versions( vasl_mod.vasl_version, remappings[0] ) >= 0:
if compare_version_strings( remappings[0], "6.5.0" ) < 0 \
or compare_version_strings( vasl_mod.vasl_version, remappings[0] ) >= 0:
gpid = remappings[1].get( gpid, gpid )
return gpid
@ -517,6 +520,6 @@ def get_reverse_remapped_gpid( vasl_mod, gpid ):
if not vasl_mod:
return gpid
for remappings in REVERSE_GPID_REMAPPINGS:
if compare_vasl_versions( vasl_mod.vasl_version, remappings[0] ) >= 0:
if compare_version_strings( vasl_mod.vasl_version, remappings[0] ) >= 0:
gpid = remappings[1].get( gpid, gpid )
return gpid

@ -19,10 +19,14 @@ from vasl_templates.webapp import app, globvars
from vasl_templates.webapp.config.constants import BASE_DIR, IS_FROZEN
from vasl_templates.webapp.utils import TempFile, SimpleError
from vasl_templates.webapp.webdriver import WebDriver
from vasl_templates.webapp.vasl_mod import get_reverse_remapped_gpid
from vasl_templates.webapp.vasl_mod import get_reverse_remapped_gpid, compare_version_strings
SUPPORTED_VASSAL_VERSIONS = [ "3.2.15" ,"3.2.16", "3.2.17" ]
SUPPORTED_VASSAL_VERSIONS_DISPLAY = "3.2.15-.17"
# NOTE: VASSAL dropped support for Java 8 from 3.3.0. The first version of VASL that supported
# the later versions of Java was 6.6.0, but it was compiled against VASSAL 3.4.2, so we don't
# need to support versions of VASSAL prior to this (3.3.0-.2, 3.4.0-.1), since VASL is known
# not work with them.
SUPPORTED_VASSAL_VERSIONS = [ "3.4.2", "3.4.3", "3.4.4", "3.4.5", "3.4.6", "3.4.7" ]
SUPPORTED_VASSAL_VERSIONS_DISPLAY = "3.4.2-.7"
# ---------------------------------------------------------------------
@ -365,10 +369,28 @@ class VassalShim:
# initialize
logger = logging.getLogger( "vassal_shim" )
# prepare the command
# figure out where Java is
java_path = app.config.get( "JAVA_PATH" )
java8_path = app.config.get( "JAVA8_PATH" )
if java8_path:
# FUDGE! From 3.3, VASSAL no longer works with Java 8. We want to mantain back-compatibility
# with the older versions of VASL (6.5.1 and older) for some time, and while it's not a big issue
# from the user's perspective (they just configure the appropriate VASSAL+VASL), it's problematic
# for the test suite (since it has to be able to run the correct version of Java for the VASSAL
# being used). We do this here, and since it's just for the purpose of running tests, we can
# require that the VASSAL version be embedded in the filename.
# NOTE: I eventually gave up trying to maintain back-compat with older versions of VASL, but
# the GPID remapping test (test_gpid_remapping() in test_counters.py) is an important one,
# but is currently only relevant for 6.4.4 and 6.5.0-.1, so for the sole purpose of being able
# to run those tests, we still support Java 8. Sigh...
mo = re.search( r"\d+\.\d+\.\d+", self.vengine_jar )
if compare_version_strings( mo.group(), "3.3.0" ) < 0:
# we're using a legacy version of VASSAL - use Java 8
java_path = java8_path
if not java_path:
java_path = "java" # nb: this must be in the PATH
# prepare the command
class_path = app.config.get( "JAVA_CLASS_PATH" )
if not class_path:
class_path = [ self.vengine_jar, self.shim_jar ]

@ -1,5 +1,6 @@
# Define VASSAL_DIR in the command line arguments to point to the directory that contains Vengine.jar e.g.
# make all VASSAL_DIR=...
# We are currently compiling with Java 14.0.2, using VASSAL 3.4.2.
SRC_DIR:=src
DATA_DIR:=data

@ -3,6 +3,8 @@ package vassal_shim ;
import java.io.BufferedWriter ;
import java.io.FileWriter ;
import java.util.ArrayList ;
import java.lang.reflect.Method ;
import java.lang.reflect.InvocationTargetException ;
import VASSAL.Info ;
@ -20,6 +22,28 @@ public class Main
System.exit( 0 ) ;
}
// FUDGE! In VASSAL 3.4.4, they changed the way the version number is tracked (it's now in the resources),
// and Info.getVersion() reports the wrong thing OOB :-/ We have to install a StandardConfig instance
// into the Info class, but since this is a new thing, we have to use reflection to figure out if it exists
// and we can do it (and we obviously can't check the VASSAL version, since that's what we're trying to set :-/).
// NOTE: We do this in all cases, not just when we're getting the VASSAL version, since VASL is checking
// the VASSAL version and complains if there is a mismatch e.g. VASL 6.6.1 was compiled against VASSAL 3.4.6,
// but even if we're using VASSAL 3.4.6, it mis-reports itself as 3.4.3, so VASL complains. It might just be
// a warning for the user, but VASL could also be adjusting its behaviour depending on what version of VASSAL
// is being used, so for safety, we install the VASSAL version number properly. Sigh... :-/
try {
// NOTE: We're trying to do this:
// Info.setConfig( new StandardConfig() ) ;
Class<?> infoClass = Class.forName( "VASSAL.Info" ) ;
Class<?> configClass = Class.forName( "VASSAL.launch.Config" ) ;
Method setConfigMethod = infoClass.getMethod( "setConfig", configClass ) ;
Object standardConfig = Class.forName( "VASSAL.launch.StandardConfig" ).getDeclaredConstructor().newInstance() ;
setConfigMethod.invoke( null, standardConfig ) ;
} catch( ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException ex ) {
// NOTE: If anything fails, we assume it's because we're on a version earlier than 3.4.4,
// and hopefully Info.getVersion() will work OOB.
}
// execute the specified command
try {
String cmd = args[0].toLowerCase() ;

Loading…
Cancel
Save