Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1073)

Unified Diff: scripts/slave/unittests/expect_tests/pipeline.py

Issue 355143002: Set coverage path globs on a per-Test basis instead of in main(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: scripts/slave/unittests/expect_tests/pipeline.py
diff --git a/scripts/slave/unittests/expect_tests/pipeline.py b/scripts/slave/unittests/expect_tests/pipeline.py
index fff0b3d792d7b941a5c5b4b804057adf57271d9f..6d5ddbf5b98211b931d0d19dfcc434cea8ea7092 100644
--- a/scripts/slave/unittests/expect_tests/pipeline.py
+++ b/scripts/slave/unittests/expect_tests/pipeline.py
@@ -4,6 +4,7 @@
import Queue
import glob
+import inspect
import logging
import multiprocessing
import re
@@ -60,7 +61,13 @@ def gen_loop_process(gen, test_queue, result_queue, opts, kill_switch,
paths_seen = set()
seen_tests = False
try:
- for root_test in gen():
+ with cover_ctx:
+ gen_inst = gen()
+
+ while not kill_switch.is_set():
+ with cover_ctx:
+ root_test = next(gen_inst)
+
if kill_switch.is_set():
Vadim Sh. 2014/06/27 18:06:48 Is it still needed here?
iannucci 2014/06/28 08:58:17 I guess not, but it doesn't hurt, especially if ne
break
@@ -95,6 +102,8 @@ def gen_loop_process(gen, test_queue, result_queue, opts, kill_switch,
if not seen_tests:
result_queue.put_nowait(NoMatchingTestsError())
+ except StopIteration:
+ pass
except KeyboardInterrupt:
pass
finally:
@@ -103,9 +112,8 @@ def gen_loop_process(gen, test_queue, result_queue, opts, kill_switch,
next_stage = (result_queue if opts.handler.SKIP_RUNLOOP else test_queue)
- with cover_ctx:
- opts.handler.gen_stage_loop(opts, generate_tests(), next_stage.put_nowait,
- result_queue.put_nowait)
+ opts.handler.gen_stage_loop(opts, generate_tests(), next_stage.put_nowait,
+ result_queue.put_nowait)
def run_loop_process(test_queue, result_queue, opts, kill_switch, cover_ctx):
@@ -113,6 +121,7 @@ def run_loop_process(test_queue, result_queue, opts, kill_switch, cover_ctx):
into opts.run_stage_loop().
Generates coverage data as a side-effect.
+
@type test_queue: multiprocessing.Queue()
@type result_queue: multiprocessing.Queue()
@type opts: argparse.Namespace
@@ -130,7 +139,8 @@ def run_loop_process(test_queue, result_queue, opts, kill_switch, cover_ctx):
SKIP = object()
def process_test(subtest):
logstream.reset()
- subresult = subtest.run()
+ with cover_ctx(include=subtest.coverage_includes()):
+ subresult = subtest.run()
if isinstance(subresult, TestError):
result_queue.put_nowait(subresult)
return SKIP
@@ -163,9 +173,8 @@ def run_loop_process(test_queue, result_queue, opts, kill_switch, cover_ctx):
except KeyboardInterrupt:
pass
- with cover_ctx:
- opts.handler.run_stage_loop(opts, generate_tests_results(),
- result_queue.put_nowait)
+ opts.handler.run_stage_loop(opts, generate_tests_results(),
+ result_queue.put_nowait)
def result_loop(test_gen, cover_ctx, opts):
@@ -181,8 +190,17 @@ def result_loop(test_gen, cover_ctx, opts):
test_queue = multiprocessing.Queue()
result_queue = multiprocessing.Queue()
+ gen_cover_ctx = cover_ctx
+ if cover_ctx.enabled:
+ if hasattr(test_gen, '_covers'):
+ # decorated with expect_tests.covers
+ gen_cover = test_gen._covers() # pylint: disable=W0212
Vadim Sh. 2014/06/27 18:06:48 I forgot what type test_gen has here. Why do you
iannucci 2014/06/28 08:58:17 it's a user function. Moved this all to util and u
+ else:
+ gen_cover = [inspect.getabsfile(test_gen)]
Vadim Sh. 2014/06/27 18:06:48 Cover single file? Also, have you verified it work
iannucci 2014/06/28 08:58:17 It seems to always give back a .py file. I have py
+ gen_cover_ctx = cover_ctx(include=gen_cover)
+
test_gen_args = (
- test_gen, test_queue, result_queue, opts, kill_switch, cover_ctx)
+ test_gen, test_queue, result_queue, opts, kill_switch, gen_cover_ctx)
procs = []
if opts.handler.SKIP_RUNLOOP:

Powered by Google App Engine
This is Rietveld 408576698