Skip to content
Browse files

made everything look like the old test suite.

  • Loading branch information...
1 parent 50f5867 commit 292fec782d8f42d6f7fcd7f1546d1f387f655b09 @Neppord Neppord committed
Showing with 80 additions and 322 deletions.
  1. +27 −243 run_tests.py
  2. +0 −30 run_unit.py
  3. +53 −49 test_results.txt
View
270 run_tests.py 100755 → 100644
@@ -1,246 +1,30 @@
-#! /usr/bin/env python
-
-import os
-import sys
-import tempfile
-from glob import glob
-from optparse import OptionParser
-from difflib import unified_diff
-
-PY_OUT_FILE_NAME = os.path.join(tempfile.gettempdir(), "py.out")
-JS_OUT_FILE_NAME = os.path.join(tempfile.gettempdir(), "js.out")
-JS_ERR_FILE_NAME = os.path.join(tempfile.gettempdir(), "js.err")
-JS_SRC_FILE_NAME = os.path.join(tempfile.gettempdir(), "js.src")
-JS_DIFF_FILE_NAME = os.path.join(tempfile.gettempdir(), "js.diff")
-PY2JS_ERR_FILE_NAME = os.path.join(tempfile.gettempdir(), "py2js.err")
-
-
-def test1(in_file):
- w = Writer()
- w.write("Testing the file: %s" % in_file)
- r = os.system('js -f py-builtins.js -f \"%s\"' % in_file)
- w.check(r)
-
-def test2(in_file):
- w = Writer()
- w.write("Testing the file: %s" % in_file)
- command = ""
- if sys.platform == "win32":
- command = "set "
- r = os.system("%sPYTHONPATH=.:$PYTHONPATH python \"%s\"" % (command,in_file))
- w.check(r)
-
-def test3(name, in_file=None, known_to_fail=False):
-
- in_file = in_file or name
-
- PYTHON_COMMAND = "python \"%s\" > \"%s\""
- PY2JS_COMMAND = "python pyjs.py --include-builtins \"%s\" > \"%s\" 2> \"%s\""
- JS_COMMAND = "js -f \"%s\" > \"%s\" 2> \"%s\""
- DIFF_COMMAND = "diff \"%s\" \"%s\" > \"%s\""
- w = Writer()
- w.write("%s [4]: " % name)
- r = os.system(PYTHON_COMMAND % (in_file, PY_OUT_FILE_NAME))
- w.write(".")
- if r == 0:
- r = os.system( PY2JS_COMMAND % (in_file, JS_SRC_FILE_NAME, PY2JS_ERR_FILE_NAME ))
- w.write(".")
- if r == 0:
- r = os.system( JS_COMMAND%(JS_SRC_FILE_NAME, JS_OUT_FILE_NAME, JS_ERR_FILE_NAME))
- w.write(".")
- if r == 0:
- r = os.system(DIFF_COMMAND%(JS_OUT_FILE_NAME, PY_OUT_FILE_NAME, JS_DIFF_FILE_NAME))
- w.write(".")
- w.check(r, known_to_fail)
-
+#! python
+import optparse
+import testtools.runner
+import testtools.util
+import testtools.tests
+import unittest
def main():
- if not os.path.exists("py-builtins.js"):
- print "py-builtins.js not found. Run 'make' to generate it"
- return False
- if not (os.path.exists("js") or os.path.exists("js.exe")):
- print "the js shell doesn't exsist or is named wrong."
- return False
-
- parser = OptionParser(usage="%prog [options] filename",
- description="py2js tests.")
- parser.add_option("-a", "--run-all",
- action="store_true", dest="run_all",
- default=False, help="run all tests (including the known-to-fail)")
- options, args = parser.parse_args()
- if len(args) == 1:
- test3(args[0])
+ option_parser = optparse.OptionParser(
+ usage="%prog [options] [filenames]",
+ description="py2js unittests script."
+ )
+ option_parser.add_option(
+ "-a",
+ "--run-all",
+ action="store_true",
+ dest="run_all",
+ default=False,
+ help="run all tests (including the known-to-fail)"
+ )
+ options, args = option_parser.parse_args()
+ runner = testtools.runner.Py2JsTestRunner(verbosity=2)
+ if options.run_all:
+ runner.run(testtools.tests.ALL)
+ elif args:
+ runner.run(testtools.tests.get_tests(args))
else:
- test1("tests/test_builtins.js")
- files = glob("tests/test_*.py")
- for file in files:
- test2(file)
- dirs = [
- "tests/basic/*.py",
- "tests/errors/*.py",
- "tests/functions/*.py",
- "tests/lists/*.py",
- "tests/libraries/*.py",
- "tests/modules/*.py",
- "tests/strings/*.py",
- "tests/algorithms/*.py",
- ]
- files = []
- for dir in dirs:
- files.extend((path.replace("\\","/"), os.path.abspath(path)) for path in glob(dir))
- known_to_fail = [
- "tests/basic/nestedclass.py",
- "tests/basic/super.py",
- "tests/basic/kwargs.py",
- "tests/basic/float2int.py",
- "tests/basic/oo_inherit.py",
- "tests/basic/listcomp2.py",
- "tests/basic/del_dict.py",
- "tests/basic/del_local.py",
- "tests/basic/sumcomp.py",
- "tests/basic/del_array.py",
- "tests/basic/valueerror.py",
- "tests/basic/lambda.py",
- "tests/basic/try.py",
- "tests/basic/vargs.py",
- "tests/basic/del_attr.py",
- "tests/basic/del_global.py",
- "tests/basic/del_slice.py",
- "tests/basic/generator.py",
- "tests/basic/raise.py",
-
- "tests/functions/sort_cmp.py",
- "tests/functions/ne.py",
- "tests/functions/aug.py",
- "tests/functions/floatdiv.py",
- "tests/functions/sort23.py",
-
- "tests/errors/decorator.py",
-
- "tests/lists/filter.py",
- "tests/lists/reduce.py",
- "tests/lists/sum.py",
- "tests/lists/subclass.py",
-
- "tests/libraries/xmlwriter.py",
-
- "tests/modules/classname.py",
- "tests/modules/from_import.py",
- "tests/modules/import.py",
- "tests/modules/import_alias.py",
- "tests/modules/import_class.py",
- "tests/modules/import_diamond.py",
- "tests/modules/import_global.py",
- "tests/modules/import_multi.py",
- "tests/modules/module_name.py",
- "tests/modules/rng.py",
-
- "tests/strings/string_format_d.py",
- "tests/strings/string_format_efg.py",
- "tests/strings/string_format_i.py",
- "tests/strings/string_format_o.py",
- "tests/strings/string_format_u.py",
- "tests/strings/string_format_x.py",
- "tests/strings/ulcase.py",
- ]
- known_to_fail = [os.path.abspath(path) for path in known_to_fail]
- files.sort()
- for name, file in files:
- if options.run_all:
- test3(name, file, file in known_to_fail)
- elif file not in known_to_fail:
- test3(name, file)
-
-class Writer(object):
-
- def __init__(self):
- self._line_wrap = False
- self._write_pos = 0
-
- def write(self, text, color="", align="left", width=80):
- """
- Prints a text on the screen.
-
- It uses sys.stdout.write(), so no readline library is necessary.
-
- color ... choose from the colors below, "" means default color
- align ... left/right, left is a normal print, right is aligned on the
- right hand side of the screen, filled with " " if necessary
- width ... the screen width
- """
- color_templates = (
- ("Black" , "0;30"),
- ("Red" , "0;31"),
- ("Green" , "0;32"),
- ("Brown" , "0;33"),
- ("Blue" , "0;34"),
- ("Purple" , "0;35"),
- ("Cyan" , "0;36"),
- ("LightGray" , "0;37"),
- ("DarkGray" , "1;30"),
- ("LightRed" , "1;31"),
- ("LightGreen" , "1;32"),
- ("Yellow" , "1;33"),
- ("LightBlue" , "1;34"),
- ("LightPurple" , "1;35"),
- ("LightCyan" , "1;36"),
- ("White" , "1;37"), )
-
- colors = {}
-
- for name, value in color_templates:
- colors[name] = value
- c_normal = '\033[0m'
- c_color = '\033[%sm'
-
- if align == "right":
- if self._write_pos+len(text) > width:
- # we don't fit on the current line, create a new line
- self.write("\n")
- self.write(" "*(width-self._write_pos-len(text)))
-
- if hasattr(sys.stdout, 'isatty') and not sys.stdout.isatty():
- # the stdout is not a terminal, this for example happens if the
- # output is piped to less, e.g. "bin/test | less". In this case,
- # the terminal control sequences would be printed verbatim, so
- # don't use any colors.
- color = ""
- if sys.platform == "win32":
- # Windows consoles don't support ANSI escape sequences
- color = ""
-
- if self._line_wrap:
- if text[0] != "\n":
- sys.stdout.write("\n")
-
- if color == "":
- sys.stdout.write(text)
- else:
- sys.stdout.write("%s%s%s" % (c_color % colors[color], text, c_normal))
- sys.stdout.flush()
- l = text.rfind("\n")
- if l == -1:
- self._write_pos += len(text)
- else:
- self._write_pos = len(text)-l-1
- self._line_wrap = self._write_pos >= width
- self._write_pos %= width
-
- def check(self, r, known_to_fail=False, exit_on_failure=True):
- if r == 0:
- if known_to_fail:
- self.write("should fail but [OK]", align="right", color="Green")
- else:
- self.write("[OK]", align="right", color="Green")
- else:
- if known_to_fail:
- self.write("known to [FAIL]", align="right", color="Purple")
- else:
- self.write("[FAIL]", align="right", color="Red")
- if exit_on_failure:
- print
- print
- sys.exit(1)
- self.write("\n")
+ runner.run(testtools.tests.NOT_KNOWN_TO_FAIL)
-if __name__ == '__main__':
- main()
+if __name__ == "__main__":
+ main()
View
30 run_unit.py
@@ -1,30 +0,0 @@
-#! python
-import optparse
-import testtools.runner
-import testtools.util
-import testtools.tests
-import unittest
-def main():
- option_parser = optparse.OptionParser(
- usage="%prog [options] [filenames]",
- description="py2js unittests script."
- )
- option_parser.add_option(
- "-a",
- "--run-all",
- action="store_true",
- dest="run_all",
- default=False,
- help="run all tests (including the known-to-fail)"
- )
- options, args = option_parser.parse_args()
- runner = testtools.runner.Py2JsTestRunner(verbosity=2)
- if options.run_all:
- runner.run(testtools.tests.ALL)
- elif args:
- runner.run(testtools.tests.get_tests(args))
- else:
- runner.run(testtools.tests.NOT_KNOWN_TO_FAIL)
-
-if __name__ == "__main__":
- main()
View
102 test_results.txt
@@ -1,5 +1,6 @@
-Testing the file: tests/test_builtins.js [OK]
-Testing the file: tests\test_compile_js.py [OK]
+Looking for "js" and "py-builtins" [2]: .. [OK]
+tests/test_compile_js.py [1]: . [OK]
+tests/test_builtins.js [1]: . [OK]
tests/algorithms/sqrt.py [4]: .... [OK]
tests/algorithms/triangulation.py [4]: .... [OK]
tests/basic/assign_slice.py [4]: .... [OK]
@@ -16,42 +17,29 @@ tests/basic/class6.py [4]: .... [OK]
tests/basic/closure.py [4]: .... [OK]
tests/basic/continue.py [4]: .... [OK]
tests/basic/default.py [4]: .... [OK]
-tests/basic/del_array.py [4]: .... known to [FAIL]
-tests/basic/del_attr.py [4]: .. known to [FAIL]
-tests/basic/del_dict.py [4]: .... known to [FAIL]
-tests/basic/del_global.py [4]: .. known to [FAIL]
-tests/basic/del_local.py [4]: .. known to [FAIL]
-tests/basic/del_slice.py [4]: .... known to [FAIL]
tests/basic/dictionary.py [4]: .... [OK]
tests/basic/dictionary2.py [4]: .... [OK]
tests/basic/docstring.py [4]: .... [OK]
tests/basic/embedding.py [4]: .... [OK]
tests/basic/fib.py [4]: .... [OK]
-tests/basic/float2int.py [4]: .... known to [FAIL]
tests/basic/for_in.py [4]: .... [OK]
tests/basic/for_step.py [4]: .... [OK]
tests/basic/for_xrange.py [4]: .... [OK]
-tests/basic/generator.py [4]: ... known to [FAIL]
tests/basic/globalvar.py [4]: .... [OK]
tests/basic/helloworld.py [4]: .... [OK]
tests/basic/ifs.py [4]: .... [OK]
tests/basic/keys.py [4]: .... [OK]
-tests/basic/kwargs.py [4]: ... known to [FAIL]
tests/basic/kwargs2.py [4]: .... [OK]
-tests/basic/lambda.py [4]: .... known to [FAIL]
tests/basic/list.py [4]: .... [OK]
tests/basic/list2.py [4]: .... [OK]
-tests/basic/listcomp2.py [4]: .. known to [FAIL]
tests/basic/literals.py [4]: .... [OK]
tests/basic/logicalops.py [4]: .... [OK]
tests/basic/loops.py [4]: .... [OK]
tests/basic/multiassign.py [4]: .... [OK]
-tests/basic/nestedclass.py [4]: ... known to [FAIL]
tests/basic/none.py [4]: .... [OK]
tests/basic/oo.py [4]: .... [OK]
tests/basic/oo_attributes.py [4]: .... [OK]
tests/basic/oo_diamond.py [4]: .... [OK]
-tests/basic/oo_inherit.py [4]: .. known to [FAIL]
tests/basic/oo_inherit2.py [4]: .... [OK]
tests/basic/oo_inherit3.py [4]: .... [OK]
tests/basic/oo_inherit_simple.py [4]: .... [OK]
@@ -60,31 +48,22 @@ tests/basic/oo_static_inherit.py [4]: .... [OK]
tests/basic/oo_super.py [4]: .... [OK]
tests/basic/pass.py [4]: .... [OK]
tests/basic/print.py [4]: .... [OK]
-tests/basic/raise.py [4]: .. known to [FAIL]
tests/basic/scope.py [4]: .... [OK]
tests/basic/str1.py [4]: .... [OK]
-tests/basic/sumcomp.py [4]: .. known to [FAIL]
-tests/basic/super.py [4]: .. known to [FAIL]
tests/basic/trueorfalse.py [4]: .... [OK]
-tests/basic/try.py [4]: .. known to [FAIL]
tests/basic/tuple.py [4]: .... [OK]
tests/basic/tuple2.py [4]: .... [OK]
-tests/basic/valueerror.py [4]: .. known to [FAIL]
-tests/basic/vargs.py [4]: ... known to [FAIL]
tests/basic/vars.py [4]: .... [OK]
tests/basic/vars2.py [4]: .... [OK]
tests/basic/while.py [4]: .... [OK]
-tests/errors/decorator.py [4]: .. known to [FAIL]
tests/errors/py_collision.py [4]: .... [OK]
tests/functions/and.py [4]: .... [OK]
tests/functions/append.py [4]: .... [OK]
-tests/functions/aug.py [4]: .. known to [FAIL]
tests/functions/bitand.py [4]: .... [OK]
tests/functions/bitor.py [4]: .... [OK]
tests/functions/bitxor.py [4]: .... [OK]
tests/functions/divfloor.py [4]: .... [OK]
tests/functions/float.py [4]: .... [OK]
-tests/functions/floatdiv.py [4]: .. known to [FAIL]
tests/functions/gtge.py [4]: .... [OK]
tests/functions/in.py [4]: .... [OK]
tests/functions/int.py [4]: .... [OK]
@@ -92,44 +71,26 @@ tests/functions/isinstance.py [4]: .... [OK]
tests/functions/len.py [4]: .... [OK]
tests/functions/lshift.py [4]: .... [OK]
tests/functions/ltle.py [4]: .... [OK]
-tests/functions/ne.py [4]: .. known to [FAIL]
tests/functions/or.py [4]: .... [OK]
tests/functions/pop.py [4]: .... [OK]
tests/functions/rshift.py [4]: .... [OK]
tests/functions/sort.py [4]: .... [OK]
-tests/functions/sort23.py [4]: .... known to [FAIL]
-tests/functions/sort_cmp.py [4]: .... known to [FAIL]
tests/functions/str.py [4]: .... [OK]
tests/functions/ubitcomp.py [4]: .... [OK]
tests/functions/uminus.py [4]: .... [OK]
tests/functions/uplus.py [4]: .... [OK]
-tests/libraries/xmlwriter.py [4]: .. known to [FAIL]
tests/lists/extend.py [4]: .... [OK]
-tests/lists/filter.py [4]: ... known to [FAIL]
tests/lists/in.py [4]: .... [OK]
tests/lists/insert.py [4]: .... [OK]
tests/lists/map.py [4]: .... [OK]
tests/lists/max.py [4]: .... [OK]
tests/lists/min.py [4]: .... [OK]
-tests/lists/reduce.py [4]: ... known to [FAIL]
tests/lists/reverse.py [4]: .... [OK]
-tests/lists/subclass.py [4]: ... known to [FAIL]
tests/lists/subclass2.py [4]: .... [OK]
tests/lists/subclass3.py [4]: .... [OK]
-tests/lists/sum.py [4]: .. known to [FAIL]
tests/lists/sum2.py [4]: .... [OK]
tests/lists/xrange.py [4]: .... [OK]
tests/lists/zip.py [4]: .... [OK]
-tests/modules/classname.py [4]: .. known to [FAIL]
-tests/modules/from_import.py [4]: .. known to [FAIL]
-tests/modules/import.py [4]: .. known to [FAIL]
-tests/modules/import_alias.py [4]: .. known to [FAIL]
-tests/modules/import_class.py [4]: .. known to [FAIL]
-tests/modules/import_diamond.py [4]: .. known to [FAIL]
-tests/modules/import_global.py [4]: .. known to [FAIL]
-tests/modules/import_multi.py [4]: .. known to [FAIL]
-tests/modules/module_name.py [4]: .. known to [FAIL]
-tests/modules/rng.py [4]: . known to [FAIL]
tests/strings/count.py [4]: .... [OK]
tests/strings/find.py [4]: .... [OK]
tests/strings/join.py [4]: .... [OK]
@@ -142,18 +103,61 @@ tests/strings/rstrip1.py [4]: .... [OK]
tests/strings/split.py [4]: .... [OK]
tests/strings/splitlines.py [4]: .... [OK]
tests/strings/string_format_combined_simple.py [4]: .... [OK]
-tests/strings/string_format_d.py [4]: ... known to [FAIL]
tests/strings/string_format_d_simple.py [4]: .... [OK]
-tests/strings/string_format_efg.py [4]: .... known to [FAIL]
tests/strings/string_format_f_simple.py [4]: .... [OK]
-tests/strings/string_format_i.py [4]: ... known to [FAIL]
-tests/strings/string_format_o.py [4]: .... known to [FAIL]
tests/strings/string_format_s_simple.py [4]: .... [OK]
-tests/strings/string_format_u.py [4]: ... known to [FAIL]
-tests/strings/string_format_x.py [4]: .... known to [FAIL]
tests/strings/strings_in_strings.py [4]: .... [OK]
tests/strings/strip.py [4]: .... [OK]
tests/strings/strip1.py [4]: .... [OK]
-tests/strings/ulcase.py [4]: ... known to [FAIL]
tests/strings/ulcase1.py [4]: .... [OK]
tests/strings/zipstring.py [4]: .... [OK]
+tests/basic/del_array.py [4]: ... known to [FAIL]
+tests/basic/del_attr.py [4]: . known to [FAIL]
+tests/basic/del_dict.py [4]: ... known to [FAIL]
+tests/basic/del_global.py [4]: . known to [FAIL]
+tests/basic/del_local.py [4]: . known to [FAIL]
+tests/basic/del_slice.py [4]: ... known to [FAIL]
+tests/basic/float2int.py [4]: ... known to [FAIL]
+tests/basic/generator.py [4]: .. known to [FAIL]
+tests/basic/kwargs.py [4]: .. known to [FAIL]
+tests/basic/lambda.py [4]: ... known to [FAIL]
+tests/basic/listcomp2.py [4]: . known to [FAIL]
+tests/basic/nestedclass.py [4]: .. known to [FAIL]
+tests/basic/oo_inherit.py [4]: . known to [FAIL]
+tests/basic/raise.py [4]: . known to [FAIL]
+tests/basic/sumcomp.py [4]: . known to [FAIL]
+tests/basic/super.py [4]: . known to [FAIL]
+tests/basic/try.py [4]: . known to [FAIL]
+tests/basic/valueerror.py [4]: . known to [FAIL]
+tests/basic/vargs.py [4]: .. known to [FAIL]
+tests/errors/decorator.py [4]: . known to [FAIL]
+tests/functions/aug.py [4]: . known to [FAIL]
+tests/functions/floatdiv.py [4]: . known to [FAIL]
+tests/functions/ne.py [4]: . known to [FAIL]
+tests/functions/sort23.py [4]: ... known to [FAIL]
+tests/functions/sort_cmp.py [4]: ... known to [FAIL]
+tests/libraries/xmlwriter.py [4]: . known to [FAIL]
+tests/lists/filter.py [4]: .. known to [FAIL]
+tests/lists/reduce.py [4]: .. known to [FAIL]
+tests/lists/subclass.py [4]: .. known to [FAIL]
+tests/lists/sum.py [4]: . known to [FAIL]
+tests/modules/classname.py [4]: . known to [FAIL]
+tests/modules/from_import.py [4]: . known to [FAIL]
+tests/modules/import.py [4]: . known to [FAIL]
+tests/modules/import_alias.py [4]: . known to [FAIL]
+tests/modules/import_class.py [4]: . known to [FAIL]
+tests/modules/import_diamond.py [4]: . known to [FAIL]
+tests/modules/import_global.py [4]: . known to [FAIL]
+tests/modules/import_multi.py [4]: . known to [FAIL]
+tests/modules/module_name.py [4]: . known to [FAIL]
+tests/modules/rng.py [4]: known to [FAIL]
+tests/strings/string_format_d.py [4]: .. known to [FAIL]
+tests/strings/string_format_efg.py [4]: ... known to [FAIL]
+tests/strings/string_format_i.py [4]: .. known to [FAIL]
+tests/strings/string_format_o.py [4]: ... known to [FAIL]
+tests/strings/string_format_u.py [4]: .. known to [FAIL]
+tests/strings/string_format_x.py [4]: ... known to [FAIL]
+tests/strings/ulcase.py [4]: .. known to [FAIL]
+Ran 160 tests in 58.874s
+
+OK (expected failures=47)

0 comments on commit 292fec7

Please sign in to comment.
Something went wrong with that request. Please try again.