Skip to content

Commit 11a73e8

Browse files
author
ocaisa
authored
Merge pull request #2480 from boegel/containerize_x
fix running --containerize --container-build-image with --extended-dry-run
2 parents d74c2e2 + b6e107a commit 11a73e8

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

easybuild/tools/containers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def check_singularity():
257257
path_to_singularity_cmd = which('singularity')
258258
if path_to_singularity_cmd:
259259
print_msg("Singularity tool found at %s" % path_to_singularity_cmd)
260-
out, ec = run_cmd("singularity --version", simple=False, trace=False)
260+
out, ec = run_cmd("singularity --version", simple=False, trace=False, force_in_dry_run=True)
261261
if ec:
262262
raise EasyBuildError("Failed to determine Singularity version: %s" % out)
263263
else:

test/framework/containers.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@
4444
echo "2.4.0"
4545
else
4646
echo "singularity was called with arguments: $@"
47+
# actually create image file using 'touch'
48+
echo "$@"
49+
echo $#
50+
if [[ $# -eq 3 ]]; then
51+
img=$2
52+
elif [[ $# -eq 4 ]]; then
53+
img=$3
54+
else
55+
echo "Don't know how to extract container image location" >&2
56+
exit 1
57+
fi
58+
touch $img
4759
fi
4860
"""
4961

@@ -222,6 +234,8 @@ def test_end2end_singularity_image(self):
222234
]
223235
self.check_regexs(regexs, stdout)
224236

237+
self.assertTrue(os.path.exists(os.path.join(containerpath, 'toy-0.0.simg')))
238+
225239
remove_file(os.path.join(containerpath, 'Singularity.toy-0.0'))
226240

227241
# check use of --container-image-format & --container-image-name
@@ -236,11 +250,12 @@ def test_end2end_singularity_image(self):
236250
regexs[-1] = "^== Singularity image created at %s/containers/foo-bar\.img$" % self.test_prefix
237251
self.check_regexs(regexs, stdout)
238252

253+
cont_img = os.path.join(containerpath, 'foo-bar.img')
254+
self.assertTrue(os.path.exists(cont_img))
255+
239256
remove_file(os.path.join(containerpath, 'Singularity.foo-bar'))
240257

241258
# test again with container image already existing
242-
cont_img = os.path.join(containerpath, 'foo-bar.img')
243-
write_file(cont_img, '')
244259

245260
error_pattern = "Container image already exists at %s, not overwriting it without --force" % cont_img
246261
self.mock_stdout(True)
@@ -254,6 +269,13 @@ def test_end2end_singularity_image(self):
254269
"WARNING: overwriting existing container image at %s due to --force" % cont_img,
255270
])
256271
self.check_regexs(regexs, stdout)
272+
self.assertTrue(os.path.exists(cont_img))
273+
274+
# also check behaviour under --extended-dry-run
275+
args.append('--extended-dry-run')
276+
stdout, stderr = self.run_main(args)
277+
self.assertFalse(stderr)
278+
self.check_regexs(regexs, stdout)
257279

258280

259281
def suite():

0 commit comments

Comments
 (0)