Merge lp:~jelmer/brz/coverage-coverage into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/coverage-coverage
Merge into: lp:brz
Diff against target: 157 lines (+26/-23)
6 files modified
.bzrignore (+1/-0)
.coveragerc (+1/-0)
.travis.yml (+2/-3)
breezy/commands.py (+15/-19)
breezy/plugin.py (+1/-1)
breezy/tests/__init__.py (+6/-0)
To merge this branch: bzr merge lp:~jelmer/brz/coverage-coverage
Reviewer Review Type Date Requested Status
Martin Packman Approve
Jelmer Vernooij Approve
Review via email: mp+345192@code.launchpad.net

Commit message

Switch --coverage to use coverage module.

Description of the change

This should make it easier to integrate with e.g. codecov.io; it also allows more easily generating HTML coverage output (rather than the text output that tracer generates).

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
Martin Packman (gz) wrote :

Looks good to me. The envvar setting is a little ugly but interface is otherwise close enough and this is the module I use on other projects.

review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Running landing tests failed
https://ci.breezy-vcs.org/job/brz-dev/144/

Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Running landing tests failed
https://ci.breezy-vcs.org/job/brz-dev/145/

Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Running landing tests failed
https://ci.breezy-vcs.org/job/brz-dev/146/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2018-02-18 17:56:45 +0000
+++ .bzrignore 2018-05-09 23:48:22 +0000
@@ -74,3 +74,4 @@
74python3.passing.old74python3.passing.old
75python3.passing.new75python3.passing.new
76selftest.log76selftest.log
77.coverage
7778
=== modified file '.coveragerc'
--- .coveragerc 2018-05-07 13:30:31 +0000
+++ .coveragerc 2018-05-09 23:48:22 +0000
@@ -1,5 +1,6 @@
1[run]1[run]
2branch = True2branch = True
3source = breezy
34
4[report]5[report]
5exclude_lines =6exclude_lines =
67
=== modified file '.travis.yml'
--- .travis.yml 2018-05-07 13:35:54 +0000
+++ .travis.yml 2018-05-09 23:48:22 +0000
@@ -14,12 +14,12 @@
14matrix:14matrix:
15 include:15 include:
16 - python: 2.716 - python: 2.7
17 env: SELFTEST_OPTIONS=""17 env: SELFTEST_OPTIONS="--coverage"
18 EXTRA_MAKE_ARGS="extensions"18 EXTRA_MAKE_ARGS="extensions"
1919
20script:20script:
21 - make docs $EXTRA_MAKE_ARGS21 - make docs $EXTRA_MAKE_ARGS
22 - BRZ_PLUGIN_PATH=-site:-user python -Werror -Wignore::ImportWarning -Wignore::PendingDeprecationWarning -Wignore::DeprecationWarning -m coverage run -p --source=breezy ./brz selftest --parallel=fork $SELFTEST_OPTIONS22 - BRZ_PLUGIN_PATH=-site:-user python -Werror -Wignore::ImportWarning -Wignore::PendingDeprecationWarning -Wignore::DeprecationWarning ./brz selftest --parallel=fork $SELFTEST_OPTIONS
2323
24install:24install:
25 - sudo apt install python-all-dev python3-all-dev subunit25 - sudo apt install python-all-dev python3-all-dev subunit
@@ -27,5 +27,4 @@
27 - travis_retry pip install -U pip coverage codecov flake8 testtools paramiko fastimport configobj cython testscenarios six docutils python-subunit $TEST_REQUIRE27 - travis_retry pip install -U pip coverage codecov flake8 testtools paramiko fastimport configobj cython testscenarios six docutils python-subunit $TEST_REQUIRE
2828
29after_success:29after_success:
30 - python -m coverage combine
31 - codecov30 - codecov
3231
=== modified file 'breezy/commands.py'
--- breezy/commands.py 2017-11-12 13:53:51 +0000
+++ breezy/commands.py 2018-05-09 23:48:22 +0000
@@ -957,19 +957,16 @@
957 return argdict957 return argdict
958958
959959
960def apply_coveraged(dirname, the_callable, *args, **kwargs):960def apply_coveraged(the_callable, *args, **kwargs):
961 import trace961 import coverage
962 tracer = trace.Trace(count=1, trace=0)962 cov = coverage.Coverage()
963 sys.settrace(tracer.globaltrace)963 os.environ['COVERAGE_PROCESS_START'] = cov.config_file
964 threading.settrace(tracer.globaltrace)964 cov.start()
965
966 try:965 try:
967 return exception_to_return_code(the_callable, *args, **kwargs)966 return exception_to_return_code(the_callable, *args, **kwargs)
968 finally:967 finally:
969 sys.settrace(None)968 cov.stop()
970 results = tracer.results()969 cov.save()
971 results.write_results(show_missing=1, summary=False,
972 coverdir=dirname)
973970
974971
975def apply_profiled(the_callable, *args, **kwargs):972def apply_profiled(the_callable, *args, **kwargs):
@@ -1085,7 +1082,7 @@
1085 Run under the Python lsprof profiler.1082 Run under the Python lsprof profiler.
10861083
1087 --coverage1084 --coverage
1088 Generate line coverage report in the specified directory.1085 Generate code coverage report
10891086
1090 --concurrency1087 --concurrency
1091 Specify the number of processes that can be run concurrently (selftest).1088 Specify the number of processes that can be run concurrently (selftest).
@@ -1095,8 +1092,8 @@
1095 trace.mutter("brz arguments: %r", argv)1092 trace.mutter("brz arguments: %r", argv)
10961093
1097 opt_lsprof = opt_profile = opt_no_plugins = opt_builtin = \1094 opt_lsprof = opt_profile = opt_no_plugins = opt_builtin = \
1098 opt_no_l10n = opt_no_aliases = False1095 opt_coverage = opt_no_l10n = opt_no_aliases = False
1099 opt_lsprof_file = opt_coverage_dir = None1096 opt_lsprof_file = None
11001097
1101 # --no-plugins is handled specially at a very early stage. We need1098 # --no-plugins is handled specially at a very early stage. We need
1102 # to load plugins before doing other command parsing so that they1099 # to load plugins before doing other command parsing so that they
@@ -1127,8 +1124,7 @@
1127 os.environ['BRZ_CONCURRENCY'] = argv[i + 1]1124 os.environ['BRZ_CONCURRENCY'] = argv[i + 1]
1128 i += 11125 i += 1
1129 elif a == '--coverage':1126 elif a == '--coverage':
1130 opt_coverage_dir = argv[i + 1]1127 opt_coverage = True
1131 i += 1
1132 elif a == '--profile-imports':1128 elif a == '--profile-imports':
1133 pass # already handled in startup script Bug #5882771129 pass # already handled in startup script Bug #588277
1134 elif a.startswith('-D'):1130 elif a.startswith('-D'):
@@ -1178,17 +1174,17 @@
1178 saved_verbosity_level = option._verbosity_level1174 saved_verbosity_level = option._verbosity_level
1179 option._verbosity_level = 01175 option._verbosity_level = 0
1180 if opt_lsprof:1176 if opt_lsprof:
1181 if opt_coverage_dir:1177 if opt_coverage:
1182 trace.warning(1178 trace.warning(
1183 '--coverage ignored, because --lsprof is in use.')1179 '--coverage ignored, because --lsprof is in use.')
1184 ret = apply_lsprofiled(opt_lsprof_file, run, *run_argv)1180 ret = apply_lsprofiled(opt_lsprof_file, run, *run_argv)
1185 elif opt_profile:1181 elif opt_profile:
1186 if opt_coverage_dir:1182 if opt_coverage:
1187 trace.warning(1183 trace.warning(
1188 '--coverage ignored, because --profile is in use.')1184 '--coverage ignored, because --profile is in use.')
1189 ret = apply_profiled(run, *run_argv)1185 ret = apply_profiled(run, *run_argv)
1190 elif opt_coverage_dir:1186 elif opt_coverage:
1191 ret = apply_coveraged(opt_coverage_dir, run, *run_argv)1187 ret = apply_coveraged(run, *run_argv)
1192 else:1188 else:
1193 ret = run(*run_argv)1189 ret = run(*run_argv)
1194 return ret or 01190 return ret or 0
11951191
=== modified file 'breezy/plugin.py'
--- breezy/plugin.py 2017-10-26 11:10:38 +0000
+++ breezy/plugin.py 2018-05-09 23:48:22 +0000
@@ -463,7 +463,7 @@
463 if state is None:463 if state is None:
464 state = breezy.get_global_state()464 state = breezy.get_global_state()
465 items = []465 items = []
466 for name, a_plugin in sorted(state.plugins.items()):466 for name, a_plugin in sorted(getattr(state, 'plugins', {}).items()):
467 items.append("%s[%s]" %467 items.append("%s[%s]" %
468 (name, a_plugin.__version__))468 (name, a_plugin.__version__))
469 return ', '.join(items)469 return ', '.join(items)
470470
=== modified file 'breezy/tests/__init__.py'
--- breezy/tests/__init__.py 2018-03-30 14:54:24 +0000
+++ breezy/tests/__init__.py 2018-05-09 23:48:22 +0000
@@ -3487,6 +3487,12 @@
3487 try:3487 try:
3488 stream = os.fdopen(c2pwrite, 'wb', 1)3488 stream = os.fdopen(c2pwrite, 'wb', 1)
3489 workaround_zealous_crypto_random()3489 workaround_zealous_crypto_random()
3490 try:
3491 import coverage
3492 except ImportError:
3493 pass
3494 else:
3495 coverage.process_startup()
3490 os.close(c2pread)3496 os.close(c2pread)
3491 # Leave stderr and stdout open so we can see test noise3497 # Leave stderr and stdout open so we can see test noise
3492 # Close stdin so that the child goes away if it decides to3498 # Close stdin so that the child goes away if it decides to

Subscribers

People subscribed via source and target branches