Skip to content

Commit

Permalink
Fix test for subdirectories
Browse files Browse the repository at this point in the history
  • Loading branch information
avirshup committed Mar 6, 2018
1 parent 812da57 commit 3a5c1b2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pyccc/files/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,13 @@ def put(self, destination):
members = []
for tarinfo in tf:
# Get only files under the directory `self.dirname`
pathsplit = os.path.split(tarinfo.path)
pathsplit = os.path.normpath(tarinfo.path).split(os.sep)
if pathsplit[0] not in valid_paths:
print('WARNING: skipped file "%s" in archive; not in directory "%s"' %
(tarinfo.path, self.dirname))
continue
if len(pathsplit) == 1:
continue
tarinfo.name = os.path.join(*pathsplit[1:])
members.append(tarinfo)

Expand Down
15 changes: 15 additions & 0 deletions pyccc/tests/test_dir_refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,18 @@ def test_put_directory_reference_with_renaming(request, fixturename, tmpdir, rel
assert not mismatch
assert not errors


def test_get_directory_with_subdirs(tmpdir):
engine = pyccc.Docker()

cmd = ("mkdir -p /opt/blah/fugu && echo a > /opt/blah/a"
" && echo b > /opt/blah/b && echo fish > /opt/blah/fugu/fish")

job = engine.launch(image='alpine',
workingdir='/test',
command=cmd)
job.wait()
outdir = job.get_directory('/opt/blah')
outdir.put(tmpdir)
for path in ['a', 'b', 'fugu/fish']:
assert os.path.exists(os.path.join(tmpdir, 'blah', path))

0 comments on commit 3a5c1b2

Please sign in to comment.