From 36ba7e2c1ee039d7dadc6fedb858780d0d33b644 Mon Sep 17 00:00:00 2001 From: Shahwat Dalal Date: Tue, 30 Jul 2019 17:49:47 +0100 Subject: tests/workspaces: Test edge case when linking files to RO directory When we open a workspace, we are linking the sources to the directory specified. As such testing that we are able to open a workspace on a read-only directory should show that we are able to link files to a RO directory when we are staging complex sources (eg. Docker source). --- tests/integration/workspace.py | 14 ++++++++++++++ tests/sources/tar.py | 8 ++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/integration/workspace.py b/tests/integration/workspace.py index fe5e76ea3..9e74e574f 100644 --- a/tests/integration/workspace.py +++ b/tests/integration/workspace.py @@ -36,6 +36,20 @@ def test_workspace_mount(cli, datafiles): assert os.path.exists(os.path.join(cli.directory, 'workspace')) +@pytest.mark.datafiles(DATA_DIR) +def test_workspace_mount_on_read_only_directory(cli, datafiles): + project = str(datafiles) + workspace = os.path.join(cli.directory, 'workspace') + os.makedirs(workspace) + element_name = 'workspace/workspace-mount.bst' + + # make directory RO + os.chmod(workspace, 0o555) + + res = cli.run(project=project, args=['workspace', 'open', '--directory', workspace, element_name]) + assert res.exit_code == 0 + + @pytest.mark.datafiles(DATA_DIR) @pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox') @pytest.mark.xfail(HAVE_SANDBOX == 'buildbox', reason='Not working with BuildBox', strict=True) diff --git a/tests/sources/tar.py b/tests/sources/tar.py index 9789a4484..fac6f3f8b 100644 --- a/tests/sources/tar.py +++ b/tests/sources/tar.py @@ -279,10 +279,10 @@ def test_stage_default_basedir_lzip(cli, tmpdir, datafiles, srcdir): # Test that tarballs with read-only files work # a - contains read-only files in a writable directory # b - root directory has read-only permission -# c - contains one file that has no read nor write permissions +# c - contains one file that has no read nor write permissions. Base-dir set to '' to extract root of tarball @pytest.mark.datafiles(os.path.join(DATA_DIR, 'read-only')) -@pytest.mark.parametrize("tar_name", ["a", "b", "c"]) -def test_read_only_dir(cli, tmpdir, datafiles, tar_name): +@pytest.mark.parametrize("tar_name, base_dir", [("a", "*"), ("b", '*'), ("c", '')]) +def test_read_only_dir(cli, tmpdir, datafiles, tar_name, base_dir): try: project = str(datafiles) generate_project(project, tmpdir) @@ -297,7 +297,7 @@ def test_read_only_dir(cli, tmpdir, datafiles, tar_name): 'kind': 'tar', 'url': 'tmpdir:/{}'.format(tar_file), 'ref': 'foo', - 'base-dir': '' + 'base-dir': base_dir } ] }, bst_path) -- cgit v1.2.1