diff options
author | Shahwat Dalal <sdalal29@bloomberg.net> | 2019-07-02 12:53:54 +0100 |
---|---|---|
committer | Shahwat Dalal <sdalal29@bloomberg.net> | 2019-07-04 10:48:45 +0100 |
commit | 438ee733d67dbde09718fe45271628763b27b8e1 (patch) | |
tree | acda735d6311dbf77e3b567801158bbf2c370dd4 /tests/sources | |
parent | 1be4a7f1ea65af2f8ee6391a01a14dc685f5be26 (diff) | |
download | buildstream-438ee733d67dbde09718fe45271628763b27b8e1.tar.gz |
utils.py: Add write permission to root path in _force_rmtreeshashwatdalal/tar-file-extraction
This is needed in the case where the temp directory permissions
are changed between creation and deletion.
Diffstat (limited to 'tests/sources')
-rw-r--r-- | tests/sources/tar.py | 25 | ||||
-rw-r--r-- | tests/sources/tar/read-only/content/b.tar.gz | bin | 0 -> 148 bytes |
2 files changed, 21 insertions, 4 deletions
diff --git a/tests/sources/tar.py b/tests/sources/tar.py index 07108ccbb..8d409b512 100644 --- a/tests/sources/tar.py +++ b/tests/sources/tar.py @@ -276,21 +276,38 @@ def test_stage_default_basedir_lzip(cli, tmpdir, datafiles, srcdir): assert checkout_contents == original_contents -# Test that a tarball that contains a read only dir works +# Test that tarballs with read-only files work +# a - contains read-only files in a writable directory +# b - root directory has read-only permission @pytest.mark.datafiles(os.path.join(DATA_DIR, 'read-only')) -def test_read_only_dir(cli, tmpdir, datafiles): +@pytest.mark.parametrize("tar_name", ["a", "b"]) +def test_read_only_dir(cli, tmpdir, datafiles, tar_name): try: project = str(datafiles) generate_project(project, tmpdir) + bst_path = os.path.join(project, "target.bst") + tar_file = "{}.tar.gz".format(tar_name) + + _yaml.dump({ + 'kind': 'import', + 'sources': [ + { + 'kind': 'tar', + 'url': 'tmpdir:/{}'.format(tar_file), + 'ref': 'foo' + } + ] + }, bst_path) + # Get the tarball in tests/sources/tar/read-only/content # # NOTE that we need to do this because tarfile.open and tar.add() # are packing the tar up with writeable files and dirs - tarball = os.path.join(str(datafiles), 'content', 'a.tar.gz') + tarball = os.path.join(str(datafiles), 'content', tar_file) if not os.path.exists(tarball): raise FileNotFoundError('{} does not exist'.format(tarball)) - copyfile(tarball, os.path.join(str(tmpdir), 'a.tar.gz')) + copyfile(tarball, os.path.join(str(tmpdir), tar_file)) # Because this test can potentially leave directories behind # which are difficult to remove, ask buildstream to use diff --git a/tests/sources/tar/read-only/content/b.tar.gz b/tests/sources/tar/read-only/content/b.tar.gz Binary files differnew file mode 100644 index 000000000..79fd1e864 --- /dev/null +++ b/tests/sources/tar/read-only/content/b.tar.gz |