Commits

Cat's Eye Technologies  committed 45e29da

Catch KeyboardInterrupt and show those tests we did manage to run.

  • Participants
  • Parent commits 5968e3e

Comments (0)

Files changed (3)

File HISTORY.markdown

 * In `--verbose` mode, `py-falderal` will issue warnings about any test that
   has been run twice (i.e. more than run on identical test body text and
   implementation.)
+* If `py-falderal` catches a `KeyboardInterrupt` exception while running tests,
+  it shows a report of all the tests that it did manage to run until that
+  point, and a warning message to the effect that not all tests were run.
 
 Version 0.8 "Ukranian Village" (current released version):
 

File TODO.markdown

 having both kinds of expectations would allow non-deterministic combinations
 of the two to be matched.)
 
-### catch KeyboardInterrupt, report on all results so far
-
-When a test suite takes a long time to run, it would be very nice if
-interrupting it with `^C` were to show a report of all the tests that did
-manage to run, plus a count of how many were not run.
-
 ### Split InterveningMarkdown blocks to make nice test descriptions
 
 For example, if we have

File src/falderal/driver.py

     # run tests
     results = []
     dup_check = {}
-    for test in tests:
-        if options.verbose:
-            print str(test)
-        these_results = test.run(options=options)
-        if options.verbose:
-            for result in these_results:
-                key = repr(test.body_block.text()) + repr(result.implementation)
-                location = "%s, line %d" % (
-                    test.body_block.filename, test.body_block.line_num
-                )
-                dup_check.setdefault(key, []).append(location)
-        results += these_results
+    all_ran = False
+    try:
+        for test in tests:
+            if options.verbose:
+                print str(test)
+            these_results = test.run(options=options)
+            if options.verbose:
+                for result in these_results:
+                    key = repr(test.body_block.text()) + repr(result.implementation)
+                    location = "%s, line %d" % (
+                        test.body_block.filename, test.body_block.line_num
+                    )
+                    dup_check.setdefault(key, []).append(location)
+            results += these_results
+        all_ran = True
+    except KeyboardInterrupt:
+        pass
 
     if options.verbose:
         for key in dup_check:
         result.report()
     num_results = len(results)
     num_failures = len([x for x in results if not x.is_successful()])
+    if not all_ran:
+        print '**************************************************************'
+        print '** TESTING TERMINATED PREMATURELY -- NOT ALL TESTS WERE RUN **'
+        print '**************************************************************'
+
     print '--------------------------------'
     print 'Total test runs: %d, failures: %d' % (num_results, num_failures)
     print '--------------------------------'