Ejemplo n.º 1
0
    def test_is_ignored_real_location_skip_special(self):
        test_file_location = self.get_test_loc('ignore/vcs.tgz')
        assert not ignore.is_ignored(test_file_location, {'asdf': 'skip'}, {}, skip_special=True)
        assert not ignore.is_ignored(test_file_location, {'asdf': 'skip'}, {}, skip_special=False)

        assert not ignore.is_ignored(test_file_location, {'asdf': 'skip'}, {}, skip_special=True)
        assert not ignore.is_ignored(test_file_location, {'asdf': 'skip'}, {}, skip_special=False)
Ejemplo n.º 2
0
    def test_is_ignored_special_files_skip_special(self):
        test_fifo = self.get_temp_file()
        os.mkfifo(test_fifo)
        assert ignore.is_ignored(test_fifo, {'asdf': 'skip'}, {}, skip_special=True)
        assert not ignore.is_ignored(test_fifo, {'asdf': 'skip'}, {}, skip_special=False)

        test_symlink = self.get_temp_file()
        test_file_location = self.get_test_loc('ignore/vcs.tgz')
        os.symlink(test_file_location, test_symlink)
        assert ignore.is_ignored(test_symlink, {'asdf': 'skip'}, {}, skip_special=True)
        assert not ignore.is_ignored(test_symlink, {'asdf': 'skip'}, {}, skip_special=False)
Ejemplo n.º 3
0
    def check_default(self, test_dir, expected_message):
        for top, dirs, files in os.walk(test_dir, topdown=True):
            not_ignored = []
            for d in dirs:
                p = os.path.join(top, d)
                ign = ignore.is_ignored(p, ignore.default_ignores, {})
                if not ign:
                    not_ignored.append(d)
            dirs[:] = not_ignored

            for f in files:
                p = os.path.join(top, f)
                ign = ignore.is_ignored(p, ignore.default_ignores, {})
                if ign:
                    assert ign == expected_message
Ejemplo n.º 4
0
    def check_default(self, test_dir, expected_message):
        for top, dirs, files in os.walk(test_dir, topdown=True):
            not_ignored = []
            for d in dirs:
                p = os.path.join(top, d)
                ign = ignore.is_ignored(p, ignore.default_ignores, {})
                if not ign:
                    not_ignored.append(d)
            dirs[:] = not_ignored

            for f in files:
                p = os.path.join(top, f)
                ign = ignore.is_ignored(p, ignore.default_ignores, {})
                if ign:
                    assert ign == expected_message
Ejemplo n.º 5
0
    def test_default_ignores_mac1(self):
        test_dir = self.extract_test_tar('ignore/excludes/mac.tgz')
        test_base = os.path.join(test_dir, 'mac')

        test = os.path.join(test_base, '__MACOSX')
        result = ignore.is_ignored(test, ignore.default_ignores, {})
        assert 'Default ignore: MacOSX artifact' == result
Ejemplo n.º 6
0
    def test_is_ignored_default_ignores_mac2(self):
        test_dir = self.extract_test_tar('ignore/excludes/mac.tgz')
        test_base = os.path.join(test_dir, 'mac')

        test = os.path.join(test_base, '__MACOSX/comp_match/smallrepo/._jetty_1.0_index.csv')
        result = ignore.is_ignored(test, ignore.default_ignores, {})
        assert 'Default ignore: MacOSX artifact' == result
Ejemplo n.º 7
0
    def test_default_ignores_mac2(self):
        test_dir = self.extract_test_tar('ignore/excludes/mac.tgz')
        test_base = os.path.join(test_dir, 'mac')

        test = os.path.join(test_base, '__MACOSX/comp_match/smallrepo/._jetty_1.0_index.csv')
        result = ignore.is_ignored(test, ignore.default_ignores, {})
        assert 'Default ignore: MacOSX artifact' == result
Ejemplo n.º 8
0
    def test_default_ignores_eclipse4(self):
        test_dir = self.extract_test_tar('ignore/excludes/eclipse.tgz')
        test_base  = os.path.join(test_dir, 'eclipse')

        test = os.path.join(test_base, '.pydevproject')
        result = ignore.is_ignored(test, ignore.default_ignores, {})
        assert 'Default ignore: Eclipse IDE artifact' == result
Ejemplo n.º 9
0
 def test_ignore_glob_file(self):
     test = (
         'common/src/test/sample.txt',
         {'*.txt': 'test ignore'},
         {}
     )
     assert is_ignored(*test)
Ejemplo n.º 10
0
 def test_ignore_single_path(self):
     test = (
         'common/src/test/sample.txt',
         {'src/test/sample.txt': 'test ignore'},
         {}
     )
     assert is_ignored(*test)
 def test_ignore_single_path(self):
     test = (
         'common/src/test/sample.txt',
         {'src/test/sample.txt': 'test ignore'},
         {}
     )
     assert is_ignored(*test)
Ejemplo n.º 12
0
    def test_default_ignores_eclipse4(self):
        test_dir = self.extract_test_tar('ignore/excludes/eclipse.tgz')
        test_base = os.path.join(test_dir, 'eclipse')

        test = os.path.join(test_base, '.pydevproject')
        result = ignore.is_ignored(test, ignore.default_ignores, {})
        assert 'Default ignore: Eclipse IDE artifact' == result
Ejemplo n.º 13
0
    def test_default_ignores_mac1(self):
        test_dir = self.extract_test_tar('ignore/excludes/mac.tgz')
        test_base = os.path.join(test_dir, 'mac')

        test = os.path.join(test_base, '__MACOSX')
        result = ignore.is_ignored(test, ignore.default_ignores, {})
        assert 'Default ignore: MacOSX artifact' == result
 def test_ignore_glob_file(self):
     test = (
         'common/src/test/sample.txt',
         {'*.txt': 'test ignore'},
         {}
     )
     assert is_ignored(*test)
Ejemplo n.º 15
0
    def test_skip_vcs_files_and_dirs(self):
        test_dir = self.extract_test_tar('ignore/vcs.tgz')
        result = []
        for top, dirs, files in os.walk(test_dir, topdown=True):
            not_ignored = []
            for d in dirs:
                p = os.path.join(top, d)
                ign = ignore.is_ignored(p, ignore.default_ignores, {})
                tp = fileutils.as_posixpath(p.replace(test_dir, ''))
                result.append((
                    tp,
                    ign,
                ))
                if not ign:
                    not_ignored.append(d)

            # skip ignored things
            dirs[:] = not_ignored

            for f in files:
                p = os.path.join(top, f)
                ign = ignore.is_ignored(p, ignore.default_ignores, {})
                tp = fileutils.as_posixpath(p.replace(test_dir, ''))
                result.append((
                    tp,
                    ign,
                ))

        expected = [
            ('/vcs', False),
            ('/vcs/.bzr', 'Default ignore: Bazaar artifact'),
            ('/vcs/.git', 'Default ignore: Git artifact'),
            ('/vcs/.hg', 'Default ignore: Mercurial artifact'),
            ('/vcs/.repo', 'Default ignore: Multiple Git repository artifact'),
            ('/vcs/.svn', 'Default ignore: SVN artifact'),
            ('/vcs/CVS', 'Default ignore: CVS artifact'),
            ('/vcs/_darcs', 'Default ignore: Darcs artifact'),
            ('/vcs/_MTN', 'Default ignore: Monotone artifact'),
            ('/vcs/.bzrignore', 'Default ignore: Bazaar config artifact'),
            ('/vcs/.cvsignore', 'Default ignore: CVS config artifact'),
            ('/vcs/.gitignore', 'Default ignore: Git config artifact'),
            ('/vcs/.hgignore', 'Default ignore: Mercurial config artifact'),
            ('/vcs/.svnignore', 'Default ignore: SVN config artifact'),
            ('/vcs/vssver.scc', 'Default ignore: Visual Source Safe artifact'),
        ]
        assert sorted(expected) == sorted(result)
Ejemplo n.º 16
0
    def test_default_ignores_mac5(self):
        test_dir = self.extract_test_tar('ignore/excludes/mac.tgz')
        test_base = os.path.join(test_dir, 'mac')

        test = os.path.join(test_base, '._.DS_Store')
        result = ignore.is_ignored(test, ignore.default_ignores, {})
        # this is really weird as a behavior
        assert 'Default ignore: MacOSX artifact' == result
Ejemplo n.º 17
0
    def test_is_ignored_skip_vcs_files_and_dirs(self):
        test_dir = self.extract_test_tar('ignore/vcs.tgz')
        result = []
        for top, dirs, files in os.walk(test_dir, topdown=True):
            not_ignored = []
            for d in dirs:
                p = os.path.join(top, d)
                ign = ignore.is_ignored(p, ignore.default_ignores, {})
                tp = fileutils.as_posixpath(p.replace(test_dir, ''))
                result.append((
                    tp,
                    ign,
                ))
                if not ign:
                    not_ignored.append(d)

            # skip ignored things
            dirs[:] = not_ignored

            for f in files:
                p = os.path.join(top, f)
                ign = ignore.is_ignored(p, ignore.default_ignores, {})
                tp = fileutils.as_posixpath(p.replace(test_dir, ''))
                result.append((
                    tp,
                    ign,
                ))

        expected = [
            ('/vcs', False),
            ('/vcs/.bzr', True),
            ('/vcs/.git', True),
            ('/vcs/.hg', True),
            ('/vcs/.repo', True),
            ('/vcs/.svn', True),
            ('/vcs/CVS', True),
            ('/vcs/_darcs', True),
            ('/vcs/_MTN', True),
            ('/vcs/.bzrignore', True),
            ('/vcs/.cvsignore', True),
            ('/vcs/.gitignore', True),
            ('/vcs/.hgignore', True),
            ('/vcs/.svnignore', True),
            ('/vcs/vssver.scc', True),
        ]
        assert sorted(expected) == sorted(result)
Ejemplo n.º 18
0
    def test_default_ignores_mac5(self):
        test_dir = self.extract_test_tar('ignore/excludes/mac.tgz')
        test_base = os.path.join(test_dir, 'mac')

        test = os.path.join(test_base, '._.DS_Store')
        result = ignore.is_ignored(test, ignore.default_ignores, {})
        # this is really weird as a behavior
        assert 'Default ignore: MacOSX artifact' == result
Ejemplo n.º 19
0
def should_extract(location, kinds, ignore_pattern=()):
    """
    Return True if this location should be extracted based on the provided
    kinds
    """
    location = os.path.abspath(os.path.expanduser(location))
    ignore_pattern = {extension : 'User ignore: Supplied by --ignore' for extension in ignore_pattern}
    should_ignore = is_ignored(location, ignore_pattern)
    if get_extractor(location, kinds) and not should_ignore:
        return True
Ejemplo n.º 20
0
    def test_skip_vcs_files_and_dirs(self):
        test_dir = self.extract_test_tar('ignore/vcs.tgz')
        result = []
        for top, dirs, files in os.walk(test_dir, topdown=True):
            not_ignored = []
            for d in dirs:
                p = os.path.join(top, d)
                ign = ignore.is_ignored(p, ignore.default_ignores, {})
                tp = fileutils.as_posixpath(p.replace(test_dir, ''))
                result.append((tp, ign,))
                if not ign:
                    not_ignored.append(d)

            # skip ignored things
            dirs[:] = not_ignored

            for f in files:
                p = os.path.join(top, f)
                ign = ignore.is_ignored(p, ignore.default_ignores, {})
                tp = fileutils.as_posixpath(p.replace(test_dir, ''))
                result.append((tp, ign,))

        expected = [
            ('/vcs', False),
            ('/vcs/.bzr', 'Default ignore: Bazaar artifact'),
            ('/vcs/.git', 'Default ignore: Git artifact'),
            ('/vcs/.hg', 'Default ignore: Mercurial artifact'),
            ('/vcs/.repo', 'Default ignore: Multiple Git repository artifact'),
            ('/vcs/.svn', 'Default ignore: SVN artifact'),
            ('/vcs/CVS', 'Default ignore: CVS artifact'),
            ('/vcs/_darcs', 'Default ignore: Darcs artifact'),
            ('/vcs/_MTN', 'Default ignore: Monotone artifact'),
            ('/vcs/.bzrignore', 'Default ignore: Bazaar config artifact'),
            ('/vcs/.cvsignore', 'Default ignore: CVS config artifact'),
            ('/vcs/.gitignore', 'Default ignore: Git config artifact'),
            ('/vcs/.hgignore', 'Default ignore: Mercurial config artifact'),
            ('/vcs/.svnignore', 'Default ignore: SVN config artifact'),
            ('/vcs/vssver.scc', 'Default ignore: Visual Source Safe artifact'),
        ]
        assert sorted(expected) == sorted(result)
Ejemplo n.º 21
0
 def test_default_ignores_msft(self):
     test_dir = self.extract_test_tar('ignore/excludes/msft-vs.tgz')
     test = os.path.join(test_dir, 'msft-vs/tst.sluo')
     result = ignore.is_ignored(test, ignore.default_ignores, {})
     assert 'Default ignore: Microsoft VS project artifact' == result
Ejemplo n.º 22
0
 def test_is_ignored_path_string_skip_special(self):
     test_path = '/test/path'
     assert ignore.is_ignored(test_path, {'asdf': 'skip'}, {}, skip_special=True)
     assert not ignore.is_ignored(test_path, {'asdf': 'skip'}, {}, skip_special=False)
Ejemplo n.º 23
0
    def test_is_ignored_default_ignores_eclipse3(self):
        test_dir = self.extract_test_tar('ignore/excludes/eclipse.tgz')
        test_base = os.path.join(test_dir, 'eclipse')

        test = os.path.join(test_base, '.project')
        assert ignore.is_ignored(test, ignore.default_ignores, {})
Ejemplo n.º 24
0
    def test_is_ignored_default_ignores_mac4(self):
        test_dir = self.extract_test_tar('ignore/excludes/mac.tgz')
        test_base = os.path.join(test_dir, 'mac')

        test = os.path.join(test_base, '.DS_Store/a')
        assert ignore.is_ignored(test, ignore.default_ignores, {})
Ejemplo n.º 25
0
 def test_default_ignores_msft(self):
     test_dir = self.extract_test_tar('ignore/excludes/msft-vs.tgz')
     test = os.path.join(test_dir, 'msft-vs/tst.sluo')
     result = ignore.is_ignored(test, ignore.default_ignores, {})
     assert 'Default ignore: Microsoft VS project artifact' == result