2
2
import os
3
3
import sys
4
4
5
+ from docker .errors import ImageNotFound
6
+
5
7
from .infrastructure import (
6
8
ContainerUtils ,
7
9
DockerUtils ,
@@ -22,26 +24,28 @@ def test():
22
24
if len (sys .argv ) > 1 and sys .argv [1 ].strip ("-" ) not in ["h" , "help" ]:
23
25
# Verify that the specified container image exists
24
26
tag = sys .argv [1 ]
25
- image = GlobalConfiguration .resolveTag (
27
+ image_name = GlobalConfiguration .resolveTag (
26
28
"ue4-full:{}" .format (tag ) if ":" not in tag else tag
27
29
)
28
- if not DockerUtils .exists (image ):
30
+ try :
31
+ image = client .images .get (image_name )
32
+ except ImageNotFound :
29
33
logger .error (
30
34
'Error: the specified container image "{}" does not exist.' .format (
31
- image
35
+ image_name
32
36
)
33
37
)
34
38
sys .exit (1 )
35
39
36
40
# Use process isolation mode when testing Windows containers, since running Hyper-V containers don't currently support manipulating the filesystem
37
- platform = ImageUtils . image_platform ( client , image )
41
+ platform = image . attrs [ "Os" ]
38
42
isolation = "process" if platform == "windows" else None
39
43
40
44
# Start a container to run our tests in, automatically stopping and removing the container when we finish
41
45
logger .action (
42
- 'Starting a container using the "{}" image...' .format (image ), False
46
+ 'Starting a container using the "{}" image...' .format (image_name ), False
43
47
)
44
- container = ContainerUtils .start_for_exec (client , image , isolation = isolation )
48
+ container = ContainerUtils .start_for_exec (client , image_name , isolation = isolation )
45
49
with ContainerUtils .automatically_stop (container ):
46
50
# Create the workspace directory in the container
47
51
workspaceDir = ContainerUtils .workspace_dir (container )
0 commit comments