Run tests as host user
testr writes files into the local dir, which is cool and works because of the bind mount - but if we don't run as the same UID as the executing user, then we'll write unreadable data into .testrepository.
This commit is contained in:
parent
7f1cf63a4e
commit
72c193e5e9
|
@ -116,6 +116,10 @@ class Runner(object):
|
|||
dockerfile.append("FROM %s" % image)
|
||||
try:
|
||||
tempd = tempfile.mkdtemp()
|
||||
dockerfile.append(
|
||||
"RUN groupadd -g %(gid)s %(user)s"
|
||||
" && useradd -d /src -g %(gid)s -u %(uid)s %(user)s" % dict(
|
||||
uid=os.getuid(), gid=os.getgid(), user=os.getlogin()))
|
||||
for add_file in commands.get_add_files():
|
||||
shutil.copy(add_file, os.path.join(tempd, add_file))
|
||||
dockerfile.append("ADD %s /dox/" % add_file)
|
||||
|
@ -131,7 +135,7 @@ class Runner(object):
|
|||
|
||||
def run_commands(self, command):
|
||||
self._docker_run(
|
||||
'--rm',
|
||||
'--rm', '--user=%s' % os.getlogin(),
|
||||
'-v', "%s:/src" % os.path.abspath('.'),
|
||||
'-w', '/src', self.test_image_name, *command)
|
||||
|
||||
|
|
Loading…
Reference in New Issue