Skip to content

Commit a7df0fc

Browse files
Fixed regression in "bug validate" and compilers caused by container -> container manager API migration (#156)
* tweaked BugManager.validate to use container manager for provisioning * temporary fix for compiling programs * version bump
1 parent 5430b92 commit a7df0fc

File tree

4 files changed

+23
-14
lines changed

4 files changed

+23
-14
lines changed

bugzoo/compiler/__init__.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,27 +112,32 @@ def __init__(self,
112112
self.__time_limit = time_limit
113113

114114
def __compile(self,
115+
manager_container,
115116
container: 'Container',
116117
command: str,
117118
verbose: bool
118119
) -> CompilationOutcome:
119120
# if a context isn't given, use the source directory of the bug
120121
context = self.__context if self.__context else container.bug.source_dir
121-
cmd_outcome = container.command(command,
122-
context=context,
123-
stderr=True)
122+
cmd_outcome = manager_container.command(container,
123+
command,
124+
context=context,
125+
stderr=True)
124126
return CompilationOutcome(cmd_outcome)
125127

128+
# TODO decouple!
126129
def compile(self,
130+
manager_container,
127131
container: 'Container',
128132
verbose: bool = False
129133
) -> CompilationOutcome:
130134
"""
131135
See `Compiler.compile`
132136
"""
133-
return self.__compile(container, self.__command, verbose)
137+
return self.__compile(manager_container, container, self.__command, verbose)
134138

135139
def compile_with_coverage_instrumentation(self,
140+
manager_container,
136141
container: 'Container',
137142
verbose: bool = False
138143
) -> CompilationOutcome:
@@ -144,7 +149,7 @@ def compile_with_coverage_instrumentation(self,
144149
else:
145150
cmd = self.__command
146151

147-
return self.__compile(container, cmd, verbose)
152+
return self.__compile(manager_container, container, cmd, verbose)
148153

149154

150155
class CatkinCompiler(SimpleCompiler):

bugzoo/mgr/bug.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def validate(self, bug: Bug, verbose: bool = True) -> bool:
136136
validated = True
137137
try:
138138
c = None
139-
c = bug.provision()
139+
c = self.__installation.containers.provision(bug)
140140

141141
# ensure we can compile the bug
142142
# TODO: check compilation status!
@@ -175,6 +175,6 @@ def validate(self, bug: Bug, verbose: bool = True) -> bool:
175175
# ensure that the container is destroyed!
176176
finally:
177177
if c:
178-
c.destroy()
178+
del self.__installation.containers[c.uid]
179179

180180
return validated

bugzoo/mgr/container.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ def coverage(self,
252252
extractor = language.coverage_extractor
253253
return extractor.coverage(self, container, tests)
254254

255+
# TODO decouple
255256
def compile(self,
256257
container: Container,
257258
verbose: bool = False
@@ -269,8 +270,9 @@ def compile(self,
269270
"""
270271
# TODO use container name
271272
bug = container.bug # self.__installation.bugs[container.bug]
272-
return bug.compiler.compile(container, verbose=verbose)
273+
return bug.compiler.compile(self, container, verbose=verbose)
273274

275+
# TODO decouple
274276
def compile_with_instrumentation(self,
275277
container: Container,
276278
verbose: bool = False
@@ -282,7 +284,8 @@ def compile_with_instrumentation(self,
282284
See: `Container.compile`
283285
"""
284286
bug = self.__installation.bugs[container.bug]
285-
return bug.compiler.compile_with_coverage_instrumentation(container,
287+
return bug.compiler.compile_with_coverage_instrumentation(self,
288+
container,
286289
verbose=verbose)
287290

288291
def copy_to(self,
@@ -335,10 +338,11 @@ def command(self,
335338
cmd = template_cmd.format(context, cmd)
336339

337340
# based on: https://github.com/roidelapluie/docker-py/commit/ead9ffa34193281967de8cc0d6e1c0dcbf50eda5
338-
response = self.__docker_client.api.exec_create(container.id,
339-
cmd,
340-
stdout=stdout,
341-
stderr=stderr)
341+
docker_client = self.__installation.docker
342+
response = docker_client.api.exec_create(container.id,
343+
cmd,
344+
stdout=stdout,
345+
stderr=stderr)
342346

343347
# blocking mode
344348
if block:

bugzoo/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.0.1'
1+
__version__ = '2.0.2'

0 commit comments

Comments
 (0)