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

Side by Side Diff: recipe_engine/test.py

Issue 2828823003: Detect duplicate recipe tests (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | unittests/test_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2017 The LUCI Authors. All rights reserved. 1 # Copyright 2017 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 from __future__ import print_function 5 from __future__ import print_function
6 6
7 import argparse 7 import argparse
8 import bdb 8 import bdb
9 import cStringIO 9 import cStringIO
10 import contextlib 10 import contextlib
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 # the function definition, not GenTests body. 402 # the function definition, not GenTests body.
403 recipe_tests = list(recipe.gen_tests(test_api)) 403 recipe_tests = list(recipe.gen_tests(test_api))
404 coverage_data.update(cov.get_data()) 404 coverage_data.update(cov.get_data())
405 405
406 for test_data in recipe_tests: 406 for test_data in recipe_tests:
407 # Put the test data in shared cache. This way it can only be generated 407 # Put the test data in shared cache. This way it can only be generated
408 # once. We do this primarily for _correctness_ , for example in case 408 # once. We do this primarily for _correctness_ , for example in case
409 # a weird recipe generates tests non-deterministically. The recipe 409 # a weird recipe generates tests non-deterministically. The recipe
410 # engine should be robust against such user recipe code where 410 # engine should be robust against such user recipe code where
411 # reasonable. 411 # reasonable.
412 _GEN_TEST_CACHE[(recipe_name, test_data.name)] = copy.deepcopy( 412 key = (recipe_name, test_data.name)
413 test_data) 413 if key in _GEN_TEST_CACHE:
414 raise ValueError('Duplicate test found: %s' % test_data.name)
iannucci1 2017/04/19 18:12:42 I think the error should indicate which recipe the
Paweł Hajdan Jr. 2017/04/19 18:17:06 It does, please see the test: Exception: While ge
415 _GEN_TEST_CACHE[key] = copy.deepcopy(test_data)
414 416
415 test_description = TestDescription( 417 test_description = TestDescription(
416 recipe_name, test_data.name, expect_dir, covers) 418 recipe_name, test_data.name, expect_dir, covers)
417 if test_filter: 419 if test_filter:
418 for pattern in test_filter: 420 for pattern in test_filter:
419 if fnmatch.fnmatch(test_description.full_name, pattern): 421 if fnmatch.fnmatch(test_description.full_name, pattern):
420 tests.append(test_description) 422 tests.append(test_description)
421 break 423 break
422 else: 424 else:
423 tests.append(test_description) 425 tests.append(test_description)
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 Returns: 903 Returns:
902 Exit code 904 Exit code
903 """ 905 """
904 global _UNIVERSE_VIEW 906 global _UNIVERSE_VIEW
905 _UNIVERSE_VIEW = universe_view 907 _UNIVERSE_VIEW = universe_view
906 global _ENGINE_FLAGS 908 global _ENGINE_FLAGS
907 _ENGINE_FLAGS = engine_flags 909 _ENGINE_FLAGS = engine_flags
908 910
909 args = parse_args(raw_args) 911 args = parse_args(raw_args)
910 return args.func(args) 912 return args.func(args)
OLDNEW
« no previous file with comments | « no previous file | unittests/test_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698