Esempio n. 1
0
    def test_dirty_resultdir(self):
        ''' Test that non-empty resultdir quits. '''
        self.init_test('test_misc',
                       argv=['-n', 'python-test', '--cache'])
        bug = NameBug('python-test')
        bug.find_urls()
        bug.download_files()
        checks = Checks(bug.spec_file, bug.srpm_file).get_checks()
        checks.set_single_check('CheckResultdir')
        check = checks['CheckResultdir']
        if not os.path.exists('results.bak'):
            os.makedirs('results.bak')
        for dirt in glob.glob('results/*.*'):
            shutil.move(dirt, 'results.bak')
        check.run()
        self.assertTrue(check.is_na)

        try:
            subprocess.check_call('touch results/orvar.rpm', shell=True)
        except OSError:
            pass
        self.assertRaises(ReviewError, check.run)
        Settings.nobuild = True
        check.run()
        self.assertTrue(check.is_na)
        os.unlink('results/orvar.rpm')
        for dirt in glob.glob('results.bak/*'):
            shutil.move(dirt, 'results')
Esempio n. 2
0
 def run_single_check(bug, check_name, run_build=False):
     ''' Run a single check, return check.'''
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file).get_checks()
     checks.set_single_check(check_name)
     if run_build:
         checks['CheckBuild'].run()
     check = checks[check_name]
     check.run()
     return check
Esempio n. 3
0
 def test_md5sum_diff_ok(self):
     ''' Complete MD5sum test expected to pass. '''
     self.init_test('md5sum-diff-ok',
                    argv=['-rpn', 'python-test', '--cache',
                          '--no-build'])
     bug = NameBug('python-test')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file).get_checks()
     checks.set_single_check('CheckSourceMD5')
     check = checks['CheckSourceMD5']
     check.run()
     self.assertTrue(check.is_passed)
     expected = 'diff -r shows no differences'
     self.assertTrue(expected in check.result.attachments[0].text)
Esempio n. 4
0
 def test_md5sum_diff_fail(self):
     ''' Complete MD5sum test expected to fail. '''
     loglevel = os.environ['REVIEW_LOGLEVEL']
     os.environ['REVIEW_LOGLEVEL'] = 'ERROR'
     self.init_test('md5sum-diff-fail',
                    argv=['-rpn', 'python-test', '--cache',
                          '--no-build'])
     os.environ['REVIEW_LOGLEVEL'] = loglevel
     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)
Esempio n. 5
0
 def test_sources_data(self):
     ''' Test a SourcesDataSource. '''
     self.init_test('test_misc',
                    argv=['-n', 'python-test', '--cache',
                          '--no-build'])
     bug = NameBug('python-test')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file).get_checks()
     checks.set_single_check('CheckSourceMD5')
     check = checks['CheckSourceMD5']
     check.run()
     result = check.result
     self.log.debug('test_source, result : ' + result.result)
     if result.output_extra:
         self.log.debug("Result extra text: " + result.output_extra)
     self.assertTrue(check.is_passed)
     paths = check.checks.sources.find_all_re('.*[.]py')
     files = [os.path.basename(p) for p in paths]
     self.assertEqual(set(files), set(['setup.py', '__init__.py']))
     files = check.checks.sources.get_filelist()
     self.assertEqual(len(files), 10)
 def test_all_checks(self):
     ''' Run all automated review checks'''
     self.init_test('test-R',
                     argv=['-rpn', 'R-Rdummypkg', '--no-build'])
     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 not os.path.exists('test-R/rpms-unpacked'):
         #    os.mkdir('test-R/rpms-unpacked')
         if check.is_passed or check.is_pending or check.is_failed:
             ok_groups = ['Generic.build', 'Generic', 'Generic.should', 'R']
             self.assertIn(check.group, ok_groups)
class TestRChecks(FR_TestCase):
    ''' Some R specific tests. '''

    R_TEST_SRPM = 'https://fedorahosted.org/releases/F/e' \
                  '/FedoraReview/R-Rdummypkg-1.0-2.fc15.src.rpm'
    R_TEST_SPEC = FR_TestCase.BASE_URL + 'R-Rdummypkg.spec'
    R_TEST_SRC  = FR_TestCase.BASE_URL + 'Rdummypkg_1.0.tar.gz'

    def setUp(self):
        if not srcpath.PLUGIN_PATH in sys.path:
            sys.path.append(srcpath.PLUGIN_PATH)
        self.startdir = os.getcwd()

    def test_good_R_spec(self):
        ''' test R spec, expected to pass. '''
        # pylint: disable=F0401,R0201,C0111

        from plugins.R import RCheckInstallSection

        class ChecksMockup(object):
            pass

        class ApplicableRCheckInstallSection(RCheckInstallSection):
            def is_applicable(self):
                return True

        self.init_test('test-R',
                        argv=['-rpn', 'R-Rdummypkg', '--no-build'])
        spec = SpecFile(os.path.join(os.getcwd(), 'R-Rdummypkg.spec'))
        check = ApplicableRCheckInstallSection(ChecksMockup())
        check.checks.spec = spec
        check.run()
        self.assertTrue(check.is_passed)

    def test_bad_R_spec(self):
        ''' test R spec, expected to fail. '''
        # pylint: disable=F0401,R0201,C0111

        from plugins.R import RCheckInstallSection

        class ChecksMockup(object):
            pass

        class ApplicableRCheckInstallSection(RCheckInstallSection):
            def is_applicable(self):
                return True

        self.init_test('test-R',
                        argv=['-rpn', 'R-Rdummypkg', '--no-build'])
        spec = SpecFile(os.path.join(os.getcwd(), 'R-Rdummypkg-bad.spec'))
        check = ApplicableRCheckInstallSection(ChecksMockup())
        check.checks.spec = spec
        check.run()
        note = check.result.output_extra
        self.assertTrue(check.is_failed)
        self.assertTrue('directory creation' in note)
        self.assertTrue('removal of *.o and *.so' in note)
        self.assertTrue('removal of the R.css file' in note)
        self.assertTrue('R CMD INSTALL function' in note)

    @unittest.skipIf(FAST_TEST, 'slow test disabled by REVIEW_FAST_TEST')
    def test_all_checks(self):
        ''' Run all automated review checks'''
        self.init_test('test-R',
                        argv=['-rpn', 'R-Rdummypkg', '--no-build'])
        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 not os.path.exists('test-R/rpms-unpacked'):
            #    os.mkdir('test-R/rpms-unpacked')
            if check.is_passed or check.is_pending or check.is_failed:
                ok_groups = ['Generic.build', 'Generic', 'Generic.should', 'R']
                self.assertIn(check.group, ok_groups)