javaclass

Change of test.py

160:e0c8821fcbcb
test.py
     1.1 --- a/test.py	Mon Jan 24 00:46:54 2005 +0100
     1.2 +++ b/test.py	Mon Jan 24 20:08:56 2005 +0100
     1.3 @@ -3,6 +3,8 @@
     1.4  "Run the test suite."
     1.5  
     1.6  import os, glob
     1.7 +import runclass
     1.8 +import java.lang
     1.9  
    1.10  def get_test_sources():
    1.11      return glob.glob("*.java")
    1.12 @@ -18,10 +20,11 @@
    1.13              print "Compiling", java_file
    1.14              os.system(javac + " " + java_file)
    1.15  
    1.16 -def run_test_files(java):
    1.17 -    for class_ in get_test_classes():
    1.18 -        print "Running", class_
    1.19 -        os.system(java + " " + class_)
    1.20 +def run_test_files():
    1.21 +    classes = runclass.load_classes(get_test_classes())
    1.22 +    for cls in classes:
    1.23 +        print "Running", cls
    1.24 +        runclass.run_class(cls, [java.lang.String("Test")])
    1.25  
    1.26  if __name__ == "__main__":
    1.27      import sys
    1.28 @@ -34,12 +37,13 @@
    1.29      elif len(sys.argv) > 1:
    1.30          javac = sys.argv[1]
    1.31      else:
    1.32 -        print "Cannot find a Java compiler."
    1.33 -        print "Please specify the full path as an argument to this program"
    1.34 -        print "or set JAVA_HOME to the JDK installation."
    1.35 -        sys.exit(1)
    1.36 +        print "Guessing that javac is your Java compiler."
    1.37 +        print "If this does not work then please specify the full path as an"
    1.38 +        print "argument to this program or set JAVA_HOME to refer to the JDK"
    1.39 +        print "installation."
    1.40 +        javac = "javac"
    1.41  
    1.42 -    if not os.path.exists(javac):
    1.43 +    if javac != "javac" and not os.path.exists(javac):
    1.44          print "The suggested Java compiler cannot be found."
    1.45          sys.exit(1)
    1.46  
    1.47 @@ -47,6 +51,8 @@
    1.48  
    1.49      os.chdir("tests")
    1.50      compile_test_files(javac)
    1.51 -    run_test_files("runclass.py")
    1.52 +    run_test_files()
    1.53 +
    1.54 +    print "Tests complete."
    1.55  
    1.56  # vim: tabstop=4 expandtab shiftwidth=4