@@ -168,14 +168,14 @@ def _impl(ctx):
168
168
# Commands to build the image targets and copy files.
169
169
commands_image1 = cd_cmd + [
170
170
("bazel --output_base=%s build " % host_outs_path1 ) + " " .join (build_targets ),
171
- ] + cp_cmds + [ "rm -rf %s" % host_outs_path1 ]
171
+ ] + cp_cmds
172
172
173
173
# Some deb package installations (e.g. openjdk-8-jdk) use timestamps
174
174
# during installation. Avoid bulding and reproducing a container at the
175
175
# same start time by sleeping 10 secs before rebuilding.
176
176
commands_image2 = ["sleep 10" ] + cd_cmd + [
177
177
("bazel --output_base=%s build " % host_outs_path2 ) + " " .join (build_targets ),
178
- ] + cp_cmds + [ "rm -rf %s" % host_outs_path2 ]
178
+ ] + cp_cmds
179
179
180
180
# Mount the docker.sock inside the running container to enable docker
181
181
# sibling, which is needed when builing the test image itself requires
@@ -217,6 +217,14 @@ def _impl(ctx):
217
217
script_file = ctx .actions .declare_file (name + ".build2" ),
218
218
)
219
219
220
+ # Delete intermediate outputs
221
+ delete_out = ctx .actions .declare_file (name + "_delete_out" )
222
+ ctx .actions .run_shell (
223
+ inputs = [bazel_out1 , bazel_out2 , img1_outs , img2_outs ],
224
+ outputs = [delete_out ],
225
+ command = " rm -rf %s && rm -rf %s | tee %s" % (host_outs_path1 , host_outs_path2 , delete_out .path ),
226
+ )
227
+
220
228
# Expand template to run the image comparison test.
221
229
type_args = ["--type=" + type_arg for type_arg in ctx .attr .container_diff_args ]
222
230
diff_tool_exec = ctx .executable ._container_diff_tool
@@ -241,6 +249,7 @@ def _impl(ctx):
241
249
files = [
242
250
bazel_out1 ,
243
251
bazel_out2 ,
252
+ delete_out ,
244
253
diff_tool_exec ,
245
254
img1_outs ,
246
255
img2_outs ,
0 commit comments