Example #1
0
    def testGetHigherLevelPathGivenPathInSrcDirectory(self):
        """Checks that '' is returned when the last directory is reached.

    If the directory above the tools directory is src, then receiving
    'src/OWNERS' is the point at which recursion stops. However, this directory
    may not always be src.
    """
        path_to_chromium_directory = [
            os.path.dirname(__file__), '..', '..', '..', '..'
        ]
        path = os.path.abspath(
            os.path.join(*(path_to_chromium_directory + ['src/OWNERS'])))
        self.assertEqual(expand_owners._GetHigherLevelOwnersFilePath(path), '')
Example #2
0
  def testGetHigherLevelPath(self):
    """Checks that higher directories are recursively checked for OWNERS.

    Also, checks that there isn't a recursive loop.
    """
    path = expand_owners._GetOwnersFilePath('src/banana/chocolate/OWNERS')
    result = expand_owners._GetHigherLevelOwnersFilePath(path)

    # The condition is true when the tools directory's parent directory is src,
    # which is generally the case locally. However, the parent directory is not
    # always src, e.g. on various testing bots.
    if os.path.basename(_GetToolsParentDir()) == 'src':
      self.assertRegexpMatches(result, r'.*OWNERS')
    else:
      self.assertEqual(result, '')
Example #3
0
 def testGetHigherLevelPathDerivedPathInSrcDirectory(self):
     """Checks that higher directories are recursively checked for OWNERS."""
     path = expand_owners._GetOwnersFilePath('src/banana/chocolate/OWNERS')
     self.assertRegexpMatches(
         expand_owners._GetHigherLevelOwnersFilePath(path), r'.*src/OWNERS')