mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 20:22:46 +00:00
Fix bugs with %autosetup and --test builds.
Extract method, add some tests, and fixed the regex problem.
This commit is contained in:
parent
d802362964
commit
5d258e7d2e
2 changed files with 48 additions and 20 deletions
|
@ -681,13 +681,28 @@ def munge_specfile(spec_file, commit_id, commit_count, fullname=None, tgz_filena
|
|||
print('%s: %s' % (m.group(1), tgz_filename))
|
||||
continue
|
||||
|
||||
macro = munge_setup_macro(fullname, line)
|
||||
if macro is not None:
|
||||
print(macro)
|
||||
continue
|
||||
|
||||
print(line.rstrip('\n'))
|
||||
|
||||
|
||||
def munge_setup_macro(fullname, line):
|
||||
"""
|
||||
Adjust the %setup or %autosetup line in spec file to accomodate the renamed
|
||||
test source.
|
||||
|
||||
Return None if the given line is not the setup or autosetup line.
|
||||
"""
|
||||
m = re.match(r'^(\s*%(?:auto)?setup)(.*?)$', line)
|
||||
if fullname and m:
|
||||
macro = m.group(1)
|
||||
setup_arg = " -n %s" % fullname
|
||||
|
||||
args = m.group(2)
|
||||
args_match = re.search(r'(.+?)\s+-n\s+\S+(.*)', args)
|
||||
args_match = re.search(r'(.*?)\s+-n\s+\S+(.*)', args)
|
||||
if args_match:
|
||||
macro += args_match.group(1)
|
||||
macro += args_match.group(2)
|
||||
|
@ -701,10 +716,8 @@ def munge_specfile(spec_file, commit_id, commit_count, fullname=None, tgz_filena
|
|||
if not args_match:
|
||||
macro = "{} -p1".format(macro)
|
||||
|
||||
print(macro)
|
||||
continue
|
||||
|
||||
print(line.rstrip('\n'))
|
||||
return macro
|
||||
return None
|
||||
|
||||
|
||||
def scrape_version_and_release(template_file_name):
|
||||
|
|
|
@ -17,6 +17,7 @@ from tito.common import (replace_version, find_spec_like_file, increase_version,
|
|||
search_for, compare_version, run_command_print, find_wrote_in_rpmbuild_output,
|
||||
render_cheetah, increase_zstream, reset_release, find_file_with_extension,
|
||||
normalize_class_name, extract_sha1, BugzillaExtractor, DEFAULT_BUILD_DIR, munge_specfile,
|
||||
munge_setup_macro,
|
||||
_out)
|
||||
|
||||
from tito.compat import StringIO
|
||||
|
@ -632,3 +633,17 @@ class MockBug(object):
|
|||
return self.flags[flag]
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
class MungeSetupMacroTests(unittest.TestCase):
|
||||
SOURCE = "tito-git-3.20362dd"
|
||||
|
||||
def test_setup(self):
|
||||
line = "%setup -q -n tito-%{version}"
|
||||
self.assertEqual("%setup -q -n " + self.SOURCE,
|
||||
munge_setup_macro(self.SOURCE, line))
|
||||
|
||||
def test_autosetup(self):
|
||||
line = "%autosetup -n tito-%{version}"
|
||||
self.assertEqual("%autosetup -n " + self.SOURCE + " -p1",
|
||||
munge_setup_macro(self.SOURCE, line))
|
||||
|
|
Loading…
Add table
Reference in a new issue