Skip to content

Commit 1b7e55e

Browse files
Added instrument parameter to coverage methods (#224)
* added rebuild argument to client container coverage method * added rebuild arg to server * implemented instrument flag in container coverage method
1 parent cbdf698 commit 1b7e55e

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

bugzoo/client/container.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,23 @@ def test(self,
182182
self.__api.handle_erroneous_response(r)
183183

184184
def coverage(self,
185-
container: Container
185+
container: Container,
186+
*,
187+
instrument: bool = True
186188
) -> TestSuiteCoverage:
189+
"""
190+
Computes complete test suite coverage for a given container.
191+
192+
Parameters:
193+
container: the container for which coverage should be computed.
194+
rebuild: if set to True, the program will be rebuilt before
195+
coverage is computed.
196+
"""
187197
uid = container.uid
188198
logger.info("Fetching coverage information for container: %s",
189199
uid)
190-
r = self.__api.post('containers/{}/coverage'.format(uid))
200+
r = self.__api.post('containers/{}/coverage'.format(uid),
201+
params={'instrument': instrument})
191202
if r.status_code == 200:
192203
jsn = r.json()
193204
coverage = TestSuiteCoverage.from_dict(jsn) # type: ignore

bugzoo/mgr/container.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ def coverage(self,
340340
container: Container,
341341
tests: Optional[List[TestCase]] = None,
342342
files_to_instrument: List[str] = None,
343+
*,
344+
instrument: bool = True
343345
) -> TestSuiteCoverage:
344346
"""
345347
Computes line coverage information over a provided set of tests for
@@ -348,7 +350,8 @@ def coverage(self,
348350
mgr = self.__installation.coverage
349351
return mgr.coverage(container,
350352
tests,
351-
files_to_instrument=files_to_instrument)
353+
files_to_instrument=files_to_instrument,
354+
instrument=True)
352355

353356
def execute(self,
354357
container: Container,

bugzoo/mgr/coverage.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ def coverage(self,
135135
container: Container,
136136
tests: Optional[List[TestCase]] = None,
137137
files_to_instrument: List[str] = None,
138+
*,
139+
instrument: bool = True
138140
) -> TestSuiteCoverage:
139141
"""
140142
Uses a provided container to compute line coverage information for a
@@ -149,8 +151,9 @@ def coverage(self,
149151
_tests = tests
150152

151153
try:
152-
self.instrument(container,
153-
files_to_instrument=files_to_instrument)
154+
if instrument:
155+
self.instrument(container,
156+
files_to_instrument=files_to_instrument)
154157
except Exception:
155158
raise FailedToComputeCoverage("failed to instrument container.")
156159

bugzoo/server/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,13 @@ def coverage_container(id_container: str):
227227
except KeyError:
228228
return BugNotFound(container.bug), 500
229229

230+
instrument = \
231+
flask.request.args.get('instrument', 'True').lower() == 'yes'
232+
230233
try:
231-
coverage = daemon.containers.coverage(container)
234+
# FIXME implement
235+
coverage = daemon.containers.coverage(container,
236+
instrument=instrument)
232237
except Exception as err:
233238
logger.exception("failed to compute coverage for container [%s]: %s",
234239
id_container, err)

0 commit comments

Comments
 (0)