Haxe: update README, fix macro eval, add conj.
[jackhill/mal.git] / runtest.py
index a61d273..075db37 100755 (executable)
@@ -49,8 +49,8 @@ parser.add_argument('--log-file', type=str,
         help="Write messages to the named file in addition the screen")
 parser.add_argument('--debug-file', type=str,
         help="Write all test interaction the named file")
-parser.add_argument('--soft', action='store_true',
-        help="Report but do not fail tests after ';>>> soft=True'")
+parser.add_argument('--hard', action='store_true',
+        help="Turn soft tests following a ';>>> soft=True' into hard failures")
 
 parser.add_argument('test_file', type=argparse.FileType('r'),
         help="a test file formatted as with mal test data")
@@ -231,6 +231,7 @@ test_cnt = 0
 pass_cnt = 0
 fail_cnt = 0
 soft_fail_cnt = 0
+failures = []
 
 while t.next():
     log("TEST: %s -> [%s,%s]" % (t.form, repr(t.out), t.ret), end='')
@@ -252,21 +253,33 @@ while t.next():
             log(" -> SUCCESS")
             pass_cnt += 1
         else:
-            if args.soft and t.soft:
+            if t.soft and not args.hard:
                 log(" -> SOFT FAIL (line %d):" % t.line_num)
                 soft_fail_cnt += 1
+                fail_type = "SOFT "
             else:
                 log(" -> FAIL (line %d):" % t.line_num)
                 fail_cnt += 1
-            log("    Expected : %s" % repr(expected))
+                fail_type = ""
+            log("    Expected : %s" % repr(expected[0]))
             log("    Got      : %s" % repr(res))
+            failed_test = """%sFAILED TEST (line %d): %s -> [%s,%s]:
+    Expected : %s
+    Got      : %s""" % (fail_type, t.line_num, t.form, repr(t.out), t.ret, repr(expected[0]), repr(res))
+            failures.append(failed_test)
     except:
         _, exc, _ = sys.exc_info()
         log("\nException: %s" % repr(exc))
         log("Output before exception:\n%s" % r.buf)
         sys.exit(1)
 
-results = """TEST RESULTS (for %s):
+if len(failures) > 0:
+    log("\nFAILURES:")
+    for f in failures:
+        log(f)
+
+results = """
+TEST RESULTS (for %s):
   %3d: soft failing tests
   %3d: failing tests
   %3d: passing tests