| |
@@ -1,6 +1,6 @@
|
| |
- import io
|
| |
import os
|
| |
import shutil
|
| |
+ from subprocess import check_output
|
| |
import tarfile
|
| |
import tempfile
|
| |
from unittest.mock import MagicMock
|
| |
@@ -34,14 +34,14 @@
|
| |
|
| |
autorel_autochangelog_cases = [
|
| |
(autorel_case, autochangelog_case)
|
| |
- for autorel_case in ("unchanged", "without braces")
|
| |
+ for autorel_case in ("unchanged", "with braces")
|
| |
for autochangelog_case in (
|
| |
"unchanged",
|
| |
"changelog case insensitive",
|
| |
"changelog trailing garbage",
|
| |
"line in between",
|
| |
"trailing line",
|
| |
- "without braces",
|
| |
+ "with braces",
|
| |
)
|
| |
]
|
| |
|
| |
@@ -62,8 +62,8 @@
|
| |
with open(spec_file_path, "r") as orig, open(spec_file_path + ".new", "w") as new:
|
| |
for line in orig:
|
| |
if line.startswith("Release:") and autorel_case != "unchanged":
|
| |
- if autorel_case == "without braces":
|
| |
- print("Release: %autorel", file=new)
|
| |
+ if autorel_case == "with braces":
|
| |
+ print("Release: %{autorel}", file=new)
|
| |
else:
|
| |
raise ValueError(f"Unknown autorel_case: {autorel_case}")
|
| |
elif line.strip() == "%changelog" and autochangelog_case != "unchanged":
|
| |
@@ -72,13 +72,13 @@
|
| |
elif autochangelog_case == "changelog trailing garbage":
|
| |
print("%changelog with trailing garbage yes this works", file=new)
|
| |
elif autochangelog_case == "line in between":
|
| |
- print("%changelog\n\n%{autochangelog}", file=new)
|
| |
+ print("%changelog\n\n%autochangelog", file=new)
|
| |
break
|
| |
elif autochangelog_case == "trailing line":
|
| |
- print("%changelog\n%{autochangelog}\n", file=new)
|
| |
+ print("%changelog\n%autochangelog\n", file=new)
|
| |
break
|
| |
- elif autochangelog_case == "without braces":
|
| |
- print("%changelog\n%autochangelog", file=new)
|
| |
+ elif autochangelog_case == "with braces":
|
| |
+ print("%changelog\n%{autochangelog}", file=new)
|
| |
break
|
| |
else:
|
| |
raise ValueError(f"Unknown autochangelog_case: {autochangelog_case}")
|
| |
@@ -87,7 +87,6 @@
|
| |
|
| |
os.rename(spec_file_path + ".new", spec_file_path)
|
| |
|
| |
- @pytest.mark.xfail
|
| |
@pytest.mark.parametrize("autorel_case,autochangelog_case", autorel_autochangelog_cases)
|
| |
def test_autospec_cb(self, autorel_case, autochangelog_case):
|
| |
"""Test the autospec_cb() function"""
|
| |
@@ -122,7 +121,7 @@
|
| |
"release": f"{x}.fc32",
|
| |
"version": "0",
|
| |
}
|
| |
- for x in range(2, 14)
|
| |
+ for x in range(2, 7)
|
| |
]
|
| |
koji_session.listBuilds.return_value = builds
|
| |
args = ["postSCMCheckout"]
|
| |
@@ -158,6 +157,17 @@
|
| |
expected_spec_file_path = tmpspec.name
|
| |
self.fuzz_spec_file(expected_spec_file_path, autorel_case, autochangelog_case)
|
| |
|
| |
- assert list(io.open(unprocessed_spec_file_path)) == list(
|
| |
- io.open(expected_spec_file_path)
|
| |
+ rpm_cmd = ["rpm", "--define", "dist .fc32", "--specfile"]
|
| |
+
|
| |
+ unprocessed_cmd = rpm_cmd + [unprocessed_spec_file_path]
|
| |
+ expected_cmd = rpm_cmd + [expected_spec_file_path]
|
| |
+
|
| |
+ q_release = ["--qf", "%{release}\n"]
|
| |
+ assert check_output(unprocessed_cmd + q_release) == check_output(
|
| |
+ expected_cmd + q_release
|
| |
+ )
|
| |
+
|
| |
+ q_changelog = ["--changelog"]
|
| |
+ assert check_output(unprocessed_cmd + q_changelog) == check_output(
|
| |
+ expected_cmd + q_changelog
|
| |
)
|
| |