def setUp(self): MockExecutive.last_run_command = [] MockExecutive.response = '' deduplicate_tests.executive = MockExecutive self._original_cwd = os.getcwd() checkout_root = scm.find_checkout_root() self.assertNotEqual(checkout_root, None) os.chdir(checkout_root)
def setUp(self): MockExecutive.last_run_command = [] MockExecutive.response = '' deduplicate_tests.executive = MockExecutive self._original_cwd = os.getcwd() checkout_root = scm.find_checkout_root() self.assertNotEqual(checkout_root, None) os.chdir(checkout_root)
def get_relative_test_path(filename, relative_to, checkout_root=scm.find_checkout_root()): """Constructs a relative path to |filename| from |relative_to|. Args: filename: The test file we're trying to get a relative path to. relative_to: The absolute path we're relative to. Returns: A relative path to filename or None if |filename| is not below |relative_to|. """ layout_test_dir = os.path.join(checkout_root, "LayoutTests") abs_path = os.path.join(layout_test_dir, filename) return ospath.relpath(abs_path, relative_to)
def get_relative_test_path(filename, relative_to, checkout_root=scm.find_checkout_root()): """Constructs a relative path to |filename| from |relative_to|. Args: filename: The test file we're trying to get a relative path to. relative_to: The absolute path we're relative to. Returns: A relative path to filename or None if |filename| is not below |relative_to|. """ layout_test_dir = os.path.join(checkout_root, 'LayoutTests') abs_path = os.path.join(layout_test_dir, filename) return ospath.relpath(abs_path, relative_to)
def test_get_relative_test_path(self): checkout_root = scm.find_checkout_root() layout_test_dir = os.path.join(checkout_root, 'LayoutTests') test_cases = ( ('platform/mac/test.html', ('platform/mac/test.html', layout_test_dir)), ('LayoutTests/platform/mac/test.html', ('platform/mac/test.html', checkout_root)), (None, ('platform/mac/test.html', os.path.join(checkout_root, 'Source', 'WebCore'))), ('test.html', ('platform/mac/test.html', os.path.join(layout_test_dir, 'platform/mac'))), (None, ('platform/mac/test.html', os.path.join(layout_test_dir, 'platform/win'))), ) for expected, inputs in test_cases: self.assertEquals(expected, deduplicate_tests.get_relative_test_path(*inputs))
def test_get_relative_test_path(self): checkout_root = scm.find_checkout_root() layout_test_dir = os.path.join(checkout_root, 'LayoutTests') test_cases = ( ('platform/mac/test.html', ('platform/mac/test.html', layout_test_dir)), ('LayoutTests/platform/mac/test.html', ('platform/mac/test.html', checkout_root)), (None, ('platform/mac/test.html', os.path.join(checkout_root, 'Source', 'WebCore'))), ('test.html', ('platform/mac/test.html', os.path.join(layout_test_dir, 'platform/mac'))), (None, ('platform/mac/test.html', os.path.join(layout_test_dir, 'platform/win'))), ) for expected, inputs in test_cases: self.assertEquals( expected, deduplicate_tests.get_relative_test_path(*inputs))
def port_fallbacks(): """Get the port fallback information. Returns: A dictionary mapping platform name to a list of other platforms to fall back on. All platforms fall back on 'base'. """ fallbacks = {_BASE_PLATFORM: []} platform_dir = os.path.join(scm.find_checkout_root(), "LayoutTests", "platform") for port_name in os.listdir(platform_dir): try: platforms = port_factory.get(port_name).baseline_search_path() except NotImplementedError: _log.error("'%s' lacks baseline_search_path(), please fix." % port_name) fallbacks[port_name] = [_BASE_PLATFORM] continue fallbacks[port_name] = [os.path.basename(p) for p in platforms][1:] fallbacks[port_name].append(_BASE_PLATFORM) return fallbacks
def cluster_file_hashes(glob_pattern): """Get the hashes of all the test expectations in the tree. We cheat and use git's hashes. Args: glob_pattern: a pattern to filter the files. Returns: A dictionary mapping (test name, hash of content) => [paths] """ # A map of file hash => set of all files with that hash. hashes = collections.defaultdict(set) # Fill in the map. cmd = ("git", "ls-tree", "-r", "HEAD", "LayoutTests") try: git_output = executive.Executive().run_command(cmd, cwd=scm.find_checkout_root()) except OSError, e: if e.errno == 2: # No such file or directory. _log.error("Error: 'No such file' when running git.") _log.error("This script requires git.") sys.exit(1) raise e
def cluster_file_hashes(glob_pattern): """Get the hashes of all the test expectations in the tree. We cheat and use git's hashes. Args: glob_pattern: a pattern to filter the files. Returns: A dictionary mapping (test name, hash of content) => [paths] """ # A map of file hash => set of all files with that hash. hashes = collections.defaultdict(set) # Fill in the map. cmd = ('git', 'ls-tree', '-r', 'HEAD', 'LayoutTests') try: git_output = executive.Executive().run_command(cmd, cwd=scm.find_checkout_root()) except OSError, e: if e.errno == 2: # No such file or directory. _log.error("Error: 'No such file' when running git.") _log.error("This script requires git.") sys.exit(1) raise e