Merge lp:~msabramo/testrepository/add_logging into lp:~testrepository/testrepository/trunk

Proposed by Marc Abramowitz
Status: Needs review
Proposed branch: lp:~msabramo/testrepository/add_logging
Merge into: lp:~testrepository/testrepository/trunk
Diff against target: 64 lines (+12/-0)
1 file modified
testrepository/setuptools_command.py (+12/-0)
To merge this branch: bzr merge lp:~msabramo/testrepository/add_logging
Reviewer Review Type Date Requested Status
Robert Collins Needs Fixing
Review via email: mp+216532@code.launchpad.net

Description of the change

testrepository/setuptools_command.py: Add logging

to aid in debugging and testing.

I submitted the same change to pbr as https://review.openstack.org/89203

The interesting thing is that with this change in both pbr and testrepository I can see that there is weird behavior when one runs `python setup.py testr` -- methods for distutils commands defined in both are called.

```
 ❯ .tox/cover/bin/python setup.py testr --coverage
INFO:pbr.testr_command:imported
INFO:pbr.testr_command:initialize_options called
INFO:testrepository.setuptools_command:imported
running testr
INFO:testrepository.setuptools_command:initialize_options called
INFO:testrepository.setuptools_command:finalize_options called
INFO:testrepository.setuptools_command:run called
INFO:testrepository.setuptools_command:_coverage_before called
INFO:testrepository.setuptools_command:os.environ['PYTHON'] = 'coverage run --source jenkins-job-builder --parallel-mode'
INFO:testrepository.setuptools_command:_run_testr called
running=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} OS_LOG_CAPTURE=${OS_LOG_CAPTURE:-1}
```

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

Hi! Could you repropose this to master - https://github.com/testing-cabal/testrepository? Thanks!

Revision history for this message
Robert Collins (lifeless) :
review: Needs Fixing
Revision history for this message
Marc Abramowitz (msabramo) wrote :

Unmerged revisions

241. By Marc Abramowitz <email address hidden>

testrepository/setuptools_command.py: Add logging

to aid in debugging and testing.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'testrepository/setuptools_command.py'
2--- testrepository/setuptools_command.py 2013-07-10 11:50:45 +0000
3+++ testrepository/setuptools_command.py 2014-04-20 06:28:46 +0000
4@@ -27,11 +27,16 @@
5
6 from distutils import cmd
7 import distutils.errors
8+import logging
9 import os
10 import sys
11
12 from testrepository import commands
13
14+logger = logging.getLogger(__name__)
15+logging.basicConfig(level=logging.DEBUG)
16+logger.info("imported")
17+
18
19 class Testr(cmd.Command):
20
21@@ -48,16 +53,19 @@
22 boolean_options = ['coverage', 'slowest']
23
24 def _run_testr(self, *args):
25+ logger.info("_run_testr called")
26 return commands.run_argv([sys.argv[0]] + list(args),
27 sys.stdin, sys.stdout, sys.stderr)
28
29 def initialize_options(self):
30+ logger.info("initialize_options called")
31 self.testr_args = None
32 self.coverage = None
33 self.omit = ""
34 self.slowest = None
35
36 def finalize_options(self):
37+ logger.info("finalize_options called")
38 if self.testr_args is None:
39 self.testr_args = []
40 else:
41@@ -67,6 +75,7 @@
42
43 def run(self):
44 """Set up testr repo, then run testr"""
45+ logger.info("run called")
46 if not os.path.isdir(".testrepository"):
47 self._run_testr("init")
48
49@@ -83,12 +92,15 @@
50 self._coverage_after()
51
52 def _coverage_before(self):
53+ logger.info("_coverage_before called")
54 package = self.distribution.get_name()
55 if package.startswith('python-'):
56 package = package[7:]
57 options = "--source %s --parallel-mode" % package
58 os.environ['PYTHON'] = ("coverage run %s" % options)
59+ logger.info("os.environ['PYTHON'] = %r", os.environ['PYTHON'])
60
61 def _coverage_after(self):
62+ logger.info("_coverage_after called")
63 os.system("coverage combine")
64 os.system("coverage html -d ./cover %s" % self.omit)

Subscribers

People subscribed via source and target branches