Add option to keep test container

Adds -k/--keep options to allow the user to keep the test container
around instead of deleting it after the given command completes.

Change-Id: If7063c1a93436f4b477adb9b2c869d4cd027205a
This commit is contained in:
David Shrewsbury 2014-09-09 16:34:20 -04:00
parent 92fad2c7a7
commit be61a19eff
2 changed files with 13 additions and 5 deletions

View File

@ -70,6 +70,9 @@ def parse_args():
help='User to run the container to '
'format is user:uid:gid, with boot2docker use '
'docker:1000:10 (default to your current user)')
parser.add_argument('-k', '--keep', dest='keep_image', default=False,
action='store_true',
help="Keep test container after command finishes")
return parser.parse_args()

View File

@ -155,11 +155,16 @@ class Runner(object):
shutil.rmtree(tempd)
def run_commands(self, command):
self._docker_run(
'--privileged=true',
'--rm', '--user=%s' % self.user_map['username'],
'-v', "%s:/src" % os.path.abspath('.'),
'-w', '/src', self.test_image_name, *command)
docker_args = ['--privileged=true',
'--user=%s' % self.user_map['username'],
'-v', "%s:/src" % os.path.abspath('.'),
'-w', '/src',
self.test_image_name]
if not self.args.keep_image:
docker_args.append('--rm')
for c in command:
docker_args.append(c)
self._docker_run(*docker_args)
def have_base_image(self):
if self.args.rebuild_all: