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))
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')))
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')))
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)
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)
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)
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)
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)
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'))
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'))
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)
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)
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)
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)
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)
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))