def run(self): bad_pkgs = [] archs = self.checks.spec.expand_tag('BuildArchs') if len(self.spec.packages) == 1: self.set_passed(self.NA) return if len(archs) == 1 and archs[0].lower() == 'noarch': isa = '' else: isa = Mock.get_macro('%_isa', self.spec, self.flags) regex = self.REGEX.replace('%{?_isa}', isa) regex = rpm.expandMacro(regex) regex = re.sub('[.](fc|el)[0-9]+', '', regex) for pkg in self.spec.packages: if pkg == self.spec.base_package: continue for pkg_end in ['debuginfo', '-javadoc', '-doc']: if pkg.endswith(pkg_end): continue reqs = ''.join(self.rpms.get(pkg).format_requires) if regex not in reqs: bad_pkgs.append(pkg) if bad_pkgs: self.set_passed(self.PENDING, self.HDR + ' , '.join(bad_pkgs)) else: self.set_passed(self.PASS)
def test_spec_file(self): ''' Test the SpecFile class''' def fix_usr_link(path): ''' Convert absolute paths to /usr/path. ''' if not '/' in path: return path lead = path.split('/')[1] if lead in ['bin', 'sbin', 'lib', 'lib64']: return '/usr' + path return path self.init_test('test_misc', argv=['-n', 'python-test', '--no-build']) spec = SpecFile(os.path.join(os.getcwd(), 'python-test.spec')) self.assertEqual(spec.name, 'python-test') self.assertEqual(spec.version, '1.0') dist = Mock.get_macro('%dist', None, {}) self.assertEqual(spec.release, '1' + dist) self.assertEqual(spec.expand_tag('Release'), '1' + dist) self.assertEqual(spec.expand_tag('License'), 'GPLv2+') self.assertEqual(spec.expand_tag('Group'), 'Development/Languages') # Test rpm value not there self.assertEqual(spec.expand_tag('PreReq'), None) # Test get sections expected = ['rm -rf $RPM_BUILD_ROOT'] self.assertEqual(spec.get_section('%clean'), expected) expected = '%{__python} setup.py build' expected = ['LANG=C', 'export LANG', 'unset DISPLAY', '/usr/bin/python setup.py build'] build = spec.get_section('%build') build = map(fix_usr_link, build) self.assertIn(''.join(build), ''.join(expected)) install = spec.get_section('%install') install = map(fix_usr_link, install) expected = ['LANG=C', 'export LANG', 'unset DISPLAY', 'rm -rf $RPM_BUILD_ROOT', '/usr/bin/python setup.py install -O1 --skip-build' ' --root $RPM_BUILD_ROOT'] self.assertIn(''.join(install), ''.join(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.sources_by_tag, expected) expected = ['%defattr(-,root,root,-)', '%doc COPYING', rpm.expandMacro('%{python_sitelib}') + '/*'] self.assertEqual(spec.get_files(), expected) # Test find regex = re.compile(r'^Release\s*:\s*(.*)') res = spec.find_re(regex) if res: self.assertEqual(res.split(':')[1].strip(), '1%{?dist}') else: self.assertTrue(False)
def run_on_applicable(self): try: fedora_vers = int(Mock.get_macro("%fedora", self.spec, self.flags)) except ValueError: # EPEL? fedora_vers = 20 if fedora_vers <= 20: self.set_passed(self.NA) return failed = self.spec.find_re(r'Requires:\s*rubygem\s*$') if failed: text = 'Obsolete %s found in spec' % failed self.set_passed(self.FAIL, text) else: self.set_passed(self.PASS)
def run_on_applicable(self): try: fedora_vers = int(Mock.get_macro("%fedora", self.spec, self.flags)) except ValueError: # EPEL? fedora_vers = 20 if fedora_vers > 20: self.set_passed(self.NA) return failed = [] for pkg_name in self.spec.packages: for suffix in ['-doc', '-fonts', '-devel']: if pkg_name.endswith(suffix): continue rpm_pkg = self.rpms.get(pkg_name) if 'rubygems' not in rpm_pkg.requires and \ 'ruby(rubygems)' not in rpm_pkg.requires: failed.append(pkg_name) if failed: text = 'Requires: rubygems missing in ' + ', '.join(failed) self.set_passed(self.FAIL, text) else: self.set_passed(self.PASS)