Created
April 20, 2016 22:08
-
-
Save JieGhost/07c58285b3c725be82c1f69793666693 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProjectTreeTestBase(AbstractClass): | |
@abstractmethod | |
def mk_project_tree(self, build_root, ignore_patterns=[]): | |
"""Construct a ProjectTree for the given build_root path.""" | |
pass | |
def make_base_dir(self): | |
""" | |
:API: public | |
""" | |
return tempfile.mkdtemp() | |
def fullpath(self, path): | |
""" | |
:API: public | |
""" | |
return os.path.join(self.root_dir, path) | |
def makedirs(self, path): | |
""" | |
:API: public | |
""" | |
safe_mkdir(self.fullpath(path)) | |
def touch(self, path): | |
""" | |
:API: public | |
""" | |
touch(self.fullpath(path)) | |
def rmdirs(self, path): | |
""" | |
:API: public | |
""" | |
shutil.rmtree(path) | |
class PantsIgnoreTestBase(ProjectTreeTestBase): | |
def setUp(self): | |
""" | |
:API: public | |
""" | |
self.base_dir = self.make_base_dir() | |
self.root_dir = os.path.join(self.base_dir, 'root') | |
# make 'root/' | |
self.makedirs('') | |
# make 'root/...' | |
self.touch('apple') | |
self.touch('orange') | |
self.touch('banana') | |
# make 'root/fruit/' | |
self.makedirs('fruit') | |
# make 'root/fruit/...' | |
self.touch('fruit/apple') | |
self.touch('fruit/orange') | |
self.touch('fruit/banana') | |
# make 'root/fruit/fruit/' | |
self.makedirs('fruit/fruit') | |
# make 'root/fruit/fruit/...' | |
self.touch('fruit/fruit/apple') | |
self.touch('fruit/fruit/orange') | |
self.touch('fruit/fruit/banana') | |
self.makedirs('grocery') | |
self.touch('grocery/fruit') | |
self.cwd = os.getcwd() | |
os.chdir(self.root_dir) | |
def tearDown(self): | |
""" | |
:API: public | |
""" | |
os.chdir(self.cwd) | |
self.rmdirs(self.base_dir) | |
def test_ignore_pattern_blank_line(self): | |
self._project_tree = self.mk_project_tree(self.root_dir, [""]) | |
files_list = [] | |
for root, dirs, files in self._project_tree.walk(''): | |
for file in files: | |
files_list.append(os.path.join(root, file)) | |
…….. | |
class FileSystemPantsIgnoreTest(unittest.TestCase, PantsIgnoreTestBase): | |
def mk_project_tree(self, build_root, ignore_patterns=[]): | |
return FileSystemProjectTree(build_root, ignore_patterns) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment