예제 #1
0
 def test_bad_location(self):
     bii_ignore = BiiIgnore.defaults()
     save(os.path.join(self.folder, 'User/mybadFile.cpp'), '')
     _ = walk_bii_folder(self.folder, bii_ignore, self.biiout)
     # Check that the system detected misplaced file
     self.assertIn("WARN: User/mybadFile.cpp is misplaced",
                   str(self.biiout))
예제 #2
0
 def test_accept(self):
     ig = BiiIgnore.defaults()
     self.assertFalse(ig.ignored('path/file.patata'))
     self.assertFalse(ig.ignored(CellName('path/to/file.h')))
     self.assertFalse(ig.ignored(CellName('path/to.to/file.h')))
     self.assertFalse(ig.ignored(CellName('file.cpp')))
     self.assertFalse(ig.ignored(CellName('file.inl')))
     self.assertFalse(ig.ignored(CellName('file.ipp')))
     self.assertFalse(ig.ignored(CellName('Dense')))
예제 #3
0
 def test_accept(self):
     ig = BiiIgnore.defaults()
     self.assertFalse(ig.ignored('path/file.patata'))
     self.assertFalse(ig.ignored(CellName('path/to/file.h')))
     self.assertFalse(ig.ignored(CellName('path/to.to/file.h')))
     self.assertFalse(ig.ignored(CellName('file.cpp')))
     self.assertFalse(ig.ignored(CellName('file.inl')))
     self.assertFalse(ig.ignored(CellName('file.ipp')))
     self.assertFalse(ig.ignored(CellName('Dense')))
예제 #4
0
    def test_src_default_accepted(self):
        bii_ignore = BiiIgnore.defaults()
        save(os.path.join(self.folder, 'User/Block/myFile.cpp'), '')

        src_files = walk_bii_folder(self.folder, bii_ignore, self.biiout)
        self.assertEqual(['User/Block/myFile.cpp'], src_files.keys())

        # Check disk
        disk_src_files = set([f.replace('\\', '/') for f in self._get_files()])
        self.assertEqual({'User/Block/myFile.cpp'}, disk_src_files)
예제 #5
0
    def test_src_default_accepted(self):
        bii_ignore = BiiIgnore.defaults()
        save(os.path.join(self.folder, 'User/Block/myFile.cpp'), '')

        src_files = walk_bii_folder(self.folder, bii_ignore, self.biiout)
        self.assertEqual(['User/Block/myFile.cpp'], src_files.keys())

        # Check disk
        disk_src_files = set([f.replace('\\', '/') for f in self._get_files()])
        self.assertEqual({'User/Block/myFile.cpp'},
                         disk_src_files)
예제 #6
0
def _get_filters(bii_ignore, bii_ignores, root, files, subfolder):
    #Now get the bii_ignore
    parent_dir = os.path.dirname(root)
    current_bii_ignore = bii_ignores.get(parent_dir, bii_ignore)
    if 'ignore.bii' in files:
        ignorebii_path = os.path.join(root, 'ignore.bii')
        ignorebii = file_utils.load(ignorebii_path)

        current_bii_ignore = current_bii_ignore + BiiIgnore.loads(ignorebii, subfolder)
    bii_ignores[root] = current_bii_ignore
    return current_bii_ignore
예제 #7
0
    def test_symlink_files_simple_block(self):
        '''
        Check if walker follows symlinked files on bii block
        '''
        block_name = 'User/Block'
        block_folder = os.path.join(self.folder, block_name)
        bii_ignore = BiiIgnore.defaults()

        def test_block():
            return walk_bii_folder(self.folder, bii_ignore, self.biiout)

        self._test_symlink_files(block_folder, block_name, test_block)
예제 #8
0
파일: walk_block.py 프로젝트: toeb/client
def _get_filters(bii_ignore, bii_ignores, root, files, subfolder):
    #Now get the bii_ignore
    parent_dir = os.path.dirname(root)
    current_bii_ignore = bii_ignores.get(parent_dir, bii_ignore)
    if 'ignore.bii' in files:
        ignorebii_path = os.path.join(root, 'ignore.bii')
        ignorebii = file_utils.load(ignorebii_path)

        current_bii_ignore = current_bii_ignore + BiiIgnore.loads(
            ignorebii, subfolder)
    bii_ignores[root] = current_bii_ignore
    return current_bii_ignore
예제 #9
0
    def test_symlink_files_simple_block(self):
        '''
        Check if walker follows symlinked files on bii block
        '''
        block_name = 'User/Block'
        block_folder = os.path.join(self.folder, block_name)
        bii_ignore = BiiIgnore.defaults()

        def test_block():
            return walk_bii_folder(self.folder, bii_ignore, self.biiout)

        self._test_symlink_files(block_folder, block_name, test_block)
예제 #10
0
    def test_src_custom_ignored(self):
        dest_folder = os.path.join(self.folder, 'User/Block')

        save(os.path.join(dest_folder, 'myFile.cpp'), '')
        save(os.path.join(dest_folder, 'ignore.bii'), '*.kk')
        save(os.path.join(dest_folder, 'subdir1/ignore.bii'), '*.kk1')
        save(os.path.join(dest_folder, 'subdir1/prueba.kk'), '')
        save(os.path.join(dest_folder, 'subdir1/prueba.kk1'), '')
        save(os.path.join(dest_folder, 'subdir1/prueba.kk2'), '')
        save(os.path.join(dest_folder, 'subdir2/ignore.bii'), '*.kk2')
        save(os.path.join(dest_folder, 'subdir2/prueba.kk'), '')
        save(os.path.join(dest_folder, 'subdir2/prueba.kk1'), '')
        save(os.path.join(dest_folder, 'subdir2/prueba.kk2'), '')
        save(os.path.join(dest_folder, 'subdir3/ignore.bii'), 'hello.kk3')
        save(os.path.join(dest_folder, 'subdir3/hello.kk3'), '')
        save(os.path.join(dest_folder, 'subdir4/subdir5/subdir6/ignore.bii'),
             'hello.kk5')
        save(os.path.join(dest_folder, 'subdir4/subdir5/subdir6/hello.kk5'),
             '')

        bii_ignore = BiiIgnore.defaults()
        src_files = walk_bii_folder(self.folder, bii_ignore, self.biiout)

        src_files = src_files.keys()
        self.assertEqual(
            set([
                'User/Block/myFile.cpp', 'User/Block/ignore.bii',
                'User/Block/subdir1/ignore.bii',
                'User/Block/subdir1/prueba.kk2',
                'User/Block/subdir2/ignore.bii',
                'User/Block/subdir2/prueba.kk1',
                'User/Block/subdir3/ignore.bii',
                'User/Block/subdir4/subdir5/subdir6/ignore.bii'
            ]), set(src_files))

        # Check disk
        disk_src_files = set([f.replace('\\', '/') for f in self._get_files()])
        self.assertEqual(
            {
                'User/Block/myFile.cpp', 'User/Block/subdir1/ignore.bii',
                'User/Block/ignore.bii', 'User/Block/subdir2/prueba.kk',
                'User/Block/subdir2/prueba.kk2',
                'User/Block/subdir1/prueba.kk2',
                'User/Block/subdir1/prueba.kk1',
                'User/Block/subdir2/prueba.kk1',
                'User/Block/subdir1/prueba.kk',
                'User/Block/subdir2/ignore.bii',
                'User/Block/subdir3/ignore.bii',
                'User/Block/subdir3/hello.kk3',
                'User/Block/subdir4/subdir5/subdir6/ignore.bii',
                'User/Block/subdir4/subdir5/subdir6/hello.kk5'
            }, disk_src_files)
예제 #11
0
 def test_ignore(self):
     ig = BiiIgnore.defaults()
     self.assertTrue(ig.ignored('path/to/file.obj'))
     self.assertTrue(ig.ignored('file.o'))
     self.assertTrue(ig.ignored('file.cpp~'))
     self.assertTrue(ig.ignored('path/file.h~'))
     self.assertTrue(ig.ignored('path/.git/file.cpp'))
     self.assertTrue(ig.ignored('path/git/.file'))
     self.assertTrue(ig.ignored('.git/file.cpp'))
     self.assertTrue(ig.ignored('.svn/file.cpp'))
     self.assertTrue(ig.ignored('.classpath'))
     self.assertTrue(ig.ignored('__init__.pyc'))
     self.assertTrue(ig.ignored('.DS_STORE'))
예제 #12
0
    def test_ordered_rules(self):
        f = '''#Test comment

    *.c
!pepe.c
    *.py
!pepe.py
*.py'''
        ig = BiiIgnore.loads(f)
        self.assertTrue(ig.ignored('kk.c'))
        self.assertFalse(ig.ignored('pepe.c'))
        self.assertTrue(ig.ignored('file.py'))
        self.assertTrue(ig.ignored('pepe.py'))
예제 #13
0
 def test_ignore(self):
     ig = BiiIgnore.defaults()
     self.assertTrue(ig.ignored('path/to/file.obj'))
     self.assertTrue(ig.ignored('file.o'))
     self.assertTrue(ig.ignored('file.cpp~'))
     self.assertTrue(ig.ignored('path/file.h~'))
     self.assertTrue(ig.ignored('path/.git/file.cpp'))
     self.assertTrue(ig.ignored('path/git/.file'))
     self.assertTrue(ig.ignored('.git/file.cpp'))
     self.assertTrue(ig.ignored('.svn/file.cpp'))
     self.assertTrue(ig.ignored('.classpath'))
     self.assertTrue(ig.ignored('__init__.pyc'))
     self.assertTrue(ig.ignored('.DS_STORE'))
예제 #14
0
    def test_ordered_rules(self):
        f = '''#Test comment

    *.c
!pepe.c
    *.py
!pepe.py
*.py'''
        ig = BiiIgnore.loads(f)
        self.assertTrue(ig.ignored('kk.c'))
        self.assertFalse(ig.ignored('pepe.c'))
        self.assertTrue(ig.ignored('file.py'))
        self.assertTrue(ig.ignored('pepe.py'))
예제 #15
0
    def test_symlink_files_anonymous_block(self):
        '''
        Check if walker follows symlinked files on anonymous block
        '''
        block_name = 'User/Block'
        bii_ignore = BiiIgnore.defaults()

        def test_anonymous_block():
            bii_paths = BiiPathsMock(self.folder,
                                     'root-block: {}\nauto-root-block: True'.format(block_name),
                                     self.user_home)
            return walk_anonymous_block(bii_paths, bii_ignore, self.biiout, BlockName(block_name))

        self._test_symlink_files(self.folder, block_name, test_anonymous_block)
예제 #16
0
    def test_src_custom_ignored(self):
        dest_folder = os.path.join(self.folder, 'User/Block')

        save(os.path.join(dest_folder, 'myFile.cpp'), '')
        save(os.path.join(dest_folder, 'ignore.bii'), '*.kk')
        save(os.path.join(dest_folder, 'subdir1/ignore.bii'), '*.kk1')
        save(os.path.join(dest_folder, 'subdir1/prueba.kk'), '')
        save(os.path.join(dest_folder, 'subdir1/prueba.kk1'), '')
        save(os.path.join(dest_folder, 'subdir1/prueba.kk2'), '')
        save(os.path.join(dest_folder, 'subdir2/ignore.bii'), '*.kk2')
        save(os.path.join(dest_folder, 'subdir2/prueba.kk'), '')
        save(os.path.join(dest_folder, 'subdir2/prueba.kk1'), '')
        save(os.path.join(dest_folder, 'subdir2/prueba.kk2'), '')
        save(os.path.join(dest_folder, 'subdir3/ignore.bii'), 'hello.kk3')
        save(os.path.join(dest_folder, 'subdir3/hello.kk3'), '')
        save(os.path.join(dest_folder, 'subdir4/subdir5/subdir6/ignore.bii'), 'hello.kk5')
        save(os.path.join(dest_folder, 'subdir4/subdir5/subdir6/hello.kk5'), '')

        bii_ignore = BiiIgnore.defaults()
        src_files = walk_bii_folder(self.folder, bii_ignore, self.biiout)

        src_files = src_files.keys()
        self.assertEqual(set(['User/Block/myFile.cpp',
                              'User/Block/ignore.bii',
                              'User/Block/subdir1/ignore.bii',
                              'User/Block/subdir1/prueba.kk2',
                              'User/Block/subdir2/ignore.bii',
                              'User/Block/subdir2/prueba.kk1',
                              'User/Block/subdir3/ignore.bii',
                              'User/Block/subdir4/subdir5/subdir6/ignore.bii']), set(src_files))

        # Check disk
        disk_src_files = set([f.replace('\\', '/') for f in self._get_files()])
        self.assertEqual({'User/Block/myFile.cpp',
                          'User/Block/subdir1/ignore.bii',
                          'User/Block/ignore.bii',
                          'User/Block/subdir2/prueba.kk',
                          'User/Block/subdir2/prueba.kk2',
                          'User/Block/subdir1/prueba.kk2',
                          'User/Block/subdir1/prueba.kk1',
                          'User/Block/subdir2/prueba.kk1',
                          'User/Block/subdir1/prueba.kk',
                          'User/Block/subdir2/ignore.bii',
                          'User/Block/subdir3/ignore.bii',
                          'User/Block/subdir3/hello.kk3',
                          'User/Block/subdir4/subdir5/subdir6/ignore.bii',
                          'User/Block/subdir4/subdir5/subdir6/hello.kk5'},
                          disk_src_files)
예제 #17
0
    def test_symlink_files_anonymous_block(self):
        '''
        Check if walker follows symlinked files on anonymous block
        '''
        block_name = 'User/Block'
        bii_ignore = BiiIgnore.defaults()

        def test_anonymous_block():
            bii_paths = BiiPathsMock(
                self.folder,
                'root-block: {}\nauto-root-block: True'.format(block_name),
                self.user_home)
            return walk_anonymous_block(bii_paths, bii_ignore, self.biiout,
                                        BlockName(block_name))

        self._test_symlink_files(self.folder, block_name, test_anonymous_block)
예제 #18
0
    def test_src_default_ignored(self):
        bii_ignore = BiiIgnore.defaults()

        save(os.path.join(self.folder, 'User/Block/.myFile.cpp'), '')
        save(os.path.join(self.folder, 'User/Block/myFile.cpp~'), '')
        save(os.path.join(self.folder, 'User2/Block2/Path/To/HelloWorld.obj'), '')

        src_files = walk_bii_folder(self.folder, bii_ignore, self.biiout)

        src_files = {name: t for name, (t, _) in src_files.iteritems()}
        self.assertEqual({}, src_files)

        # Check disk
        disk_src_files = set([f.replace('\\', '/') for f in self._get_files()])
        self.assertEqual({'User/Block/.myFile.cpp', 'User2/Block2/Path/To/HelloWorld.obj',
                          'User/Block/myFile.cpp~'},
                          disk_src_files)
예제 #19
0
    def test_src_default_ignored(self):
        bii_ignore = BiiIgnore.defaults()

        save(os.path.join(self.folder, 'User/Block/.myFile.cpp'), '')
        save(os.path.join(self.folder, 'User/Block/myFile.cpp~'), '')
        save(os.path.join(self.folder, 'User2/Block2/Path/To/HelloWorld.obj'),
             '')

        src_files = walk_bii_folder(self.folder, bii_ignore, self.biiout)

        src_files = {name: t for name, (t, _) in src_files.iteritems()}
        self.assertEqual({}, src_files)

        # Check disk
        disk_src_files = set([f.replace('\\', '/') for f in self._get_files()])
        self.assertEqual(
            {
                'User/Block/.myFile.cpp',
                'User2/Block2/Path/To/HelloWorld.obj', 'User/Block/myFile.cpp~'
            }, disk_src_files)
예제 #20
0
 def bii_ignore(self):
     from biicode.client.workspace.bii_ignore import BiiIgnore, default_bii_ignore
     path = os.path.join(self._folder, 'ignore.bii')
     if not os.path.exists(path):
         save(path, default_bii_ignore)
     return BiiIgnore.loads(load(path))
예제 #21
0
 def test_bad_location(self):
     bii_ignore = BiiIgnore.defaults()
     save(os.path.join(self.folder, 'User/mybadFile.cpp'), '')
     _ = walk_bii_folder(self.folder, bii_ignore, self.biiout)
     # Check that the system detected misplaced file
     self.assertIn("WARN: User/mybadFile.cpp is misplaced", str(self.biiout))