You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.1 KiB

  1. """Run the Python regression test using the compiler
  2. This test runs the standard Python test suite using bytecode generated
  3. by this compiler instead of by the builtin compiler.
  4. The regression test is run with the interpreter in verbose mode so
  5. that import problems can be observed easily.
  6. """
  7. from compiler import compileFile
  8. import os
  9. import sys
  10. import test
  11. import tempfile
  12. def copy_test_suite():
  13. dest = tempfile.mkdtemp()
  14. os.system("cp -r %s/* %s" % (test.__path__[0], dest))
  15. print "Creating copy of test suite in", dest
  16. return dest
  17. def copy_library():
  18. dest = tempfile.mkdtemp()
  19. libdir = os.path.split(test.__path__[0])[0]
  20. print "Found standard library in", libdir
  21. print "Creating copy of standard library in", dest
  22. os.system("cp -r %s/* %s" % (libdir, dest))
  23. return dest
  24. def compile_files(dir):
  25. print "Compiling", dir, "\n\t",
  26. line_len = 10
  27. for file in os.listdir(dir):
  28. base, ext = os.path.splitext(file)
  29. if ext == '.py':
  30. source = os.path.join(dir, file)
  31. line_len = line_len + len(file) + 1
  32. if line_len > 75:
  33. print "\n\t",
  34. line_len = len(source) + 9
  35. print file,
  36. try:
  37. compileFile(source)
  38. except SyntaxError, err:
  39. print err
  40. continue
  41. # make sure the .pyc file is not over-written
  42. os.chmod(source + "c", 444)
  43. elif file == 'CVS':
  44. pass
  45. else:
  46. path = os.path.join(dir, file)
  47. if os.path.isdir(path):
  48. print
  49. print
  50. compile_files(path)
  51. print "\t",
  52. line_len = 10
  53. print
  54. def run_regrtest(lib_dir):
  55. test_dir = os.path.join(lib_dir, "test")
  56. os.chdir(test_dir)
  57. os.system("PYTHONPATH=%s %s -v regrtest.py" % (lib_dir, sys.executable))
  58. def cleanup(dir):
  59. os.system("rm -rf %s" % dir)
  60. def main():
  61. lib_dir = copy_library()
  62. compile_files(lib_dir)
  63. run_regrtest(lib_dir)
  64. raw_input("Cleanup?")
  65. cleanup(lib_dir)
  66. if __name__ == "__main__":
  67. main()