예제 #1
0
    def test_patch_export_options(self):
        """Test patch export options"""
        repo = self.init_test_repo('gbp-test2')

        # Test no-patch-export
        base_args = ['--git-builder=osc', '--git-no-build']
        eq_(mock_gbp(base_args + ['--git-no-patch-export']), 0)
        ref_files = self.ls_tree(repo, 'HEAD:packaging')
        ref_files.add('gbp-test2-2.0.tar.gz')
        eq_(ls_dir('../rpmbuild', False), ref_files)
        shutil.rmtree('../rpmbuild')

        # No patches should be generated if patch-export-rev is upstream version

        # Test patch compression and numbering
        eq_(
            mock_gbp(
                base_args +
                ['--git-no-patch-numbers', '--git-patch-export-compress=1']),
            0)
        new_files = ls_dir('../rpmbuild', False) - ref_files
        ok_(len(new_files) > 0)
        for fname in new_files:
            # Patches should start with an alphabet and be compressed with gz
            ok_(re.match(r'^[a-zA-Z]\S*.patch.gz$', fname), fname)
 def test_dir(self):
     """Basic test for unpacked sources, no filtering etc"""
     tmpdir = tempfile.mkdtemp(dir=self._tmpdir, prefix='dir_basic_')
     source = UpstreamSource(self._origs['dir'])
     orig, prist = prepare_sources(source, 'test', '1.0', None, None, False,
                                   None, tmpdir)
     self.assertEqual(ls_dir(self._origs['dir']), ls_dir(orig))
     self.assertEqual(prist, '')
 def test_dir_filter(self):
     """Test filtering of unpacked sources"""
     tmpdir = tempfile.mkdtemp(dir=self._tmpdir, prefix='dir_filter_')
     source = UpstreamSource(self._origs['dir'])
     orig, prist = prepare_sources(source, 'test', '1.0', None, ['pkg'],
                                   False, None, tmpdir)
     orig_filt_ref = set([
         fname for fname in ls_dir(self._origs['dir'])
         if not fname.startswith('pkg')
     ])
     self.assertEqual(orig_filt_ref, ls_dir(orig))
     self.assertEqual(prist, '')
 def test_dir_pristine_filter(self):
     """Test filtering pristine-tar and mangling prefix"""
     tmpdir = tempfile.mkdtemp(dir=self._tmpdir, prefix='dir_filter3_')
     source = UpstreamSource(self._origs['dir'])
     orig, prist = prepare_sources(source, 'test', '1.0', 'test.tar.gz',
                                   ['pkg'], True, 'newpref', tmpdir)
     src_ls = ls_dir(self._origs['dir'])
     orig_filt_ref = set(
         [fname for fname in src_ls if not fname.startswith('pkg')])
     prist_ref = set(['newpref/%s' % fname
                      for fname in orig_filt_ref] + ['newpref'])
     self.assertEqual(orig_filt_ref, ls_dir(orig))
     self.assertEqual(prist_ref, ls_tar(prist))
 def test_dir_pristine_nofilter(self):
     """Test filtering of unpacked sources, not filtering pristine-tar"""
     tmpdir = tempfile.mkdtemp(dir=self._tmpdir, prefix='dir_filter2_')
     source = UpstreamSource(self._origs['dir'])
     orig, prist = prepare_sources(source, 'test', '1.0', 'test.tar.gz',
                                   ['pkg'], False, None, tmpdir)
     src_ls = ls_dir(self._origs['dir'])
     orig_filt_ref = set(
         [fname for fname in src_ls if not fname.startswith('pkg')])
     prist_ref = set(['test-1.0/%s' % fname
                      for fname in src_ls] + ['test-1.0'])
     self.assertEqual(orig_filt_ref, ls_dir(orig))
     self.assertEqual(prist_ref, ls_tar(prist))
 def test_dir_nopristinefilter(self):
     """Test importing directory with --no-pristine-tar-filter"""
     orig = self.unpack_tar(os.path.join(DATA_DIR, 'gbp-test-1.0.tar.bz2'))
     args = ['--pristine-tar', '--filter=README', orig]
     eq_(self.mock_import(args, 'gbp-test\n1.0\n'), 0)
     files = ['Makefile', 'dummy.sh']
     self.check_repo(None, None, [])
     self.check_tree('upstream', ['Makefile', 'dummy.sh'])
     prist_ref = set(['gbp-test-1.0/%s' % fname
                      for fname in ls_dir(orig)] + ['gbp-test-1.0'])
     self.check_files(prist_ref, self.ls_pristine_tar('gbp-test.tar.gz'))
 def test_tar(self):
     """Basic test for tarball sources, with pristine-tar"""
     tmpdir = tempfile.mkdtemp(dir=self._tmpdir, prefix='tar_basic_')
     source = UpstreamSource(self._origs['tar'])
     orig, prist = prepare_sources(source, 'test', '1.0', 'test.tgz', None,
                                   False, 'test-1.0', tmpdir)
     src_ls = ls_tar(self._origs['tar'])
     orig_ref = set([
         fname.replace('test-1.0/', '') for fname in src_ls
         if fname != 'test-1.0'
     ])
     self.assertEqual(orig_ref, ls_dir(orig))
     self.assertEqual(src_ls, ls_tar(prist))
 def test_tar_filter_pristine_prefix(self):
     """Filter tarball, pristine-tar prefix mangling but not filter"""
     tmpdir = tempfile.mkdtemp(dir=self._tmpdir, prefix='tar_filter_')
     source = UpstreamSource(self._origs['tar'])
     orig, prist = prepare_sources(source, 'test', '1.0', 'test.tgz',
                                   ['pkg'], False, 'newp', tmpdir)
     src_ls = ls_tar(self._origs['tar'])
     orig_ref = set([
         fname.replace('test-1.0/', '') for fname in src_ls
         if fname != 'test-1.0' and not fname.startswith('test-1.0/pkg')
     ])
     prist_ref = set(
         [fname.replace('test-1.0', 'newp') for fname in src_ls])
     self.assertEqual(orig_ref, ls_dir(orig))
     self.assertEqual(prist_ref, ls_tar(prist))