diff --git a/specfile/prep.py b/specfile/prep.py index 92609d0..8ef2b9b 100644 --- a/specfile/prep.py +++ b/specfile/prep.py @@ -357,6 +357,10 @@ def parse(cls, section: Section) -> "Prep": m.group("d"), m.group("o"), ) + if delimiter == "" and option_string != "": + # delimiter can't be empty unless the match is just base macro with no options + buffer.append(line) + continue prefix += line[: m.start("m")] suffix = line[m.end("o") :] + suffix klass = next( diff --git a/tests/unit/test_prep.py b/tests/unit/test_prep.py index e6f99b7..1f6711f 100644 --- a/tests/unit/test_prep.py +++ b/tests/unit/test_prep.py @@ -112,13 +112,15 @@ def test_prep_parse(): "prep", data=[ "%setup -q", - "# a comment", + "# list all patches", + "echo %patches", "%patch0 -p1", "%{!?skip_patch2:%patch2 -p2}", "", ], ) ) + assert len(prep.macros) == 3 assert prep.macros[0].name == "%setup" assert prep.macros[0].options.q assert prep.macros[1].name == "%patch0" @@ -147,7 +149,7 @@ def test_prep_get_raw_section_data(): PatchMacro.DEFAULTS, ), " ", - preceding_lines=["# a comment"], + preceding_lines=["# list all patches", "echo %patches"], ), PatchMacro( PatchMacro.CANONICAL_NAME + "2", @@ -166,7 +168,8 @@ def test_prep_get_raw_section_data(): ) assert prep.get_raw_section_data() == [ "%setup -q", - "# a comment", + "# list all patches", + "echo %patches", "%patch0 -p1", "%{!?skip_patch2:%patch2 -p2}", "",