Ejemplo n.º 1
0
    def init_test(self, cd, argv=None, wd=None, buildroot=None, options=None):
        '''
        Initiate a test which runs in directory cd
        kwargs:
           argv: fed to sys.argv and eventually to Settings
                 fedora-review is prepended and mock_root appended.
           wd:   review directory, cleared.
           options: mock-options'''

        cd = os.path.abspath(cd)
        os.chdir(cd)
        if not wd:
            wd = os.getcwd()
        ReviewDirs.workdir_setup(wd, 'testing')
        if not argv:
            argv = []
        args = argv
        args.insert(0, 'fedora-review')
        br = buildroot if buildroot else self.BUILDROOT
        args.append("--mock-config=" + br)
        opts = []
        if NO_NET:
            opts.append('--offline')
        if options:
            opts.append(options)
        if opts:
            argv.append('--mock-options=' + ' '.join(opts))
        sys.argv = argv
        Settings.init(True)
        Mock.clear_builddir()
        Mock.reset()
Ejemplo n.º 2
0
    def test_source_file(self):
        """ Test the SourceFile class """
        if os.path.exists('python-test'):
            shutil.rmtree('python-test')
        sys.argv = ['fedora-review', '-n', 'python-test']
        Settings.init(True)
        ReviewDirs.reset()
        ReviewDirs.workdir_setup('.', True)
        bug = NameBug('python-test')
        bug.find_urls()
        bug.download_files()

        spec = SpecFile(bug.spec_file)
        sources = Sources(spec)
        source = Source(sources, 'Source0', TEST_SRC)
        # check that source exists and source.filename point to the right location
        expected = os.path.abspath('./upstream/python-test-1.0.tar.gz')
        self.assertEqual(source.filename, expected)
        self.assertEqual(source.is_archive(), True)
        self.assertTrue(os.path.exists(source.filename))
        self.assertEqual(
            source.check_source_checksum(),
            "7ef644ee4eafa62cfa773cad4056cdcea592e27dacd5ae"
            "b4e8b11f51f5bf60d3")
        os.chdir(self.startdir)
Ejemplo n.º 3
0
    def test_prebuilt(self):
        ''' test --name --prebuilt '''

        argv = ['fedora-review', '-rpn', 'python-spiffgtkwidgets']
        argv.extend(['--mock-config', 'fedora-16-i386'])
        sys.argv = argv
        os.chdir('prebuilt')
        if os.path.exists('python-spiffgtkwidgets'):
            shutil.rmtree('python-spiffgtkwidgets')
        ReviewDirs.reset()
        Settings.init(True)
  
        rpms = glob('/var/lib/mock/fedora-16-i386/*.rpm')
        for r in rpms:
            os.unlink(r)

        rh = ReviewHelper()
        sys.stdout = open( '/dev/null', 'w')
        rh.run()
        sys.stdout = sys.__stdout__
        self.assertEqual(len(rpms), 0)
        rv = 'python-spiffgtkwidgets-review.txt'
        with open(os.path.abspath(rv)) as f:
            log = '\n'.join(f.readlines())
        self.assertIn('Using prebuilt rpms', log)
        os.chdir(startdir)
Ejemplo n.º 4
0
    def init_test(self, cd, argv=None, wd=None,
                  buildroot=None, options=None):
        '''
        Initiate a test which runs in directory cd
        kwargs:
           argv: fed to sys.argv and eventually to Settings
                 fedora-review is prepended and mock_root appended.
           wd:   review directory, cleared.
           options: mock-options'''

        cd = os.path.abspath(cd)
        os.chdir(cd)
        if not wd:
            wd = os.getcwd()
        ReviewDirs.workdir_setup(wd, 'testing')
        if not argv:
            argv = []
        args = argv
        args.insert(0, 'fedora-review')
        br = buildroot if buildroot else self.BUILDROOT
        args.append("--mock-config=" + br)
        opts = []
        if NO_NET:
            opts.append('--offline')
        if options:
            opts.append(options)
        if opts:
            argv.append('--mock-options=' + ' '.join(opts))
        sys.argv = argv
        Settings.init(True)
        Mock.clear_builddir()
        Mock.reset()
Ejemplo n.º 5
0
    def test_prebuilt(self):
        """ test --name --prebuilt """

        argv = ["fedora-review", "-rpn", "python-spiffgtkwidgets"]
        argv.extend(["--mock-config", "fedora-16-i386"])
        sys.argv = argv
        os.chdir("prebuilt")
        if os.path.exists("python-spiffgtkwidgets"):
            shutil.rmtree("python-spiffgtkwidgets")
        ReviewDirs.reset()
        Settings.init(True)

        rpms = glob("/var/lib/mock/fedora-16-i386/*.rpm")
        for r in rpms:
            os.unlink(r)

        rh = ReviewHelper()
        sys.stdout = open("/dev/null", "w")
        rh.run()
        sys.stdout = sys.__stdout__
        self.assertEqual(len(rpms), 0)
        rv = "python-spiffgtkwidgets-review.txt"
        with open(os.path.abspath(rv)) as f:
            log = "\n".join(f.readlines())
        self.assertIn("Using prebuilt rpms", log)
        os.chdir(startdir)
Ejemplo n.º 6
0
 def setUp(self):
     sys.argv = ['fedora-review','-rpn','R-Rdummypkg']
     os.chdir('test-R')
     if os.path.exists('R-Rdummypkg'):
          shutil.rmtree('R-Rdummypkg')
     Settings.init(True)
     ReviewDirs.reset()
Ejemplo n.º 7
0
 def setUp(self):
     sys.argv = ['fedora-review', '-rpn', 'R-Rdummypkg']
     os.chdir('test-R')
     if os.path.exists('R-Rdummypkg'):
         shutil.rmtree('R-Rdummypkg')
     Settings.init(True)
     ReviewDirs.reset()
Ejemplo n.º 8
0
 def init_test(self, cd, argv=[], wd=None,
               buildroot=None, options=None):
     # Initiate a test which runs in directory cd
     # kwargs:
     #    argv: fed to sys.argv and eventually to Settings
     #          fedora-review is prepended and mock_root appended.
     #    wd:   review directory, cleared.
     #    options: mock-options
     os.chdir(cd)
     if wd:
         if os.path.exists(wd):
             shutil.rmtree(wd)
     ReviewDirs.reset(cd)
     ReviewDirs.workdir_setup(os.getcwd(), True)
     args = argv
     args.insert(0, 'fedora-review')
     br = buildroot if buildroot else self.BUILDROOT
     args.append("--mock-config=" + br)
     opts = []
     if NO_NET:
         opts.append('--offline')
     if options:
         opts.append(options)
     if opts:
         argv.append('--mock-options=' +  ' '.join(opts))
     sys.argv = argv
     Settings.init(True)
     Mock.reset()
Ejemplo n.º 9
0
 def test_unversioned_so_private(self):
     self.init_test('unversioned-so-private',
                    argv=['-rpn', 'python-test', '--cache'],
                    wd='python-test')
     ReviewDirs.reset(os.getcwd())
     bug = NameBug('python-test')
     check = self.run_single_check(bug,'CheckSoFiles')
     self.assertTrue(check.is_pending)
Ejemplo n.º 10
0
 def init_test(self, argv=["fedora-review"], d=None):
     os.chdir(startdir)
     if d:
         os.chdir(d)
     if os.path.exists("python-test"):
         shutil.rmtree("python-test")
     ReviewDirs.reset()
     ReviewDirs.workdir_setup(".", True)
     sys.argv = argv
     Settings.init(True)
Ejemplo n.º 11
0
 def init_test(self, argv= ['fedora-review'], d=None):
     os.chdir(startdir)
     if d:
         os.chdir(d)
     if os.path.exists('python-test'):
         shutil.rmtree('python-test')
     ReviewDirs.reset()
     ReviewDirs.workdir_setup('.', True)
     sys.argv = argv
     Settings.init(True)
Ejemplo n.º 12
0
 def test_107_no_space_config(self):
     """ Test the case when there is no space in %config line between
     the file and macro itself
     """
     self.init_test('test_regressions',
                    argv=['-rn', self.srpm_file, '--cache'])
     ReviewDirs.reset(os.getcwd())
     bug = NameBug(self.srpm_file)
     check = self.run_single_check(bug, 'CheckNoConfigInUsr')
     self.assertTrue(check.is_failed)
Ejemplo n.º 13
0
 def test_107_changelog_skipping(self):
     """ Test the case when sourceX is name and we use f-r -n so
     that file gets mixed up with a directory
     """
     self.init_test('test_regressions',
                    argv=['-rn', self.srpm_file])
     ReviewDirs.reset(os.getcwd())
     spec = SpecFile(self.spec_file)
     regex = re.compile('initial fedora')
     self.assertEqual(len(spec.find_all(regex)), 2)
     self.assertEqual(len(spec.find_all(regex, True)), 1)
Ejemplo n.º 14
0
 def test_spec_file(self):
     ''' Test the SpecFile class'''
     ReviewDirs.reset()
     ReviewDirs.workdir_setup('.', True)
     dest = Mock.get_builddir('SOURCES')
     if not os.path.exists(dest):
         os.makedirs(dest)
     self.helpers._get_file(TEST_SPEC, Mock.get_builddir('SOURCES'))
     spec = SpecFile(self.spec_file)
     # Test misc rpm values (Macro resolved)
     self.assertEqual(spec.name, 'python-test')
     self.assertEqual(spec.version, '1.0')
     # resolve the dist-tag
     dist = self.helpers._run_cmd('rpm --eval %dist')[:-1]
     self.assertEqual(spec.release, '1' + dist)
     # test misc rpm values (without macro resolve)
     self.assertEqual(spec.find_tag('Release'), ['1%{?dist}'])
     self.assertEqual(spec.find_tag('License'), ['GPLv2+'])
     self.assertEqual(spec.find_tag('Group'), ['Development/Languages'])
     # Test rpm value not there
     self.assertEqual(spec.find_tag('PreReq'), [])
     # Test get sections
     expected = {'%clean': ['rm -rf $RPM_BUILD_ROOT']}
     self.assertEqual(spec.get_section('%clean'), expected)
     expected = {'%build': ['%{__python} setup.py build']}
     self.assertEqual(spec.get_section('%build'), expected)
     expected = {
         '%install': [
             'rm -rf $RPM_BUILD_ROOT',
             '%{__python} setup.py install -O1 --skip-build'
             ' --root $RPM_BUILD_ROOT'
         ]
     }
     self.assertEqual(spec.get_section('%install'), expected)
     expected = {
         '%files':
         ['%defattr(-,root,root,-)', '%doc COPYING', '%{python_sitelib}/*']
     }
     self.assertEqual(spec.get_section('%files'), expected)
     # Test get_sources (return the Source/Patch lines with macros resolved)
     expected = {
         'Source0':
         'http://timlau.fedorapeople.org/'
         'files/test/review-test/python-test-1.0.tar.gz'
     }
     self.assertEqual(spec.get_sources(), expected)
     # Test find
     regex = re.compile(r'^Release\s*:\s*(.*)')
     res = spec.find(regex)
     if res:
         self.assertEqual(res.groups(), ('1%{?dist}', ))
     else:
         self.assertTrue(False)
     os.chdir(self.startdir)
Ejemplo n.º 15
0
 def test_desktop_file_bug(self):
     os.chdir('desktop-file')
     if os.path.exists('python-test'):
         shutil.rmtree('python-test')
     sys.argv = ['fedora-review','-rpn','python-test']
     Settings.init(True)
     ReviewDirs.reset()
     bug = NameBug('python-test')
     check = self.run_single_check(bug,'CheckDesktopFileInstall')
     self.assertEqual(check.state, 'pass')
     os.chdir(self.startdir)
Ejemplo n.º 16
0
 def test_desktop_file_bug(self):
     os.chdir('desktop-file')
     if os.path.exists('python-test'):
         shutil.rmtree('python-test')
     sys.argv = ['fedora-review', '-rpn', 'python-test']
     Settings.init(True)
     ReviewDirs.reset()
     bug = NameBug('python-test')
     check = self.run_single_check(bug, 'CheckDesktopFileInstall')
     self.assertEqual(check.state, 'pass')
     os.chdir(self.startdir)
Ejemplo n.º 17
0
 def test_rpm_spec(self):
     self.init_test('test_misc',
                    argv=['-rn','python-test', '--cache',
                          '--no-build'])
     ReviewDirs.reset()
     bug = NameBug('python-test')
     bug.find_urls()
     expected = 'src/test/test_misc/python-test-1.0-1.fc16.src.rpm'
     self.assertTrue(bug.srpm_url.endswith(expected))
     expected = 'src/test/test_misc/review-python-test/srpm-unpacked/python-test.spec'
     print bug.spec_url
     self.assertTrue(bug.spec_url.endswith(expected))
Ejemplo n.º 18
0
 def test_bad_specname(self):
     self.init_test('bad-specname',
                    argv=['-rn','python-test', '--cache'])
     ReviewDirs.reset(os.getcwd())
     bug = NameBug('python-test')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     check = checks.checkdict['CheckSpecAsInSRPM']
     check.run()
     self.assertTrue(check.is_failed)
     self.assertIn('Bad spec filename:', check.result.output_extra)
Ejemplo n.º 19
0
 def test_local_repo(self):
     self.init_test('test_misc',
                    argv=['-rn','python-test', '--local-repo',
                          'repo', '--cache'])
     ReviewDirs.reset(os.getcwd())
     bug = NameBug('python-test')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     check = checks.checkdict['CheckPackageInstalls']
     check.run()
     self.assertTrue(check.is_passed)
     self.assertTrue(Mock.is_installed('dummy'))
Ejemplo n.º 20
0
 def test_bad_specfile(self):
     os.chdir('bad-spec')
     if os.path.exists('python-test'):
         shutil.rmtree('python-test')
     sys.argv = ['fedora-review', '-pn', 'python-test']
     Settings.init(True)
     ReviewDirs.reset()
     ReviewDirs.workdir_setup('.', True)
     bug = NameBug('python-test')
     check = self.run_single_check(bug, 'CheckSpecAsInSRPM')
     self.assertEqual(check.state, 'fail')
     self.assertTrue('#TestTag' in check.attachments[0].text)
     os.chdir(self.startdir)
Ejemplo n.º 21
0
 def test_rpm_spec(self):
     sys.argv = ['fedora-review', '-rn', 'python-test']
     Settings.init(True)
     ReviewDirs.reset()
     if os.path.exists('python-test'):
         shutil.rmtree('python-test')
     bug = NameBug('python-test')
     bug.find_urls()
     expected = 'src/test/python-test-1.0-1.fc16.src.rpm'
     self.assertTrue(bug.srpm_url.endswith(expected))
     expected = 'src/test/python-test/srpm-unpacked/python-test.spec'
     self.assertTrue(bug.spec_url.endswith(expected))
     os.chdir(self.startdir)
Ejemplo n.º 22
0
 def test_all_checks(self):
     ''' Run all automated review checks'''
     self.init_test('test-R',
                     argv=['-rpn','R-Rdummypkg', '--no-build'])
     ReviewDirs.reset()
     self.bug = NameBug('R-Rdummypkg')
     self.bug.find_urls()
     self.bug.download_files()
     self.checks = Checks(self.bug.spec_file, self.bug.srpm_file)
     self.checks.run_checks(writedown=False)
     for check in self.checks.checkdict.itervalues():
         if check.is_passed or check.is_pending or check.is_failed:
             self.assertIn(check.group, ['Generic', 'R'])
Ejemplo n.º 23
0
 def test_bad_specfile(self):        
     os.chdir('bad-spec')
     if os.path.exists('python-test'):
         shutil.rmtree('python-test')
     sys.argv = ['fedora-review','-pn','python-test']
     Settings.init(True)
     ReviewDirs.reset()
     ReviewDirs.workdir_setup('.', True)
     bug = NameBug('python-test')
     check = self.run_single_check(bug,'CheckSpecAsInSRPM')
     self.assertEqual(check.state, 'fail')
     self.assertTrue('#TestTag' in check.attachments[0].text)
     os.chdir(self.startdir)
Ejemplo n.º 24
0
 def test_107_source_same_as_name(self):
     """ Test the case when Source is equal to %{name}
     """
     srpm_file = os.path.join(os.path.abspath('.'),
                                   'test_regressions',
                                   'test_107_2-1.0-1.fc17.src.rpm')
     self.init_test('test_regressions',
                    argv=['-rn', srpm_file, '--cache'])
     ReviewDirs.reset(os.getcwd())
     bug = NameBug(srpm_file)
     bug.find_urls()
     self.assertNotEqual(None, bug.srpm_file)
     self.assertNotEqual(None, bug.spec_file)
Ejemplo n.º 25
0
 def test_rpm_spec(self):
     sys.argv = ['fedora-review','-rn','python-test']
     Settings.init(True)
     ReviewDirs.reset()
     if os.path.exists('python-test'):
         shutil.rmtree('python-test')
     bug = NameBug('python-test')
     bug.find_urls()
     expected = 'src/test/python-test-1.0-1.fc16.src.rpm'
     self.assertTrue(bug.srpm_url.endswith(expected))
     expected = 'src/test/python-test/srpm-unpacked/python-test.spec'
     self.assertTrue(bug.spec_url.endswith(expected))
     os.chdir(self.startdir)
Ejemplo n.º 26
0
 def test_md5sum_diff_fail(self):
     self.init_test('md5sum-diff-fail',
                    argv=['-rpn','python-test', '--cache',
                          '--no-build'])
     ReviewDirs.reset(os.getcwd())
     bug = NameBug('python-test')
     bug.find_urls()
     checks = Checks(bug.spec_file, bug.srpm_file).get_checks()
     checks.set_single_check('CheckSourceMD5')
     check = checks['CheckSourceMD5']
     check.run()
     self.assertTrue(check.is_failed)
     expected = 'diff -r also reports differences'
     self.assertTrue(expected in check.result.attachments[0].text)
Ejemplo n.º 27
0
 def test_review_dir(self):
     ''' Test ReviewDir setup functions. '''
     self.init_test('.', argv=['-n', 'python-test', '--no-build'])
     from FedoraReview.review_dirs import _ReviewDirs
     os.chdir('review_dir')
     check_output('rm -rf testdirs; mkdir testdirs', shell=True)
     ReviewDirs.workdir_setup('testdirs', 'testing')
     check_output(['touch', 'results/dummy.rpm'])
     os.chdir('..')
     rd = _ReviewDirs()
     rd.workdir_setup('testdirs')
     self.assertEqual(len(glob.glob('*')), 7)
     self.assertEqual(os.path.basename(os.getcwd()), 'testdirs')
     self.assertTrue(os.path.exists('results/dummy.rpm'))
     self.assertEqual(glob.glob('BUILD/*'), ['BUILD/pkg-1.0'])
Ejemplo n.º 28
0
 def test_srv_opt(self):
     ''' Test check of no files in /srv, /opt and /usr/local. '''
     self.init_test('srv-opt',
                    argv=['-rn','dummy', '--cache',
                           '--no-build'])
     ReviewDirs.reset(os.getcwd())
     bug = NameBug('dummy')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     check = checks.checkdict['CreateEnvCheck'].run()
     check = checks.checkdict['check-srv-opt-local']
     check.run()
     self.assertTrue( '/srv' in check.result.output_extra)
     self.assertTrue( '/opt' in check.result.output_extra)
     self.assertTrue( '/usr/local' in check.result.output_extra)
Ejemplo n.º 29
0
 def test_bugzilla_bug(self):
     sys.argv = ['fedora-review', '-b', '817268']
     Settings.init(True)
     ReviewDirs.reset()
     ReviewDirs.workdir_setup('.', True)
     bug = BugzillaBug('817268')
     bug.find_urls()
     expected ='http://dl.dropbox.com/u/17870887/python-faces-0.11.7-2' \
               '/python-faces-0.11.7-2.fc16.src.rpm'
     self.assertEqual(expected, bug.srpm_url)
     expected = 'http://dl.dropbox.com/u/17870887/python-faces-0.11.7-2/' \
                'python-faces.spec'
     self.assertEqual(expected, bug.spec_url)
     self.assertEqual(None, bug.spec_file)
     self.assertEqual(None, bug.srpm_file)
     os.chdir(self.startdir)
Ejemplo n.º 30
0
 def test_perl_module(self):
     ''' test basic perl python + shell test '''
     self.init_test('perl',
                    argv=['-rn','perl-RPM-Specfile', '--no-build'])
     ReviewDirs.reset(os.getcwd())
     bug = NameBug('perl-RPM-Specfile')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     checks.checkdict['CreateEnvCheck'].run()
     check = checks.checkdict['PerlCheckBuildRequires']
     check.run()
     self.assertTrue(check.is_pending)
     check = checks.checkdict['perl-url-tag']
     check.run()
     self.assertTrue(check.is_pending)
Ejemplo n.º 31
0
 def test_bugzilla_bug(self):
     sys.argv = ['fedora-review','-b','817268']
     Settings.init(True)
     ReviewDirs.reset()
     ReviewDirs.workdir_setup('.', True)
     bug = BugzillaBug('817268')
     bug.find_urls()
     expected ='http://dl.dropbox.com/u/17870887/python-faces-0.11.7-2' \
               '/python-faces-0.11.7-2.fc16.src.rpm'
     self.assertEqual(expected, bug.srpm_url)
     expected = 'http://dl.dropbox.com/u/17870887/python-faces-0.11.7-2/' \
                'python-faces.spec'
     self.assertEqual(expected, bug.spec_url)
     self.assertEqual(None, bug.spec_file)
     self.assertEqual(None, bug.srpm_file)
     os.chdir(self.startdir)
Ejemplo n.º 32
0
 def setUp(self):
     self.startdir = os.getcwd()
     sys.argv = ['test-checks', '-b', '1234']
     Settings.init(True)
     ReviewDirs.reset()
     ReviewDirs.workdir_setup('.', True)
     if not os.path.exists(TEST_WORK_DIR):
         os.makedirs(TEST_WORK_DIR)
     self.checks = None
     self.srpm = TEST_WORK_DIR + os.path.basename(TEST_SRPM)
     self.spec = TEST_WORK_DIR + os.path.basename(TEST_SPEC)
     self.source = TEST_WORK_DIR + os.path.basename(TEST_SRC)
     helper = Helpers()
     helper._get_file(TEST_SRPM, TEST_WORK_DIR)
     helper._get_file(TEST_SRC, TEST_WORK_DIR)
     helper._get_file(TEST_SPEC, TEST_WORK_DIR)
     del helper
Ejemplo n.º 33
0
 def setUp(self):
     self.startdir = os.getcwd()
     sys.argv = ['test-checks','-b','1234']
     Settings.init(True)
     ReviewDirs.reset()
     ReviewDirs.workdir_setup('.', True)
     if not os.path.exists(TEST_WORK_DIR):
         os.makedirs(TEST_WORK_DIR)
     self.checks = None
     self.srpm = TEST_WORK_DIR + os.path.basename(TEST_SRPM)
     self.spec = TEST_WORK_DIR + os.path.basename(TEST_SPEC)
     self.source = TEST_WORK_DIR + os.path.basename(TEST_SRC)
     helper = Helpers()
     helper._get_file(TEST_SRPM, TEST_WORK_DIR)
     helper._get_file(TEST_SRC, TEST_WORK_DIR)
     helper._get_file(TEST_SPEC, TEST_WORK_DIR)
     del helper
Ejemplo n.º 34
0
 def test_spec_file(self):
     ''' Test the SpecFile class'''
     ReviewDirs.reset()
     ReviewDirs.workdir_setup('.', True)
     dest = Mock.get_builddir('SOURCES')
     if not os.path.exists(dest):
         os.makedirs(dest)
     self.helpers._get_file(TEST_SPEC, Mock.get_builddir('SOURCES'))
     spec = SpecFile(self.spec_file)
     # Test misc rpm values (Macro resolved)
     self.assertEqual(spec.name,'python-test')
     self.assertEqual(spec.version,'1.0')
     # resolve the dist-tag
     dist = self.helpers._run_cmd('rpm --eval %dist')[:-1]
     self.assertEqual(spec.release,'1'+dist)
     # test misc rpm values (without macro resolve)
     self.assertEqual(spec.find_tag('Release'), ['1%{?dist}'])
     self.assertEqual(spec.find_tag('License'), ['GPLv2+'])
     self.assertEqual(spec.find_tag('Group'), ['Development/Languages'])
     # Test rpm value not there
     self.assertEqual(spec.find_tag('PreReq'), [])
     # Test get sections
     expected = {'%clean': ['rm -rf $RPM_BUILD_ROOT']}
     self.assertEqual(spec.get_section('%clean'), expected)
     expected = {'%build': ['%{__python} setup.py build']}
     self.assertEqual(spec.get_section('%build'), expected)
     expected = {'%install': ['rm -rf $RPM_BUILD_ROOT', 
                 '%{__python} setup.py install -O1 --skip-build'
                 ' --root $RPM_BUILD_ROOT']}
     self.assertEqual(spec.get_section('%install'),expected)
     expected = {'%files': ['%defattr(-,root,root,-)', 
                 '%doc COPYING', '%{python_sitelib}/*']}
     self.assertEqual(spec.get_section('%files'),expected)
     # Test get_sources (return the Source/Patch lines with macros resolved)
     expected = {'Source0': 'http://timlau.fedorapeople.org/'
                 'files/test/review-test/python-test-1.0.tar.gz'}
     self.assertEqual(spec.get_sources(), expected)
     # Test find
     regex = re.compile(r'^Release\s*:\s*(.*)')
     res = spec.find(regex)
     if res:
         self.assertEqual(res.groups(), ('1%{?dist}',))
     else:
         self.assertTrue(False)
     os.chdir(self.startdir)
Ejemplo n.º 35
0
 def test_md5sum_diff_fail(self):
     os.chdir('md5sum-diff-fail')
     sys.argv = ['fedora-review', '-rpn', 'python-test']
     Settings.init(True)
     ReviewDirs.reset()
     if os.path.exists('python-test'):
         shutil.rmtree('python-test')
     bug = NameBug('python-test')
     bug.find_urls()
     checks = Checks(bug.spec_file, bug.srpm_file)
     checks.set_single_check('CheckSourceMD5')
     self.assertEqual(len(checks.checks), 1)
     check = checks.checks[0]
     check.run()
     self.assertEqual(check.state, 'fail')
     expected = 'diff -r also reports differences'
     self.assertTrue(expected in check.attachments[0].text)
     os.chdir(self.startdir)
Ejemplo n.º 36
0
 def test_md5sum_diff_fail(self):        
     os.chdir('md5sum-diff-fail')
     sys.argv = ['fedora-review','-rpn','python-test']
     Settings.init(True)
     ReviewDirs.reset()
     if os.path.exists('python-test'):
         shutil.rmtree('python-test')
     bug = NameBug('python-test')
     bug.find_urls()
     checks = Checks(bug.spec_file, bug.srpm_file)
     checks.set_single_check('CheckSourceMD5')
     self.assertEqual(len(checks.checks), 1)
     check = checks.checks[0]
     check.run()
     self.assertEqual(check.state, 'fail')
     expected = 'diff -r also reports differences'
     self.assertTrue(expected in check.attachments[0].text)
     os.chdir(self.startdir)
Ejemplo n.º 37
0
    def __do_report(self):
        ''' Create a review report'''
        self.log.info('Getting .spec and .srpm Urls from : '
                       + self.bug.get_location())

        Settings.dump()
        if not self.bug.find_urls():
            raise self.HelperError('Cannot find .spec or .srpm URL(s)')

        if not ReviewDirs.is_inited:
            wd = self.bug.get_dirname()
            ReviewDirs.workdir_setup(wd)

        if not self.bug.download_files():
            raise self.HelperError('Cannot download .spec and .srpm')

        Settings.name = self.bug.get_name()
        self.__run_checks(self.bug.spec_file, self.bug.srpm_file)
Ejemplo n.º 38
0
    def test_jsonapi(self):
        self.init_test('test_misc',
                       argv=['-rpn','python-test', '--no-build'])
        ReviewDirs.reset(os.getcwd())
        os.environ['REVIEW_EXT_DIRS'] = os.path.normpath(os.getcwd() + '/../api')

        bug = NameBug('python-test')
        bug.find_urls()
        bug.download_files()
        checks = Checks(bug.spec_file, bug.srpm_file).get_checks()
        test1 = checks['test1']
        test2 = checks['ExtShellTest2']
        self.assertEqual( test1.group, 'Generic')
        self.assertEqual( test1.type, 'EXTRA')
        self.assertEqual( test1.text, 'A check solely for test purposes.')

        self.assertEqual( test2.group, 'Generic')
        self.assertEqual( test2.type, 'EXTRA')
        self.assertEqual( test2.text,
                          'A second check solely for test purposes.')
Ejemplo n.º 39
0
    def __do_report(self):
        ''' Create a review report'''
        self.log.info('Getting .spec and .srpm Urls from : ' +
                      self.bug.get_location())

        Settings.dump()
        if not self.bug.find_urls():
            self.log.error('Cannot find .spec or .srpm URL(s)')
            raise HandledError()

        if not ReviewDirs.is_inited:
            wd = self.bug.get_dirname()
            ReviewDirs.workdir_setup(wd)

        if not self.bug.download_files():
            self.log.error('Cannot download .spec and .srpm')
            raise HandledError()

        Settings.name = self.bug.get_name()
        self.__run_checks(self.bug.spec_file, self.bug.srpm_file)
Ejemplo n.º 40
0
    def test_rpm_spec(self):
        """ Test --rpm-spec/-r option """
        self.init_test(["fedora-review", "-rn", "python-test"], "desktop-file")
        if os.path.exists("python-test"):
            shutil.rmtree("python-test")
        ReviewDirs.reset()
        bug = NameBug(Settings.name)
        bug.find_urls()

        expected = abs_file_url("../python-test-1.0-1.fc16.src.rpm")
        self.assertEqual(expected, bug.srpm_url)
        expected = abs_file_url("./srpm-unpacked/python-test.spec")
        self.assertEqual(expected, bug.spec_url),

        bug.download_files()
        expected = os.path.abspath("../python-test-1.0-1.fc16.src.rpm")
        self.assertEqual(expected, bug.srpm_file),
        expected = os.path.abspath("./srpm-unpacked/python-test.spec")
        self.assertEqual(expected, bug.spec_file),
        os.chdir(startdir)
Ejemplo n.º 41
0
 def test_sources(self):
     if os.path.exists('python-test'):
         shutil.rmtree('python-test')
     sys.argv = ['fedora-review', '-n', 'python-test']
     Settings.init(True)
     ReviewDirs.reset()
     ReviewDirs.workdir_setup('.', True)
     bug = NameBug('python-test')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     checks.set_single_check('CheckSourceMD5')
     self.assertEqual(len(checks.checks), 1)
     check = checks.checks[0]
     check.run()
     result = check.get_result()
     self.log.debug('result : ' + result.result)
     if result.output_extra:
         self.log.debug("Result extra text: " + result.output_extra)
     self.assertEqual(result.result, 'pass')
     os.chdir(self.startdir)
Ejemplo n.º 42
0
    def test_git_source(self):
        ''' test use of local source0 tarball '''

        argv = ['fedora-review', '-rpn', 'get-flash-videos']
        argv.extend(['--mock-config', 'fedora-16-i386-rpmfusion_nonfree'])
        sys.argv = argv
        os.chdir('git-source')
        if os.path.exists('get-flash-videos'):
            shutil.rmtree('get-flash-videos')
        ReviewDirs.reset()
        Settings.init(True)
  
        rh = ReviewHelper()
        sys.stdout = open( '/dev/null', 'w')
        rh.run()
        sys.stdout = sys.__stdout__
        rv = 'get-flash-videos-review.txt'
        with open(os.path.abspath(rv)) as f:
            log = f.read()
        self.assertIn('Using local file' , log)
        os.chdir(startdir)
Ejemplo n.º 43
0
 def setUp(self):
     sys.argv = ['fedora-review', '-n', 'python-test', '--prebuilt']
     Settings.init(True)
     ReviewDirs.reset()
     ReviewDirs.workdir_setup('.', True)
     self.log = Settings.get_logger()
     self.helpers = Helpers()
     self.srpm_file = os.path.join(os.path.abspath('.'),
                                   os.path.basename(TEST_SRPM))
     self.spec_file = os.path.join(Mock.get_builddir('SOURCES'),
                                   os.path.basename(TEST_SPEC))
     self.source_file = os.path.join(Mock.get_builddir('SOURCES'),
                                     os.path.basename(TEST_SRC))
     if not os.path.exists(TEST_WORK_DIR):
         os.makedirs(TEST_WORK_DIR)
     self.helpers._get_file(TEST_SRPM, TEST_WORK_DIR)
     self.startdir = os.getcwd()
     for tree in ['python-test', 'results']:
         if os.path.exists(tree):
             shutil.rmtree(tree)
     Mock.reset()
Ejemplo n.º 44
0
    def test_rpm_spec(self):
        """ Test --rpm-spec/-r option """
        self.init_test(['fedora-review','-rn','python-test'],
                       'desktop-file')
        if os.path.exists('python-test'):
            shutil.rmtree('python-test')
        ReviewDirs.reset()
        bug = NameBug(Settings.name)
        bug.find_urls()

        expected = abs_file_url('../python-test-1.0-1.fc16.src.rpm')
        self.assertEqual(expected, bug.srpm_url)
        expected = abs_file_url('./srpm-unpacked/python-test.spec')
        self.assertEqual(expected, bug.spec_url),

        bug.download_files()
        expected = os.path.abspath('../python-test-1.0-1.fc16.src.rpm')
        self.assertEqual(expected, bug.srpm_file),
        expected = os.path.abspath('./srpm-unpacked/python-test.spec')
        self.assertEqual(expected, bug.spec_file),
        os.chdir(startdir)
Ejemplo n.º 45
0
 def test_sources(self):
     if os.path.exists('python-test'):
         shutil.rmtree('python-test')
     sys.argv = ['fedora-review','-n','python-test']
     Settings.init(True)
     ReviewDirs.reset()
     ReviewDirs.workdir_setup('.', True)
     bug = NameBug('python-test')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     checks.set_single_check('CheckSourceMD5')
     self.assertEqual(len(checks.checks), 1)
     check = checks.checks[0]
     check.run()
     result = check.get_result()
     self.log.debug('result : ' + result.result)
     if result.output_extra:
        self.log.debug("Result extra text: " + result.output_extra)
     self.assertEqual( result.result, 'pass')
     os.chdir(self.startdir)
Ejemplo n.º 46
0
 def setUp(self):
     sys.argv = ['fedora-review','-n','python-test','--prebuilt']
     Settings.init(True)
     ReviewDirs.reset()
     ReviewDirs.workdir_setup('.', True)
     self.log = Settings.get_logger()
     self.helpers = Helpers()
     self.srpm_file = os.path.join(os.path.abspath('.'),
                                   os.path.basename(TEST_SRPM))
     self.spec_file = os.path.join(Mock.get_builddir('SOURCES'),
                                     os.path.basename(TEST_SPEC))
     self.source_file = os.path.join(Mock.get_builddir('SOURCES'),
                                     os.path.basename(TEST_SRC))
     if not os.path.exists(TEST_WORK_DIR):
         os.makedirs(TEST_WORK_DIR)
     self.helpers._get_file(TEST_SRPM, TEST_WORK_DIR)
     self.startdir = os.getcwd()
     for tree in ['python-test', 'results']:
         if os.path.exists(tree):
             shutil.rmtree(tree)
     Mock.reset()
Ejemplo n.º 47
0
    def test_git_source(self):
        """ test use of local source0 tarball """

        argv = ["fedora-review", "-rpn", "get-flash-videos"]
        argv.extend(["--mock-config", "fedora-16-i386-rpmfusion_nonfree"])
        sys.argv = argv
        os.chdir("git-source")
        if os.path.exists("get-flash-videos"):
            shutil.rmtree("get-flash-videos")
        ReviewDirs.reset()
        Settings.init(True)

        rh = ReviewHelper()
        sys.stdout = open("/dev/null", "w")
        rh.run()
        sys.stdout = sys.__stdout__
        rv = "get-flash-videos-review.txt"
        with open(os.path.abspath(rv)) as f:
            log = f.read()
        self.assertIn("Using local file", log)
        os.chdir(startdir)
Ejemplo n.º 48
0
 def test_srpm_mockbuild(self):
     """ Test the SRPMFile class """
     ReviewDirs.reset()
     ReviewDirs.workdir_setup('.', True)
     sys.argv = ['fedora-review', '-b', '817268', '-m', 'fedora-16-i386']
     Settings.init(True)
     self.helpers._get_file(TEST_SRPM, os.path.abspath('.'))
     srpm = SRPMFile(self.srpm_file)
     # install the srpm
     srpm.unpack()
     self.assertTrue(hasattr(srpm, 'unpacked_src'))
     src_dir = srpm.unpacked_src
     src_files = glob.glob(os.path.expanduser(src_dir) + '/*')
     src_files = [os.path.basename(f) for f in src_files]
     self.assertTrue('python-test-1.0.tar.gz' in src_files)
     self.log.info("Starting mock build (patience...)")
     srpm.mockbuild()
     self.assertTrue(srpm.is_build)
     rpms = glob.glob(
         os.path.join(Mock.resultdir, 'python-test-1.0-1*noarch.rpm'))
     self.assertEqual(1, len(rpms))
     os.chdir(self.startdir)
Ejemplo n.º 49
0
 def __run_checks(self, spec, srpm):
     self.checks = Checks(spec, srpm)
     if Settings.no_report:
         self.outfile = '/dev/null'
     else:
         self.outfile = ReviewDirs.report_path(self.checks.spec.name)
     with open(self.outfile, "w") as output:
         if Settings.nobuild:
             self.checks.srpm.is_build = True
         self.log.info('Running checks and generate report\n')
         self.checks.run_checks(output=output,
                                writedown=not Settings.no_report)
         output.close()
     if not os.path.exists('BUILD'):
         os.symlink(Mock.get_builddir('BUILD'), 'BUILD')
     if not Settings.no_report:
         print "Review in: " + self.outfile
Ejemplo n.º 50
0
 def setUp(self):
     sys.argv = ['test-bugzilla','-b',TEST_BUG ]
     Settings.init(TEST_BUG )
     ReviewDirs.workdir_setup('.', True)
     self.bug = BugzillaBug(TEST_BUG)