| |
@@ -8,14 +8,14 @@
|
| |
|
| |
import pytest
|
| |
|
| |
- from rpmautospec import process_distgit
|
| |
+ from rpmautospec.subcommands import process_distgit
|
| |
|
| |
|
| |
__here__ = os.path.dirname(__file__)
|
| |
|
| |
|
| |
class TestProcessDistgit:
|
| |
- """Test the rpmautospec.process_distgit module"""
|
| |
+ """Test the rpmautospec.subcommands.process_distgit module"""
|
| |
|
| |
autorelease_autochangelog_cases = [
|
| |
(autorelease_case, autochangelog_case)
|
| |
@@ -103,6 +103,7 @@
|
| |
env=env,
|
| |
)
|
| |
|
| |
+ @pytest.mark.parametrize("overwrite_specfile", (False, True))
|
| |
@pytest.mark.parametrize("dirty_worktree", (False, True))
|
| |
@pytest.mark.parametrize("autorelease_case", ("unchanged", "with braces", "optional"))
|
| |
@pytest.mark.parametrize(
|
| |
@@ -118,13 +119,16 @@
|
| |
"optional",
|
| |
),
|
| |
)
|
| |
- def test_process_distgit(self, dirty_worktree, autorelease_case, autochangelog_case):
|
| |
+ def test_process_distgit(
|
| |
+ self, overwrite_specfile, dirty_worktree, autorelease_case, autochangelog_case
|
| |
+ ):
|
| |
"""Test the process_distgit() function"""
|
| |
with tempfile.TemporaryDirectory() as workdir:
|
| |
with tarfile.open(
|
| |
os.path.join(
|
| |
__here__,
|
| |
os.path.pardir,
|
| |
+ os.path.pardir,
|
| |
"test-data",
|
| |
"repodata",
|
| |
"dummy-test-package-gloster-git.tar.gz",
|
| |
@@ -146,11 +150,25 @@
|
| |
run_git_amend=not dirty_worktree,
|
| |
)
|
| |
|
| |
- process_distgit.process_distgit(unpacked_repo_dir)
|
| |
+ if overwrite_specfile:
|
| |
+ target_spec_file_path = None
|
| |
+ else:
|
| |
+ target_spec_file_path = os.path.join(workdir, "test-this-specfile-please.spec")
|
| |
+
|
| |
+ orig_test_spec_file_stat = os.stat(test_spec_file_path)
|
| |
+ process_distgit.process_distgit(unpacked_repo_dir, target_spec_file_path)
|
| |
+ if not overwrite_specfile:
|
| |
+ test_spec_file_stat = os.stat(test_spec_file_path)
|
| |
+ # we can't compare stat_results directly because st_atime has changed
|
| |
+ for attr in ("mode", "ino", "dev", "uid", "gid", "size", "mtime", "ctime"):
|
| |
+ assert getattr(test_spec_file_stat, "st_" + attr) == getattr(
|
| |
+ orig_test_spec_file_stat, "st_" + attr
|
| |
+ )
|
| |
|
| |
expected_spec_file_path = os.path.join(
|
| |
__here__,
|
| |
os.path.pardir,
|
| |
+ os.path.pardir,
|
| |
"test-data",
|
| |
"repodata",
|
| |
"dummy-test-package-gloster.spec.expected",
|
| |
@@ -178,7 +196,10 @@
|
| |
|
| |
rpm_cmd = ["rpm", "--define", "dist .fc32", "--specfile"]
|
| |
|
| |
- test_cmd = rpm_cmd + [test_spec_file_path]
|
| |
+ if target_spec_file_path:
|
| |
+ test_cmd = rpm_cmd + [target_spec_file_path]
|
| |
+ else:
|
| |
+ test_cmd = rpm_cmd + [test_spec_file_path]
|
| |
expected_cmd = rpm_cmd + [expected_spec_file_path]
|
| |
|
| |
q_release = ["--qf", "%{release}\n"]
|
| |
Depends-On: https://pagure.io/fedora-infra/rpmautospec/pull-request/181
This is on top of #181 which needs to be reviewed/merged first.