diff options
author | Googler <noreply@google.com> | 2018-07-27 09:17:45 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-07-27 09:18:53 -0700 |
commit | 55dc53f441847bbfc9abe2ef65696fc722e7cfec (patch) | |
tree | 97def244151aa0b011ea48e1de0287ec9cb72325 /tools/build_defs/pkg/archive_test.py | |
parent | aa761aec0554de2569d5eb839a8c2ff652f79af1 (diff) |
Adding option to change the root directory name in build_tar.py and archive.py.
This is required to support Windows Docker image creation.
RELNOTES: None
PiperOrigin-RevId: 206326316
Diffstat (limited to 'tools/build_defs/pkg/archive_test.py')
-rw-r--r-- | tools/build_defs/pkg/archive_test.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/build_defs/pkg/archive_test.py b/tools/build_defs/pkg/archive_test.py index 5aa64079c3..2c52fbd423 100644 --- a/tools/build_defs/pkg/archive_test.py +++ b/tools/build_defs/pkg/archive_test.py @@ -295,5 +295,39 @@ class TarFileWriterTest(unittest.TestCase): ] self.assertTarFileContent(self.tempfile, content) + def testChangingRootDirectory(self): + with archive.TarFileWriter(self.tempfile, root_directory="root") as f: + f.add_file("d", tarfile.DIRTYPE) + f.add_file("d/f") + + f.add_file("a", tarfile.DIRTYPE) + f.add_file("a/b", tarfile.DIRTYPE) + f.add_file("a/b", tarfile.DIRTYPE) + f.add_file("a/b/", tarfile.DIRTYPE) + f.add_file("a/b/c/f") + + f.add_file("x/y/f") + f.add_file("x", tarfile.DIRTYPE) + content = [ + {"name": "root", + "mode": 0o755}, + {"name": "root/d", + "mode": 0o755}, + {"name": "root/d/f"}, + {"name": "root/a", + "mode": 0o755}, + {"name": "root/a/b", + "mode": 0o755}, + {"name": "root/a/b/c", + "mode": 0o755}, + {"name": "root/a/b/c/f"}, + {"name": "root/x", + "mode": 0o755}, + {"name": "root/x/y", + "mode": 0o755}, + {"name": "root/x/y/f"}, + ] + self.assertTarFileContent(self.tempfile, content) + if __name__ == "__main__": unittest.main() |