Exemplo n.º 1
0
    def test_non_existing_dir(self, stage):
        """Test copying to a non-existing directory."""

        with fs.working_dir(str(stage)):
            fs.copy_tree('source', 'dest/sub/directory')

            assert os.path.exists('dest/sub/directory/a/b/2')
Exemplo n.º 2
0
    def test_parent_dir(self, stage):
        """Test source as a parent directory of destination."""

        with fs.working_dir(str(stage)):
            match = 'Cannot copy ancestor directory'
            with pytest.raises(ValueError, match=match):
                fs.copy_tree('source', 'source/sub/directory')
Exemplo n.º 3
0
    def test_existing_dir(self, stage):
        """Test copying to an existing directory."""

        with fs.working_dir(str(stage)):
            fs.copy_tree('source', 'dest')

            assert os.path.exists('dest/a/b/2')
Exemplo n.º 4
0
    def test_symlinks_false(self, stage):
        """Test copying without symlink preservation."""

        with fs.working_dir(str(stage)):
            fs.copy_tree('source', 'dest', symlinks=False)

            assert os.path.exists('dest/2')
            assert not os.path.islink('dest/2')
Exemplo n.º 5
0
    def test_symlinks_false(self, stage):
        """Test copying without symlink preservation."""

        with fs.working_dir(str(stage)):
            fs.copy_tree('source', 'dest', symlinks=False)

            assert os.path.exists('dest/2')
            assert not os.path.islink('dest/2')
Exemplo n.º 6
0
    def test_glob_src(self, stage):
        """Test using a glob as the source."""

        with fs.working_dir(str(stage)):
            fs.copy_tree('source/g/*', 'dest')

            assert os.path.exists('dest/i/8')
            assert os.path.exists('dest/i/9')
            assert os.path.exists('dest/j/10')
Exemplo n.º 7
0
 def test_symlinks_true_ignore(self, stage):
     """Test copying when specifying relative paths that should be ignored
     """
     with fs.working_dir(str(stage)):
         ignore = lambda p: p in ['c/d/e', 'a']
         fs.copy_tree('source', 'dest', symlinks=True, ignore=ignore)
         assert not os.path.exists('dest/a')
         assert os.path.exists('dest/c/d')
         assert not os.path.exists('dest/c/d/e')
Exemplo n.º 8
0
 def test_symlinks_true_ignore(self, stage):
     """Test copying when specifying relative paths that should be ignored
     """
     with fs.working_dir(str(stage)):
         ignore = lambda p: p in ['c/d/e', 'a']
         fs.copy_tree('source', 'dest', symlinks=True, ignore=ignore)
         assert not os.path.exists('dest/a')
         assert os.path.exists('dest/c/d')
         assert not os.path.exists('dest/c/d/e')
Exemplo n.º 9
0
    def test_parent_dir(self, stage):
        """Test copying to from a parent directory."""

        # Make sure we get the right error if we try to copy a parent into
        # a descendent directory.
        with pytest.raises(ValueError, matches="Cannot copy"):
            with fs.working_dir(str(stage)):
                fs.copy_tree('source', 'source/sub/directory')

        # Only point with this check is to make sure we don't try to perform
        # the copy.
        with pytest.raises(IOError, matches="No such file or directory"):
            with fs.working_dir(str(stage)):
                fs.copy_tree('foo/ba', 'foo/bar')
Exemplo n.º 10
0
    def test_symlinks_true(self, stage):
        """Test copying with symlink preservation."""

        with fs.working_dir(str(stage)):
            fs.copy_tree('source', 'dest', symlinks=True)

            assert os.path.exists('dest/2')
            assert islink('dest/2')

            assert os.path.exists('dest/a/b2')
            with fs.working_dir('dest/a'):
                assert os.path.exists(os.readlink('b2'))

            assert (
                os.path.realpath('dest/f/2') == os.path.abspath('dest/a/b/2'))
            assert os.path.realpath('dest/2') == os.path.abspath('dest/1')
Exemplo n.º 11
0
    def test_symlinks_true(self, stage):
        """Test copying with symlink preservation."""

        with fs.working_dir(str(stage)):
            fs.copy_tree('source', 'dest', symlinks=True)

            assert os.path.exists('dest/2')
            assert os.path.islink('dest/2')

            assert os.path.exists('dest/a/b2')
            with fs.working_dir('dest/a'):
                assert os.path.exists(os.readlink('b2'))

            assert (os.path.realpath('dest/f/2') ==
                    os.path.abspath('dest/a/b/2'))
            assert os.path.realpath('dest/2') == os.path.abspath('dest/1')
Exemplo n.º 12
0
def test_read_old_results(mock_test_stage):
    """Take test data generated before the switch to full hash everywhere
    and make sure we can still read it in"""
    # Test data was generated with:
    #   spack install printing-package
    #   spack test run --alias printpkg printing-package

    test_data_src = os.path.join(spack.paths.test_path, 'data', 'test',
                                 'test_stage')

    # Copy the old test data into the mock stage directory
    copy_tree(test_data_src, mock_test_stage)

    # The find command should print info about the old test, under
    # the alias used at test generation time
    find_output = spack_test('find')
    assert 'printpkg' in find_output

    # The results command should still print the old test results
    results_output = spack_test('results')
    assert 'PASSED' in results_output
Exemplo n.º 13
0
    def test_non_existing_src(self, stage):
        """Test using a non-existing source."""

        with fs.working_dir(str(stage)):
            with pytest.raises(IOError, match='No such file or directory'):
                fs.copy_tree('source/none', 'dest')