Example #1
0
 def testExcludeDirs(self):
     """Test the excluded directories works."""
     result = matching.FindFilesMatching('*.txt',
                                         target=self.tempdir,
                                         cwd='/',
                                         exclude_dirs=(self.excluded, ))
     self.assertCountEqual(self.txts, result)
    def BuildAutotestServerPackageTarball(self):
        """Tar up the autotest files required by the server package.

    Returns:
      str|None - The path of the autotest server package tarball if created.
    """
        # Find all files in autotest excluding certain directories.
        tast_files, transforms = self._GetTastServerFilesAndTarTransforms()
        autotest_files = matching.FindFilesMatching(
            '*',
            target='autotest',
            cwd=self.archive_basedir,
            exclude_dirs=('autotest/packages', 'autotest/client/deps/',
                          'autotest/client/tests',
                          'autotest/client/site_tests'))

        tarball = os.path.join(self.output_directory,
                               self._SERVER_PACKAGE_ARCHIVE)
        if self._BuildTarball(autotest_files + tast_files,
                              tarball,
                              extra_args=transforms,
                              check=False):
            return tarball
        else:
            return None
Example #3
0
 def testCwd(self):
     """Test the paths change relative to the cwd."""
     result = matching.FindFilesMatching('*.csv',
                                         target='path',
                                         cwd=self.tempdir)
     # Convert the csv paths to be relative to the tempdir.
     expected = [os.path.relpath(x, start=self.tempdir) for x in self.csvs]
     self.assertCountEqual(expected, result)
Example #4
0
  def BuildAutotestControlFilesTarball(self):
    """Tar up the autotest control files.

    Returns:
      str - Path of the partial autotest control files tarball.
    """
    # Find the control files in autotest/.
    input_list = matching.FindFilesMatching(
        'control*', target='autotest', cwd=self.archive_basedir,
        exclude_dirs=['autotest/test_suites'])
    tarball = os.path.join(self.output_directory, self._CONTROL_FILES_ARCHIVE)
    self._BuildTarball(input_list, tarball, compressed=False)
    return tarball
Example #5
0
 def testFindMatching(self):
     """Simple find matching."""
     result = matching.FindFilesMatching('*.csv',
                                         target=self.tempdir,
                                         cwd='/')
     self.assertCountEqual(self.csvs, result)