# HG changeset patch # User Paul Boddie # Date 1106593736 -3600 # Node ID e0c8821fcbcb82efb9ad278cfe910620e6809164 # Parent 9bbab006f98a050422bc29eb2f15a5b91b7158b7 Updated runclass and the test program. The updated test program exposes issues with the Python runtime, especially with Python 2.4, apparently within the memory management routines. diff -r 9bbab006f98a -r e0c8821fcbcb runclass.py --- a/runclass.py Mon Jan 24 00:46:54 2005 +0100 +++ b/runclass.py Mon Jan 24 20:08:56 2005 +0100 @@ -5,6 +5,21 @@ import javaclass.classhook import java.lang +# NOTE: Simple __this__ package loader to potentially avoid repeated import +# NOTE: issues exposed by test.py. + +def load_classes(class_names): + + "Load the classes with the given 'class_names'." + + module = __import__("__this__", globals(), locals(), class_names) + objs = [] + for class_name in class_names: + objs.append(getattr(module, class_name)) + return objs + +# The more general class loader. + def load_class(class_name): "Load the class with the given 'class_name'." diff -r 9bbab006f98a -r e0c8821fcbcb test.py --- a/test.py Mon Jan 24 00:46:54 2005 +0100 +++ b/test.py Mon Jan 24 20:08:56 2005 +0100 @@ -3,6 +3,8 @@ "Run the test suite." import os, glob +import runclass +import java.lang def get_test_sources(): return glob.glob("*.java") @@ -18,10 +20,11 @@ print "Compiling", java_file os.system(javac + " " + java_file) -def run_test_files(java): - for class_ in get_test_classes(): - print "Running", class_ - os.system(java + " " + class_) +def run_test_files(): + classes = runclass.load_classes(get_test_classes()) + for cls in classes: + print "Running", cls + runclass.run_class(cls, [java.lang.String("Test")]) if __name__ == "__main__": import sys @@ -34,12 +37,13 @@ elif len(sys.argv) > 1: javac = sys.argv[1] else: - print "Cannot find a Java compiler." - print "Please specify the full path as an argument to this program" - print "or set JAVA_HOME to the JDK installation." - sys.exit(1) + print "Guessing that javac is your Java compiler." + print "If this does not work then please specify the full path as an" + print "argument to this program or set JAVA_HOME to refer to the JDK" + print "installation." + javac = "javac" - if not os.path.exists(javac): + if javac != "javac" and not os.path.exists(javac): print "The suggested Java compiler cannot be found." sys.exit(1) @@ -47,6 +51,8 @@ os.chdir("tests") compile_test_files(javac) - run_test_files("runclass.py") + run_test_files() + + print "Tests complete." # vim: tabstop=4 expandtab shiftwidth=4