Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
2.0 kB · 51 lines
Python
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152"""Run the built patch on the game's own Java 1.4.2, outside the game.
python tools/test_patch.py [facade-install-folder] [--text="line to classify"]
Uses the game's JVM, working directory and launch flags (including -Xfuturestrict class checks), so a class that loads here loads in the game. Runs theharness twice: against the sidecar (start it first), then against a dead port toprove the fallback to the original parser."""import subprocessimport sys
from facade_install import BUILD_CLASSES, from_args
# From the game's launcher (strings in animEngineDLL.dll).GAME_JVM_FLAGS = ["-Xms70m", "-Xmx150m", "-XX:NewSize=25m", "-enableassertions", "-Xfuture", "-Xincgc"]DEAD_SIDECAR = "-Dfacadejev.url=http://127.0.0.1:9/da"
def run(install, text, extra_flags=()): classpath = "%s;../../classes;../../classes/jess.jar" % BUILD_CLASSES command = [str(install.java)] + GAME_JVM_FLAGS + list(extra_flags) + ["-classpath", classpath, "JevHarness", text] result = subprocess.run(command, cwd=install.sources, capture_output=True, text=True) return result.returncode, result.stdout + result.stderr
def main(): install = from_args(sys.argv) chosen = [arg[len("--text="):] for arg in sys.argv[1:] if arg.startswith("--text=")] text = chosen[0] if chosen else "sounds good" if not (BUILD_CLASSES / "JevHarness.class").is_file(): sys.exit("nothing built; run tools/build_patch.py first") if not install.java.is_file(): sys.exit("no bundled JVM at %s" % install.java)
print("== with the sidecar") code, output = run(install, text) print(output.strip()) ok = code == 0 and "engine fact: (MAIN::DA " in output
print("\n== sidecar unreachable: must fall back to the original parser") code, output = run(install, text, [DEAD_SIDECAR]) print(output.strip()) ok = ok and code == 0 and "engine fact: (MAIN::wo-" in output
print("\n%s" % ("PASS" if ok else "FAIL (is the sidecar running?)")) sys.exit(0 if ok else 1)
if __name__ == "__main__": main()