Пример #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')
Пример #2
0
 def test_exclude(self):
     ''' test --exclude/-x option. '''
     self.init_opt_test(['-n', 'python-test', '-x', 'CheckRequires',
                         '--cache'])
     bug = NameBug(Settings.name)
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     self.assertTrue(checks.checkdict['CheckRequires'].result is None)
Пример #3
0
 def test_flags_2(self):
     ''' Flag defined in python, not set by user' '''
     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)
     self.assertFalse(checks.flags['EPEL5'])
Пример #4
0
 def test_single(self):
     ''' test --single/-s option '''
     self.init_opt_test(['-n', 'python-test', '-s', 'CheckRequires',
                         '--cache'])
     bug = NameBug(Settings.name)
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     check = checks.checkdict['CheckRequires']
     self.assertEqual(check.name, 'CheckRequires')
Пример #5
0
 def test_prebuilt_sources(self):
     ''' Local built RPM:s (-n) test. '''
     self.init_test('test_misc',
                    argv=['-cn', 'python-test', '--prebuilt'])
     ReviewDirs.startdir = os.getcwd()
     bug = NameBug('python-test')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     subprocess.check_call('touch orvar.rpm', shell=True)
     rpms = Mock.get_package_rpm_paths(checks.spec)
     self.assertEqual(len(rpms), 1)
Пример #6
0
    def test_flags_4(self):
        ''' Flag defined in shell script , set by user to value '''

        os.environ['XDG_DATA_HOME'] = os.getcwd()
        self.init_test('test_misc',
                       argv=['-n', 'python-test', '--cache',
                             '--no-build', '-D', 'EPEL6=foo'])
        bug = NameBug('python-test')
        bug.find_urls()
        bug.download_files()
        checks = Checks(bug.spec_file, bug.srpm_file)
        self.assertEqual(str(checks.flags['EPEL6']), 'foo')
Пример #7
0
 def test_local_repo(self):
     ''' Local repo with prebuilt rpms test. '''
     self.init_test('test_misc',
                    argv=['-rn', 'python-test', '--local-repo',
                          'repo', '--cache'])
     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)
Пример #8
0
    def test_flags_3(self):
        ''' Flag not defined , set by user' '''

        self.init_test('test_misc',
                       argv=['-n', 'python-test', '--cache',
                             '--no-build', '-D', 'EPEL8'])
        bug = NameBug('python-test')
        bug.find_urls()
        bug.download_files()
        with self.assertRaises(ReviewError):
            # pylint: disable=W0612
            checks = Checks(bug.spec_file, bug.srpm_file)
Пример #9
0
 def test_sh_api(self):
     ''' Basic shell API test. '''
     self.init_test('test_ext',
                    argv=['-pn', 'python-test', '--cache',
                           '--no-build'],
                    wd='review-python-test')
     bug = NameBug('python-test')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     checks.checkdict['CreateEnvCheck'].run()
     checks.checkdict['unittest-test2'].run()
     self.assertTrue(checks.checkdict['unittest-test2'].is_pending)
Пример #10
0
    def test_prebuilt(self):
        ''' test --name --prebuilt '''

        argv = ['-rpn', 'python-spiffgtkwidgets', '--cache']
        self.init_test('prebuilt', argv=argv)
        bug = NameBug('python-spiffgtkwidgets')
        bug.find_urls()
        bug.download_files()
        checks = Checks(bug.spec_file, bug.srpm_file)
        check = checks.checkdict['CheckBuild']
        check.run()
        self.assertTrue(check.is_pending)
        self.assertIn('Using prebuilt packages',
                       check.result.output_extra)
Пример #11
0
 def test_bad_specname(self):
     ''' Specfile with bad name test. '''
     loglevel = os.environ['REVIEW_LOGLEVEL']
     os.environ['REVIEW_LOGLEVEL'] = 'ERROR'
     self.init_test('bad-specname',
                    argv=['-rn', 'python-test', '--cache'])
     os.environ['REVIEW_LOGLEVEL'] = loglevel
     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)
Пример #12
0
 def test_perl_module(self):
     ''' test basic perl python + shell test '''
     self.init_test('perl',
                    argv=['-rpn', 'perl-RPM-Specfile', '--no-build'])
     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)
Пример #13
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)
Пример #14
0
    def test_name(self):
        """ Test -name option """
        self.init_opt_test(['-n', 'python-test', '--cache'])
        bug = NameBug(Settings.name)

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

        bug.download_files()
        expected = os.path.abspath('./python-test-1.0-1.fc17.src.rpm')
        self.assertEqual(expected, bug.srpm_file)
        expected = os.path.abspath('./python-test.spec')
        self.assertEqual(expected, bug.spec_file)
Пример #15
0
    def test_rpm_spec(self):
        """ Test --rpm-spec/-r option """
        self.init_opt_test(['-rn', 'python-test', '--cache'], 'options')
        bug = NameBug(Settings.name)
        bug.find_urls()

        expected = self.abs_file_url('python-test-1.0-1.fc17.src.rpm')
        self.assertEqual(expected, bug.srpm_url)
        expected = self.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.fc17.src.rpm')
        self.assertEqual(expected, bug.srpm_file)
        expected = os.path.abspath('srpm-unpacked/python-test.spec')
        self.assertEqual(expected, bug.spec_file)
Пример #16
0
 def test_mock_options(self):
     ''' test -o/--mock-options and -m/mock-config '''
     nextrelease = '%d' % (int(RELEASE) + 1)
     v = nextrelease if RELEASE in self.BUILDROOT else RELEASE
     buildroot = 'fedora-%s-i386' % v
     self.init_test('mock-options',
                    argv = ['-n', 'python-test', '--cache'],
                    options='--resultdir=results --uniqueext=foo',
                    buildroot=buildroot)
     bug = NameBug('python-test')
     bug.find_urls()
     bug.download_files()
     mock_cmd = ' '.join(Mock._mock_cmd())
     Mock._get_root()
     self.assertIn('-r ' + buildroot, mock_cmd)
     self.assertEqual(Mock.mock_root, buildroot + '-foo')
Пример #17
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'])
     os.chdir('..')
     bug = NameBug('dummy')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     check = checks.checkdict['CheckBuildCompleted'].run()
     check = checks.checkdict['CreateEnvCheck'].run()
     check = checks.checkdict['generic-srv-opt']
     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)
Пример #18
0
 def test_rpm_source(self):
     ''' Test a rpm datasource. '''
     self.init_test('test_misc',
                    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)
     src = RpmDataSource(checks.spec)
     files = src.get_filelist()
     self.assertEqual(len(files), 11)
     rpms = src.get_all()
     self.assertEqual(rpms, ['python-test'])
     rpm_pkg = src.get('python-test')
     self.assertEqual(rpm_pkg.header['name'], 'python-test')
     all_files = src.find_all('*')
     self.assertEqual(len(all_files), 11)
Пример #19
0
 def test_buildsrc(self):
     ''' Test a BuildFilesData  datasource. '''
     self.init_test('perl',
                    argv=['-rpn', 'perl-RPM-Specfile', '--no-build'],
                    wd='perl-RPM-Specfile')
     bug = NameBug('perl-RPM-Specfile')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)  # pylint: disable=W0612
     src = BuildFilesSource()
     files = src.get_filelist()
     self.assertEqual(len(files), 8)
     root = src.get_all()
     expected_root = os.getcwd() + '/BUILD/RPM-Specfile-1.51'
     self.assertEqual(src.get_all(), [expected_root])
     root = src.get()
     self.assertEqual(root, expected_root)
     all_files = src.find_all('*')
     self.assertEqual(len(all_files), 8)
Пример #20
0
    def test_sh_attach(self):
        ''' Test shell attachments. '''

        self.init_test('test_ext',
                       argv=['-rn', 'python-test', '--no-build'])
        bug = NameBug('python-test')
        bug.find_urls()
        bug.download_files()
        checks = Checks(bug.spec_file, bug.srpm_file).get_checks()
        checks['CreateEnvCheck'].run()
        check = checks['test-attachments']
        check.run()
        self.assertEqual(len(check.result.attachments), 2)
        a1 = filter(lambda a: 'attachment 1' in a.text,
                    check.result.attachments)[0]
        a2 = filter(lambda a: 'attachment 2' in a.text,
                    check.result.attachments)[0]
        self.assertEqual('Heading 1', a1.header)
        self.assertEqual(8, a1.order_hint)
        self.assertEqual('Heading 2', a2.header)
        self.assertEqual(9, a2.order_hint)
Пример #21
0
    def test_git_source(self):
        ''' test use of local source0 tarball '''

        self.init_test('git-source',
                       argv= ['-rpn', 'get-flash-videos', '--cache'],
                       wd='get-flash-videos',
                       buildroot='fedora-%s-i386' % RELEASE)
        os.chdir('..')

        bug = NameBug('get-flash-videos')
        bug.find_urls()
        bug.download_files()
        checks = Checks(bug.spec_file, bug.srpm_file)
        #if not Mock.is_installed('rpmbuild'):
        #    Mock.install(['rpmbuild'])
        #check = checks.checkdict['CheckBuildCompleted']
        #check.run()
        check = checks.checkdict['CheckSourceMD5']
        check.run()
        self.assertTrue(check.is_passed)
        self.assertIn('Using local file',
                      check.result.attachments[0].text)
Пример #22
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)
Пример #23
0
 def test_mock_uniqueext(self):
     ''' Test --uniqueext option. '''
     loglevel = os.environ['REVIEW_LOGLEVEL']
     os.environ['REVIEW_LOGLEVEL'] = 'ERROR'
     self.init_test('mock-uniqueext',
                    argv=['-cn', 'python-test'],
                    options='--uniqueext=hugo')
     os.environ['REVIEW_LOGLEVEL'] = loglevel
     bug = NameBug('python-test')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     Mock.init()
     for dirt in glob.glob('results/*.*'):
         os.unlink(dirt)
     check = checks.checkdict['CheckBuild']
     check.run()
     self.assertTrue(check.is_passed)
     results = glob.glob('results/*.rpm')
     self.assertEqual(len(results), 2)
     for dirt in glob.glob('results/*.*'):
         os.unlink(dirt)
Пример #24
0
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)