Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Bug 846169: Display a message that tbpl will recognise for test timeouts when in parseable output mode. #824

Open
wants to merge 1 commit into from

2 participants

Dave Townsend ochameau
Dave Townsend
Collaborator

The tricky bit is getting the name of the running test but that is output into the log in a standard form so I'm using a regex to track it. Only the parseable output that tbpl uses is affected here.

Dave Townsend Mossop commented on the diff
python-lib/cuddlefish/runner.py
@@ -714,6 +725,10 @@ def maybe_remove_outfile():
714 725
                         last_output_time = time.time()
715 726
                         sys.stderr.write(new_chars)
716 727
                         sys.stderr.flush()
  728
+                        if is_running_tests:
1
Dave Townsend Collaborator
Mossop added a note

I guess I should check if parseable it True here too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
ochameau ochameau commented on the diff
python-lib/cuddlefish/runner.py
@@ -704,6 +707,14 @@ def maybe_remove_outfile():
704 707
 
705 708
     done = False
706 709
     result = None
  710
+    test_name = "unknown"
  711
+
  712
+    def Timeout(message):
  713
+        if parseable:
  714
+            sys.stderr.write("TEST-UNEXPECTED-FAIL | %s | %s\n" % (test_name, message))
  715
+            sys.stderr.flush()
  716
+        return Exception(message)
  717
+
1
ochameau Collaborator
ochameau added a note

nit: I'd prefer Timeout to not depend on scope variable and accept parseable and test-name parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Feb 28, 2013
Dave Townsend Bug 846169: Display a message that tbpl will recognise for test timeo…
…uts when in parseable output mode.
2bd0334
This page is out of date. Refresh to see the latest.
1  python-lib/cuddlefish/__init__.py
@@ -912,6 +912,7 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None,
912 912
                              binary=options.binary,
913 913
                              profiledir=options.profiledir,
914 914
                              verbose=options.verbose,
  915
+                             parseable=options.parseable,
915 916
                              enforce_timeouts=enforce_timeouts,
916 917
                              logfile=options.logfile,
917 918
                              addons=options.addons,
25  python-lib/cuddlefish/runner.py
@@ -23,6 +23,9 @@
23 23
 # Used to filter only messages send by `console` module
24 24
 FILTER_ONLY_CONSOLE_FROM_ADB = re.compile(r'^I/(stdout|stderr)\s*\(\s*\d+\):\s*((info|warning|error|debug): .*)$')
25 25
 
  26
+# Used to detect the currently running test
  27
+PARSEABLE_TEST_NAME = re.compile(r'TEST-START \| ([^\n]+)\n')
  28
+
26 29
 # Maximum time we'll wait for tests to finish, in seconds.
27 30
 # The purpose of this timeout is to recover from infinite loops.  It should be
28 31
 # longer than the amount of time any test run takes, including those on slow
@@ -401,7 +404,7 @@ def set_overloaded_modules(env_root, app_type, addon_id, preferences, overloads)
401 404
 
402 405
 def run_app(harness_root_dir, manifest_rdf, harness_options,
403 406
             app_type, binary=None, profiledir=None, verbose=False,
404  
-            enforce_timeouts=False,
  407
+            parseable=False, enforce_timeouts=False,
405 408
             logfile=None, addons=None, args=None, extra_environment={},
406 409
             norun=None,
407 410
             used_files=None, enable_mobile=False,
@@ -704,6 +707,14 @@ def maybe_remove_outfile():
704 707
 
705 708
     done = False
706 709
     result = None
  710
+    test_name = "unknown"
  711
+
  712
+    def Timeout(message):
  713
+        if parseable:
  714
+            sys.stderr.write("TEST-UNEXPECTED-FAIL | %s | %s\n" % (test_name, message))
  715
+            sys.stderr.flush()
  716
+        return Exception(message)
  717
+
707 718
     try:
708 719
         while not done:
709 720
             time.sleep(0.05)
@@ -714,6 +725,10 @@ def maybe_remove_outfile():
714 725
                         last_output_time = time.time()
715 726
                         sys.stderr.write(new_chars)
716 727
                         sys.stderr.flush()
  728
+                        if is_running_tests:
  729
+                            match = PARSEABLE_TEST_NAME.search(new_chars)
  730
+                            if match:
  731
+                                test_name = match.group(1)
717 732
             if os.path.exists(resultfile):
718 733
                 result = open(resultfile).read()
719 734
                 if result:
@@ -724,11 +739,11 @@ def maybe_remove_outfile():
724 739
                         sys.stderr.write("'"+result+"'\n")
725 740
             if enforce_timeouts:
726 741
                 if time.time() - last_output_time > OUTPUT_TIMEOUT:
727  
-                    raise Exception("Test output exceeded timeout (%ds)." %
728  
-                                    OUTPUT_TIMEOUT)
  742
+                    raise Timeout("Test output exceeded timeout (%ds)." %
  743
+                                  OUTPUT_TIMEOUT)
729 744
                 if time.time() - starttime > RUN_TIMEOUT:
730  
-                    raise Exception("Test run exceeded timeout (%ds)." %
731  
-                                    RUN_TIMEOUT)
  745
+                    raise Timeout("Test run exceeded timeout (%ds)." %
  746
+                                  RUN_TIMEOUT)
732 747
     except:
733 748
         runner.stop()
734 749
         raise
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.