Skip to content

Commit 3877c32

Browse files
frenzymadnessclaude
andcommitted
Add real RPM fixtures and rewrite RPM-reading tests to use them
Replace the heavily-patched MockRPMHeader approach in test_rpm_reading.py and test_rpm_checking.py with actual RPM files built from minimal spec files. The mock approach was fragile in two ways that the reviewer flagged: - test_skip_source_rpm only passed because the mock hardcoded arch='src', but real SRPMs have arch='noarch' — the test was not testing real behaviour. - Every test carried 18 patch() calls that coupled tests to implementation details (which constants the code reads, whether it uses bytes or str, etc.). New layout: tests/fixtures/rpms/ specs/ - five spec files, one per test scenario rebuild.sh - regenerate RPMs from specs (requires rpmbuild) *.noarch.rpm - six pre-built binary RPMs *.src.rpm - one pre-built source RPM Packages (all noarch, no dist tag for cross-Fedora stability): revdeptest-foo 1.0 simple package, no epoch revdeptest-bar 1.0 different SRPM (for mixed-SRPM error test) revdeptest-bundled 1.0 has bundled(libfoo) and bundled(libbar) provides revdeptest-multi 1.0 main package with a subpackage (same SRPM) revdeptest-multi-sub 1.0 subpackage of revdeptest-multi revdeptest-epoch 9.1.0 Epoch: 1 package test_rpm_reading.py now imports nothing from unittest.mock and carries no rpm-module patches. It passes real paths to read_rpm_provides() and asserts on the real header values returned by the rpm library. test_rpm_checking.py keeps MockBase/MockPackage for the DNF layer (which has its own test coverage) but passes real RPM files into check_rpm_files(). Remove *.spec from .gitignore (added for PyInstaller; not relevant here and was hiding the new spec files from git). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 83ec79f commit 3877c32

16 files changed

Lines changed: 289 additions & 484 deletions

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ MANIFEST
2929

3030
# PyInstaller
3131
*.manifest
32-
*.spec
3332

3433
# Installer logs
3534
pip-log.txt

tests/fixtures/rpms/rebuild.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
# Rebuild all test RPM fixtures from the spec files in specs/.
3+
# Run this script when you add a new spec or need to regenerate existing RPMs.
4+
#
5+
# Requirements: rpmbuild
6+
7+
set -euo pipefail
8+
9+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10+
BUILD=$(mktemp -d)
11+
trap 'rm -rf "$BUILD"' EXIT
12+
13+
build_binary() {
14+
rpmbuild --define "_topdir $BUILD" --define "dist %{nil}" --nodeps -bb "$1" 2>&1
15+
}
16+
17+
build_source() {
18+
rpmbuild --define "_topdir $BUILD" --define "dist %{nil}" --nodeps -bs "$1" 2>&1
19+
}
20+
21+
for spec in "$SCRIPT_DIR"/specs/*.spec; do
22+
echo "Building binary: $spec"
23+
build_binary "$spec"
24+
done
25+
26+
echo "Building source RPM: revdeptest-foo.spec"
27+
build_source "$SCRIPT_DIR/specs/revdeptest-foo.spec"
28+
29+
cp "$BUILD"/RPMS/noarch/*.rpm "$SCRIPT_DIR"/
30+
cp "$BUILD"/SRPMS/*.rpm "$SCRIPT_DIR"/
31+
32+
echo ""
33+
echo "Built RPMs:"
34+
ls -lh "$SCRIPT_DIR"/*.rpm
6.08 KB
Binary file not shown.
6.11 KB
Binary file not shown.
6.11 KB
Binary file not shown.
6.05 KB
Binary file not shown.
6.47 KB
Binary file not shown.
6.08 KB
Binary file not shown.
6.04 KB
Binary file not shown.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Name: revdeptest-bar
2+
Version: 1.0
3+
Release: 1
4+
Summary: Test package (second SRPM) for fedora-revdep-check tests
5+
License: CC0-1.0
6+
BuildArch: noarch
7+
8+
Provides: python3dist(revdeptest-bar) = 1.0
9+
10+
%description
11+
Minimal test package from a different SRPM for fedora-revdep-check unit tests.
12+
13+
%install
14+
mkdir -p %{buildroot}
15+
16+
%files
17+
18+
%changelog

0 commit comments

Comments
 (0)