mergerfs/tests/TEST_release_metadata

541 lines
19 KiB
Text
Raw Normal View History

build: make NDEBUG=1 and make release build the release profile - The RELEASE=1 profile replaced 2.42.0's NDEBUG=1 one, but the static archives and the container image still build with NDEBUG=1, which therefore selected the debug profile: -O0 -g3 with assertions on. Both Makefiles accept NDEBUG=1 again, as -O3 -DNDEBUG, and the debug profile defines DEBUG. The vendored libfuse follows the same profile as mergerfs. - make release first removes the objects, binaries and stamp under build/ and cleans vendored/libfuse, because make only compares timestamps: objects from an earlier debug build were otherwise linked into the release binary unchanged. Packages and build reports in build/pkgs are kept; TEST_release_pkg_preservation checks both. - make release also builds preload.so. It takes the release defines through its own PRELOAD_CPPFLAGS: the global CPPFLAGS add _FILE_OFFSET_BITS=64, which would hide its unsuffixed open/openat/fopen/creat interposers. - mergerfs.spec builds the release target, as debian/rules does. The distribution's CFLAGS, CXXFLAGS and LDFLAGS still apply. - The release driver mounts the repository with ":ro,z", not ":ro:z", which Podman read as an extra field instead of a mount option. TEST_release_metadata runs the driver against a fake podman and checks the volume argument and the build report. - Remove release-installer: build-release has no installer target. - make help printed a literal "\n" where /bin/sh is bash. Match the build.md transcript to its output and document the profiles. Performance: static archives and the container image go from -O0 with assertions back to optimized builds, now -O3 -DNDEBUG (2.42.0: -O2 -DNDEBUG). RPM packages keep the distribution's -O2 and no longer evaluate assertions. A plain make is unoptimized, as before.
2026-11-29 23:10:53 -05:00
#!/usr/bin/env python3
import json
import os
from pathlib import Path
build: make the release driver and Debian changelogs dependable - The container release driver wrote rv=fail but returned success to CI. Run every selected target, keep its report line, and exit nonzero if any target fails or its builder can't run. A missing podman during --cleanup is reported per target instead of aborting the run. Reject a target name that matches no containerfile. - --branch silently defaulted to master, and the tarball containerfile did too, so a release could package a moving branch instead of the intended tag. Require --branch and --git-repo for direct calls. - Remove the static installer target. Its makeself command printed "foo", and it copied whatever static archives the output directory held, possibly from an older release or missing one built later in the same run. The static archives themselves are unchanged. - git2debcl enumerated every tag and used symmetric differences, so a private tag could become a package version and commits from another branch could be listed. Take release and release-candidate tags reachable from the requested revision, ordered by version with each final after its candidates, with one-sided ranges between ancestor boundaries. Keep the requested version when tags share a revision or a range is empty. A tagless snapshot gets 0~git.<count>.<hash>; a shallow tagless checkout must give --version. - Debian versions for candidates are printed as 2.42.0~~rc1, so dpkg orders them below the 2.42.0 final. The raw -rc1 form sorted above it, making the final release look like a downgrade. - TEST_release_metadata covers the driver's results and arguments, sibling and merged histories, non-release tags, candidates, tagless and shallow checkouts, and dpkg version ordering. - Document the static and release targets and the driver's arguments.
2026-11-25 13:36:10 -05:00
import re
import shutil
build: make NDEBUG=1 and make release build the release profile - The RELEASE=1 profile replaced 2.42.0's NDEBUG=1 one, but the static archives and the container image still build with NDEBUG=1, which therefore selected the debug profile: -O0 -g3 with assertions on. Both Makefiles accept NDEBUG=1 again, as -O3 -DNDEBUG, and the debug profile defines DEBUG. The vendored libfuse follows the same profile as mergerfs. - make release first removes the objects, binaries and stamp under build/ and cleans vendored/libfuse, because make only compares timestamps: objects from an earlier debug build were otherwise linked into the release binary unchanged. Packages and build reports in build/pkgs are kept; TEST_release_pkg_preservation checks both. - make release also builds preload.so. It takes the release defines through its own PRELOAD_CPPFLAGS: the global CPPFLAGS add _FILE_OFFSET_BITS=64, which would hide its unsuffixed open/openat/fopen/creat interposers. - mergerfs.spec builds the release target, as debian/rules does. The distribution's CFLAGS, CXXFLAGS and LDFLAGS still apply. - The release driver mounts the repository with ":ro,z", not ":ro:z", which Podman read as an extra field instead of a mount option. TEST_release_metadata runs the driver against a fake podman and checks the volume argument and the build report. - Remove release-installer: build-release has no installer target. - make help printed a literal "\n" where /bin/sh is bash. Match the build.md transcript to its output and document the profiles. Performance: static archives and the container image go from -O0 with assertions back to optimized builds, now -O3 -DNDEBUG (2.42.0: -O2 -DNDEBUG). RPM packages keep the distribution's -O2 and no longer evaluate assertions. A plain make is unoptimized, as before.
2026-11-29 23:10:53 -05:00
import subprocess
import sys
import tempfile
import unittest
ROOT = Path(__file__).resolve().parents[1]
BUILD_RELEASE = ROOT / "buildtools" / "build-release"
build: make the release driver and Debian changelogs dependable - The container release driver wrote rv=fail but returned success to CI. Run every selected target, keep its report line, and exit nonzero if any target fails or its builder can't run. A missing podman during --cleanup is reported per target instead of aborting the run. Reject a target name that matches no containerfile. - --branch silently defaulted to master, and the tarball containerfile did too, so a release could package a moving branch instead of the intended tag. Require --branch and --git-repo for direct calls. - Remove the static installer target. Its makeself command printed "foo", and it copied whatever static archives the output directory held, possibly from an older release or missing one built later in the same run. The static archives themselves are unchanged. - git2debcl enumerated every tag and used symmetric differences, so a private tag could become a package version and commits from another branch could be listed. Take release and release-candidate tags reachable from the requested revision, ordered by version with each final after its candidates, with one-sided ranges between ancestor boundaries. Keep the requested version when tags share a revision or a range is empty. A tagless snapshot gets 0~git.<count>.<hash>; a shallow tagless checkout must give --version. - Debian versions for candidates are printed as 2.42.0~~rc1, so dpkg orders them below the 2.42.0 final. The raw -rc1 form sorted above it, making the final release look like a downgrade. - TEST_release_metadata covers the driver's results and arguments, sibling and merged histories, non-release tags, candidates, tagless and shallow checkouts, and dpkg version ordering. - Document the static and release targets and the driver's arguments.
2026-11-25 13:36:10 -05:00
GIT2DEBCL = ROOT / "buildtools" / "git2debcl"
def _deb_order_char(char):
# dpkg verrevcmp's order(): digits group first, '~' sorts before
# everything else, letters sort by value, other punctuation last.
if char.isdigit():
return 0
if char.isalpha():
return ord(char)
if char == "~":
return -1
if char:
return ord(char) + 256
return 0
def _deb_verrevcmp(a, b):
i = j = 0
while i < len(a) or j < len(b):
first_diff = 0
while ((i < len(a) and not a[i].isdigit()) or
(j < len(b) and not b[j].isdigit())):
ac = _deb_order_char(a[i]) if i < len(a) else 0
bc = _deb_order_char(b[j]) if j < len(b) else 0
if ac != bc:
return -1 if ac < bc else 1
i += 1
j += 1
while i < len(a) and a[i] == "0":
i += 1
while j < len(b) and b[j] == "0":
j += 1
while i < len(a) and a[i].isdigit() and j < len(b) and b[j].isdigit():
if first_diff == 0:
first_diff = ord(a[i]) - ord(b[j])
i += 1
j += 1
if i < len(a) and a[i].isdigit():
return 1
if j < len(b) and b[j].isdigit():
return -1
if first_diff:
return -1 if first_diff < 0 else 1
return 0
def deb_vercmp(a, b):
# Compact port of dpkg's version comparison: epoch, then upstream
# version, then Debian revision, each compared with verrevcmp.
def split(value):
epoch, sep, rest = value.partition(":")
if not sep:
epoch, rest = "0", value
upstream, _, revision = rest.rpartition("-")
return int(epoch), upstream, revision
epoch_a, upstream_a, revision_a = split(a)
epoch_b, upstream_b, revision_b = split(b)
if epoch_a != epoch_b:
return -1 if epoch_a < epoch_b else 1
rv = _deb_verrevcmp(upstream_a, upstream_b)
if rv:
return rv
return _deb_verrevcmp(revision_a, revision_b)
build: make NDEBUG=1 and make release build the release profile - The RELEASE=1 profile replaced 2.42.0's NDEBUG=1 one, but the static archives and the container image still build with NDEBUG=1, which therefore selected the debug profile: -O0 -g3 with assertions on. Both Makefiles accept NDEBUG=1 again, as -O3 -DNDEBUG, and the debug profile defines DEBUG. The vendored libfuse follows the same profile as mergerfs. - make release first removes the objects, binaries and stamp under build/ and cleans vendored/libfuse, because make only compares timestamps: objects from an earlier debug build were otherwise linked into the release binary unchanged. Packages and build reports in build/pkgs are kept; TEST_release_pkg_preservation checks both. - make release also builds preload.so. It takes the release defines through its own PRELOAD_CPPFLAGS: the global CPPFLAGS add _FILE_OFFSET_BITS=64, which would hide its unsuffixed open/openat/fopen/creat interposers. - mergerfs.spec builds the release target, as debian/rules does. The distribution's CFLAGS, CXXFLAGS and LDFLAGS still apply. - The release driver mounts the repository with ":ro,z", not ":ro:z", which Podman read as an extra field instead of a mount option. TEST_release_metadata runs the driver against a fake podman and checks the volume argument and the build report. - Remove release-installer: build-release has no installer target. - make help printed a literal "\n" where /bin/sh is bash. Match the build.md transcript to its output and document the profiles. Performance: static archives and the container image go from -O0 with assertions back to optimized builds, now -O3 -DNDEBUG (2.42.0: -O2 -DNDEBUG). RPM packages keep the distribution's -O2 and no longer evaluate assertions. A plain make is unoptimized, as before.
2026-11-29 23:10:53 -05:00
class ReleaseMetadataTests(unittest.TestCase):
def setUp(self):
tmpdir = os.environ.get("TMPDIR")
tmp = tempfile.TemporaryDirectory(
prefix="mergerfs-release-metadata-", dir=tmpdir
)
self.addCleanup(tmp.cleanup)
self.root = Path(tmp.name)
self.home = self.root / "home"
self.home.mkdir()
build: make the release driver and Debian changelogs dependable - The container release driver wrote rv=fail but returned success to CI. Run every selected target, keep its report line, and exit nonzero if any target fails or its builder can't run. A missing podman during --cleanup is reported per target instead of aborting the run. Reject a target name that matches no containerfile. - --branch silently defaulted to master, and the tarball containerfile did too, so a release could package a moving branch instead of the intended tag. Require --branch and --git-repo for direct calls. - Remove the static installer target. Its makeself command printed "foo", and it copied whatever static archives the output directory held, possibly from an older release or missing one built later in the same run. The static archives themselves are unchanged. - git2debcl enumerated every tag and used symmetric differences, so a private tag could become a package version and commits from another branch could be listed. Take release and release-candidate tags reachable from the requested revision, ordered by version with each final after its candidates, with one-sided ranges between ancestor boundaries. Keep the requested version when tags share a revision or a range is empty. A tagless snapshot gets 0~git.<count>.<hash>; a shallow tagless checkout must give --version. - Debian versions for candidates are printed as 2.42.0~~rc1, so dpkg orders them below the 2.42.0 final. The raw -rc1 form sorted above it, making the final release look like a downgrade. - TEST_release_metadata covers the driver's results and arguments, sibling and merged histories, non-release tags, candidates, tagless and shallow checkouts, and dpkg version ordering. - Document the static and release targets and the driver's arguments.
2026-11-25 13:36:10 -05:00
self.repo = None
build: make NDEBUG=1 and make release build the release profile - The RELEASE=1 profile replaced 2.42.0's NDEBUG=1 one, but the static archives and the container image still build with NDEBUG=1, which therefore selected the debug profile: -O0 -g3 with assertions on. Both Makefiles accept NDEBUG=1 again, as -O3 -DNDEBUG, and the debug profile defines DEBUG. The vendored libfuse follows the same profile as mergerfs. - make release first removes the objects, binaries and stamp under build/ and cleans vendored/libfuse, because make only compares timestamps: objects from an earlier debug build were otherwise linked into the release binary unchanged. Packages and build reports in build/pkgs are kept; TEST_release_pkg_preservation checks both. - make release also builds preload.so. It takes the release defines through its own PRELOAD_CPPFLAGS: the global CPPFLAGS add _FILE_OFFSET_BITS=64, which would hide its unsuffixed open/openat/fopen/creat interposers. - mergerfs.spec builds the release target, as debian/rules does. The distribution's CFLAGS, CXXFLAGS and LDFLAGS still apply. - The release driver mounts the repository with ":ro,z", not ":ro:z", which Podman read as an extra field instead of a mount option. TEST_release_metadata runs the driver against a fake podman and checks the volume argument and the build report. - Remove release-installer: build-release has no installer target. - make help printed a literal "\n" where /bin/sh is bash. Match the build.md transcript to its output and document the profiles. Performance: static archives and the container image go from -O0 with assertions back to optimized builds, now -O3 -DNDEBUG (2.42.0: -O2 -DNDEBUG). RPM packages keep the distribution's -O2 and no longer evaluate assertions. A plain make is unoptimized, as before.
2026-11-29 23:10:53 -05:00
def base_env(self):
env = os.environ.copy()
for key in list(env):
if key.startswith("GIT_"):
del env[key]
env.update(
{
"HOME": str(self.home),
"XDG_CONFIG_HOME": str(self.home / ".config"),
"GIT_CONFIG_NOSYSTEM": "1",
"GIT_CONFIG_GLOBAL": os.devnull,
"GIT_AUTHOR_NAME": "Release Test",
"GIT_AUTHOR_EMAIL": "release@example.invalid",
"GIT_COMMITTER_NAME": "Release Test",
"GIT_COMMITTER_EMAIL": "release@example.invalid",
"LC_ALL": "C",
}
)
return env
def run_command(self, args, cwd, env=None, timeout=30):
return subprocess.run(
[str(arg) for arg in args], cwd=str(cwd),
env=env or self.base_env(), stdout=subprocess.PIPE,
stderr=subprocess.PIPE, text=True, timeout=timeout,
)
build: make the release driver and Debian changelogs dependable - The container release driver wrote rv=fail but returned success to CI. Run every selected target, keep its report line, and exit nonzero if any target fails or its builder can't run. A missing podman during --cleanup is reported per target instead of aborting the run. Reject a target name that matches no containerfile. - --branch silently defaulted to master, and the tarball containerfile did too, so a release could package a moving branch instead of the intended tag. Require --branch and --git-repo for direct calls. - Remove the static installer target. Its makeself command printed "foo", and it copied whatever static archives the output directory held, possibly from an older release or missing one built later in the same run. The static archives themselves are unchanged. - git2debcl enumerated every tag and used symmetric differences, so a private tag could become a package version and commits from another branch could be listed. Take release and release-candidate tags reachable from the requested revision, ordered by version with each final after its candidates, with one-sided ranges between ancestor boundaries. Keep the requested version when tags share a revision or a range is empty. A tagless snapshot gets 0~git.<count>.<hash>; a shallow tagless checkout must give --version. - Debian versions for candidates are printed as 2.42.0~~rc1, so dpkg orders them below the 2.42.0 final. The raw -rc1 form sorted above it, making the final release look like a downgrade. - TEST_release_metadata covers the driver's results and arguments, sibling and merged histories, non-release tags, candidates, tagless and shallow checkouts, and dpkg version ordering. - Document the static and release targets and the driver's arguments.
2026-11-25 13:36:10 -05:00
def make_repo(self, name="repo"):
self.repo = self.root / name
rv = self.run_command(["git", "init", "-q", self.repo], self.root)
self.assertEqual(rv.returncode, 0, msg=rv.stderr)
def git(self, *args, check=True, date=None):
env = self.base_env()
if date is not None:
value = "{} +0000".format(date)
env["GIT_AUTHOR_DATE"] = value
env["GIT_COMMITTER_DATE"] = value
rv = self.run_command(["git", "-C", self.repo, *args], self.repo, env)
if check and rv.returncode != 0:
self.fail("git {} failed\nstdout:\n{}\nstderr:\n{}".format(
" ".join(args), rv.stdout, rv.stderr))
return rv
def commit(self, subject, sequence):
self.git(
"commit",
"--allow-empty",
"--no-gpg-sign",
"-q",
"-m",
subject,
date=1700000000 + sequence * 60,
)
return self.git("rev-parse", "HEAD").stdout.strip()
def tag(self, name, ref="HEAD"):
self.git("tag", name, ref)
def commit_tag(self, subject, sequence, name):
ref = self.commit(subject, sequence)
self.tag(name, ref)
return ref
def changelog(self, version=None, expected=0):
args = [
GIT2DEBCL,
"--name",
"mergerfs",
"--distro",
"debian",
"--codename",
"test",
]
if version is not None:
args.extend(["--version", version])
rv = self.run_command(args, cwd=self.repo)
message = "stdout:\n{}\nstderr:\n{}".format(rv.stdout, rv.stderr)
self.assertEqual(rv.returncode, expected, msg=message)
return rv
def changelog_versions(self, output):
return re.findall(
r"(?m)^mergerfs \((.*?)~debian-test\) test; urgency=medium$", output)
def deb_order(self, a, b):
dpkg = shutil.which("dpkg")
if dpkg is not None:
for op, rv in (("lt", -1), ("eq", 0)):
proc = self.run_command(
[dpkg, "--compare-versions", a, op, b], self.root)
if proc.returncode == 0:
return rv
return 1
return deb_vercmp(a, b)
def assert_deb_less(self, a, b):
self.assertLess(
self.deb_order(a, b), 0, "expected {} < {}".format(a, b))
def assert_commit_listed(self, output, subject):
pattern = r"(?m)^ \* [0-9a-f]+ {}$".format(re.escape(subject))
self.assertRegex(output, pattern)
def run_driver(self, fail_target="", missing_podman=False, branch="test",
target="all", fixtures=("debian-bad", "debian-good"),
cwd=None):
build: make NDEBUG=1 and make release build the release profile - The RELEASE=1 profile replaced 2.42.0's NDEBUG=1 one, but the static archives and the container image still build with NDEBUG=1, which therefore selected the debug profile: -O0 -g3 with assertions on. Both Makefiles accept NDEBUG=1 again, as -O3 -DNDEBUG, and the debug profile defines DEBUG. The vendored libfuse follows the same profile as mergerfs. - make release first removes the objects, binaries and stamp under build/ and cleans vendored/libfuse, because make only compares timestamps: objects from an earlier debug build were otherwise linked into the release binary unchanged. Packages and build reports in build/pkgs are kept; TEST_release_pkg_preservation checks both. - make release also builds preload.so. It takes the release defines through its own PRELOAD_CPPFLAGS: the global CPPFLAGS add _FILE_OFFSET_BITS=64, which would hide its unsuffixed open/openat/fopen/creat interposers. - mergerfs.spec builds the release target, as debian/rules does. The distribution's CFLAGS, CXXFLAGS and LDFLAGS still apply. - The release driver mounts the repository with ":ro,z", not ":ro:z", which Podman read as an extra field instead of a mount option. TEST_release_metadata runs the driver against a fake podman and checks the volume argument and the build report. - Remove release-installer: build-release has no installer target. - make help printed a literal "\n" where /bin/sh is bash. Match the build.md transcript to its output and document the profiles. Performance: static archives and the container image go from -O0 with assertions back to optimized builds, now -O3 -DNDEBUG (2.42.0: -O2 -DNDEBUG). RPM packages keep the distribution's -O2 and no longer evaluate assertions. A plain make is unoptimized, as before.
2026-11-29 23:10:53 -05:00
work = self.root / "driver"
containers = work / "buildtools" / "containerfiles"
containers.mkdir(parents=True)
build: make the release driver and Debian changelogs dependable - The container release driver wrote rv=fail but returned success to CI. Run every selected target, keep its report line, and exit nonzero if any target fails or its builder can't run. A missing podman during --cleanup is reported per target instead of aborting the run. Reject a target name that matches no containerfile. - --branch silently defaulted to master, and the tarball containerfile did too, so a release could package a moving branch instead of the intended tag. Require --branch and --git-repo for direct calls. - Remove the static installer target. Its makeself command printed "foo", and it copied whatever static archives the output directory held, possibly from an older release or missing one built later in the same run. The static archives themselves are unchanged. - git2debcl enumerated every tag and used symmetric differences, so a private tag could become a package version and commits from another branch could be listed. Take release and release-candidate tags reachable from the requested revision, ordered by version with each final after its candidates, with one-sided ranges between ancestor boundaries. Keep the requested version when tags share a revision or a range is empty. A tagless snapshot gets 0~git.<count>.<hash>; a shallow tagless checkout must give --version. - Debian versions for candidates are printed as 2.42.0~~rc1, so dpkg orders them below the 2.42.0 final. The raw -rc1 form sorted above it, making the final release look like a downgrade. - TEST_release_metadata covers the driver's results and arguments, sibling and merged histories, non-release tags, candidates, tagless and shallow checkouts, and dpkg version ordering. - Document the static and release targets and the driver's arguments.
2026-11-25 13:36:10 -05:00
for name in fixtures:
build: make NDEBUG=1 and make release build the release profile - The RELEASE=1 profile replaced 2.42.0's NDEBUG=1 one, but the static archives and the container image still build with NDEBUG=1, which therefore selected the debug profile: -O0 -g3 with assertions on. Both Makefiles accept NDEBUG=1 again, as -O3 -DNDEBUG, and the debug profile defines DEBUG. The vendored libfuse follows the same profile as mergerfs. - make release first removes the objects, binaries and stamp under build/ and cleans vendored/libfuse, because make only compares timestamps: objects from an earlier debug build were otherwise linked into the release binary unchanged. Packages and build reports in build/pkgs are kept; TEST_release_pkg_preservation checks both. - make release also builds preload.so. It takes the release defines through its own PRELOAD_CPPFLAGS: the global CPPFLAGS add _FILE_OFFSET_BITS=64, which would hide its unsuffixed open/openat/fopen/creat interposers. - mergerfs.spec builds the release target, as debian/rules does. The distribution's CFLAGS, CXXFLAGS and LDFLAGS still apply. - The release driver mounts the repository with ":ro,z", not ":ro:z", which Podman read as an extra field instead of a mount option. TEST_release_metadata runs the driver against a fake podman and checks the volume argument and the build report. - Remove release-installer: build-release has no installer target. - make help printed a literal "\n" where /bin/sh is bash. Match the build.md transcript to its output and document the profiles. Performance: static archives and the container image go from -O0 with assertions back to optimized builds, now -O3 -DNDEBUG (2.42.0: -O2 -DNDEBUG). RPM packages keep the distribution's -O2 and no longer evaluate assertions. A plain make is unoptimized, as before.
2026-11-29 23:10:53 -05:00
(containers / name).write_text("# test fixture\n", encoding="ascii")
repo = work / "repo"
repo.mkdir()
fake_bin = work / "bin"
fake_bin.mkdir()
podman_log = work / "podman-args.jsonl"
podman = fake_bin / "podman"
podman.write_text(
"""#!/usr/bin/env python3
import json
import os
import sys
with open(os.environ["PODMAN_LOG"], "a", encoding="ascii") as stream:
stream.write(json.dumps(sys.argv[1:]) + "\\n")
target = sys.argv[sys.argv.index("-f") + 1]
if os.path.basename(target) == os.environ.get("PODMAN_FAIL_TARGET"):
raise SystemExit(19)
raise SystemExit(0)
""",
encoding="ascii",
)
podman.chmod(0o755)
packages = work / "pkgs"
env = self.base_env()
if missing_podman:
env["PATH"] = str(work / "missing-bin")
else:
env["PATH"] = str(fake_bin) + os.pathsep + env.get("PATH", "")
env["PODMAN_LOG"] = str(podman_log)
env["PODMAN_FAIL_TARGET"] = fail_target
driver_args = [
sys.executable,
BUILD_RELEASE,
build: make the release driver and Debian changelogs dependable - The container release driver wrote rv=fail but returned success to CI. Run every selected target, keep its report line, and exit nonzero if any target fails or its builder can't run. A missing podman during --cleanup is reported per target instead of aborting the run. Reject a target name that matches no containerfile. - --branch silently defaulted to master, and the tarball containerfile did too, so a release could package a moving branch instead of the intended tag. Require --branch and --git-repo for direct calls. - Remove the static installer target. Its makeself command printed "foo", and it copied whatever static archives the output directory held, possibly from an older release or missing one built later in the same run. The static archives themselves are unchanged. - git2debcl enumerated every tag and used symmetric differences, so a private tag could become a package version and commits from another branch could be listed. Take release and release-candidate tags reachable from the requested revision, ordered by version with each final after its candidates, with one-sided ranges between ancestor boundaries. Keep the requested version when tags share a revision or a range is empty. A tagless snapshot gets 0~git.<count>.<hash>; a shallow tagless checkout must give --version. - Debian versions for candidates are printed as 2.42.0~~rc1, so dpkg orders them below the 2.42.0 final. The raw -rc1 form sorted above it, making the final release look like a downgrade. - TEST_release_metadata covers the driver's results and arguments, sibling and merged histories, non-release tags, candidates, tagless and shallow checkouts, and dpkg version ordering. - Document the static and release targets and the driver's arguments.
2026-11-25 13:36:10 -05:00
"--target={}".format(target),
build: make NDEBUG=1 and make release build the release profile - The RELEASE=1 profile replaced 2.42.0's NDEBUG=1 one, but the static archives and the container image still build with NDEBUG=1, which therefore selected the debug profile: -O0 -g3 with assertions on. Both Makefiles accept NDEBUG=1 again, as -O3 -DNDEBUG, and the debug profile defines DEBUG. The vendored libfuse follows the same profile as mergerfs. - make release first removes the objects, binaries and stamp under build/ and cleans vendored/libfuse, because make only compares timestamps: objects from an earlier debug build were otherwise linked into the release binary unchanged. Packages and build reports in build/pkgs are kept; TEST_release_pkg_preservation checks both. - make release also builds preload.so. It takes the release defines through its own PRELOAD_CPPFLAGS: the global CPPFLAGS add _FILE_OFFSET_BITS=64, which would hide its unsuffixed open/openat/fopen/creat interposers. - mergerfs.spec builds the release target, as debian/rules does. The distribution's CFLAGS, CXXFLAGS and LDFLAGS still apply. - The release driver mounts the repository with ":ro,z", not ":ro:z", which Podman read as an extra field instead of a mount option. TEST_release_metadata runs the driver against a fake podman and checks the volume argument and the build report. - Remove release-installer: build-release has no installer target. - make help printed a literal "\n" where /bin/sh is bash. Match the build.md transcript to its output and document the profiles. Performance: static archives and the container image go from -O0 with assertions back to optimized builds, now -O3 -DNDEBUG (2.42.0: -O2 -DNDEBUG). RPM packages keep the distribution's -O2 and no longer evaluate assertions. A plain make is unoptimized, as before.
2026-11-29 23:10:53 -05:00
"--git-repo={}".format(repo),
"--pkgdirpath={}".format(packages),
]
if branch is not None:
driver_args.append("--branch={}".format(branch))
build: make the release driver and Debian changelogs dependable - The container release driver wrote rv=fail but returned success to CI. Run every selected target, keep its report line, and exit nonzero if any target fails or its builder can't run. A missing podman during --cleanup is reported per target instead of aborting the run. Reject a target name that matches no containerfile. - --branch silently defaulted to master, and the tarball containerfile did too, so a release could package a moving branch instead of the intended tag. Require --branch and --git-repo for direct calls. - Remove the static installer target. Its makeself command printed "foo", and it copied whatever static archives the output directory held, possibly from an older release or missing one built later in the same run. The static archives themselves are unchanged. - git2debcl enumerated every tag and used symmetric differences, so a private tag could become a package version and commits from another branch could be listed. Take release and release-candidate tags reachable from the requested revision, ordered by version with each final after its candidates, with one-sided ranges between ancestor boundaries. Keep the requested version when tags share a revision or a range is empty. A tagless snapshot gets 0~git.<count>.<hash>; a shallow tagless checkout must give --version. - Debian versions for candidates are printed as 2.42.0~~rc1, so dpkg orders them below the 2.42.0 final. The raw -rc1 form sorted above it, making the final release look like a downgrade. - TEST_release_metadata covers the driver's results and arguments, sibling and merged histories, non-release tags, candidates, tagless and shallow checkouts, and dpkg version ordering. - Document the static and release targets and the driver's arguments.
2026-11-25 13:36:10 -05:00
rv = self.run_command(
driver_args, cwd=work if cwd is None else cwd, env=env)
build: make NDEBUG=1 and make release build the release profile - The RELEASE=1 profile replaced 2.42.0's NDEBUG=1 one, but the static archives and the container image still build with NDEBUG=1, which therefore selected the debug profile: -O0 -g3 with assertions on. Both Makefiles accept NDEBUG=1 again, as -O3 -DNDEBUG, and the debug profile defines DEBUG. The vendored libfuse follows the same profile as mergerfs. - make release first removes the objects, binaries and stamp under build/ and cleans vendored/libfuse, because make only compares timestamps: objects from an earlier debug build were otherwise linked into the release binary unchanged. Packages and build reports in build/pkgs are kept; TEST_release_pkg_preservation checks both. - make release also builds preload.so. It takes the release defines through its own PRELOAD_CPPFLAGS: the global CPPFLAGS add _FILE_OFFSET_BITS=64, which would hide its unsuffixed open/openat/fopen/creat interposers. - mergerfs.spec builds the release target, as debian/rules does. The distribution's CFLAGS, CXXFLAGS and LDFLAGS still apply. - The release driver mounts the repository with ":ro,z", not ":ro:z", which Podman read as an extra field instead of a mount option. TEST_release_metadata runs the driver against a fake podman and checks the volume argument and the build report. - Remove release-installer: build-release has no installer target. - make help printed a literal "\n" where /bin/sh is bash. Match the build.md transcript to its output and document the profiles. Performance: static archives and the container image go from -O0 with assertions back to optimized builds, now -O3 -DNDEBUG (2.42.0: -O2 -DNDEBUG). RPM packages keep the distribution's -O2 and no longer evaluate assertions. A plain make is unoptimized, as before.
2026-11-29 23:10:53 -05:00
calls = []
if podman_log.exists():
calls = [
json.loads(line)
for line in podman_log.read_text(encoding="ascii").splitlines()
]
report_path = packages / "build-report.txt"
report = ""
if report_path.exists():
report = report_path.read_text(encoding="ascii")
return rv, calls, report.splitlines()
def assert_driver_report(self, lines, bad_status):
self.assertEqual(len(lines), 2)
pattern = r"^debian-bad: branch=test; timestamp=\d+; rv={};$"
self.assertRegex(lines[0], pattern.format(bad_status))
self.assertRegex(
lines[1], r"^debian-good: branch=test; timestamp=\d+; rv=success;$")
def assert_local_volume_syntax(self, calls):
volumes = [
arg for call in calls for arg in call
if arg.endswith(":/tmp/mergerfs.git:ro,z")
]
self.assertEqual(len(volumes), 2)
def test_driver_success(self):
rv, calls, report = self.run_driver()
self.assertEqual(
rv.returncode, 0, msg=rv.stdout + rv.stderr
)
self.assertEqual(len(calls), 2)
self.assert_driver_report(report, "success")
self.assert_local_volume_syntax(calls)
build: make the release driver and Debian changelogs dependable - The container release driver wrote rv=fail but returned success to CI. Run every selected target, keep its report line, and exit nonzero if any target fails or its builder can't run. A missing podman during --cleanup is reported per target instead of aborting the run. Reject a target name that matches no containerfile. - --branch silently defaulted to master, and the tarball containerfile did too, so a release could package a moving branch instead of the intended tag. Require --branch and --git-repo for direct calls. - Remove the static installer target. Its makeself command printed "foo", and it copied whatever static archives the output directory held, possibly from an older release or missing one built later in the same run. The static archives themselves are unchanged. - git2debcl enumerated every tag and used symmetric differences, so a private tag could become a package version and commits from another branch could be listed. Take release and release-candidate tags reachable from the requested revision, ordered by version with each final after its candidates, with one-sided ranges between ancestor boundaries. Keep the requested version when tags share a revision or a range is empty. A tagless snapshot gets 0~git.<count>.<hash>; a shallow tagless checkout must give --version. - Debian versions for candidates are printed as 2.42.0~~rc1, so dpkg orders them below the 2.42.0 final. The raw -rc1 form sorted above it, making the final release look like a downgrade. - TEST_release_metadata covers the driver's results and arguments, sibling and merged histories, non-release tags, candidates, tagless and shallow checkouts, and dpkg version ordering. - Document the static and release targets and the driver's arguments.
2026-11-25 13:36:10 -05:00
def test_driver_rejects_missing_branch(self):
rv, calls, report = self.run_driver(branch=None)
self.assertNotEqual(rv.returncode, 0, msg=rv.stdout + rv.stderr)
self.assertIn("--branch", rv.stdout + rv.stderr)
self.assertEqual(calls, [])
self.assertEqual(report, [])
def test_driver_one_bad_among_good(self):
rv, calls, report = self.run_driver(fail_target="debian-bad")
self.assertNotEqual(rv.returncode, 0, msg=rv.stdout + rv.stderr)
self.assertEqual(len(calls), 2)
self.assert_driver_report(report, "fail")
self.assert_local_volume_syntax(calls)
def test_driver_missing_podman_reports_every_target(self):
rv, calls, report = self.run_driver(missing_podman=True)
self.assertNotEqual(rv.returncode, 0, msg=rv.stdout + rv.stderr)
self.assertEqual(calls, [])
self.assertEqual(len(report), 2)
for line, name in zip(report, ("debian-bad", "debian-good")):
self.assertRegex(
line,
r"^{}: branch=test; timestamp=\d+; rv=fail;$".format(name),
)
def test_driver_static_target_builds_all_static_archives(self):
# Exercises the real buildtools/containerfiles directory so the
# post-withdrawal selection is locked, not just the matching logic.
static_archives = (
"static.amd64",
"static.arm64",
"static.armhf",
"static.i386",
"static.riscv64",
)
rv, calls, report = self.run_driver(target="static", cwd=ROOT)
self.assertEqual(rv.returncode, 0, msg=rv.stdout + rv.stderr)
built = [
os.path.basename(call[call.index("-f") + 1]) for call in calls
]
self.assertEqual(built, list(static_archives))
self.assertEqual(len(report), len(static_archives))
for line, name in zip(report, static_archives):
self.assertRegex(
line,
r"^{}: branch=test; timestamp=\d+; rv=success;$".format(name),
)
def test_driver_unmatched_target_fails_without_building(self):
rv, calls, report = self.run_driver(target="installer", cwd=ROOT)
self.assertNotEqual(rv.returncode, 0, msg=rv.stdout + rv.stderr)
self.assertIn("no package targets match 'installer'", rv.stderr)
self.assertEqual(calls, [])
self.assertEqual(report, [])
def test_changelog_excludes_foreign_and_nonrelease_tags(self):
self.make_repo()
base = self.commit_tag("base", 1, "1.0")
first = self.commit_tag("main one", 2, "1.1")
self.git("checkout", "-q", "-b", "side", base)
side = self.commit("side private", 3)
self.tag("9.0", side)
self.git("checkout", "-q", "-")
second = self.commit_tag("main two", 4, "1.2")
head = self.commit("head work", 5)
self.tag("backup-pre-docsplit", head)
self.tag("2backup", head)
self.git(
"tag", "-a", "snapshot-note", "-m", "snapshot", head,
date=1700000900,
)
output = self.changelog("2.0").stdout
self.assertEqual(
self.changelog_versions(output), ["2.0", "1.2", "1.1"]
)
for subject in ("head work", "main two", "main one"):
self.assert_commit_listed(output, subject)
self.assertNotIn("side private", output)
self.assertNotIn("backup-pre-docsplit", output)
self.assertNotIn("2backup", output)
self.assertNotIn("snapshot-note", output)
self.assertNotIn("(9.0~debian-test)", output)
guessed = self.changelog().stdout
versions = self.changelog_versions(guessed)
self.assertTrue(versions)
self.assertRegex(versions[0], r"^1\.2-1-g[0-9a-f]+$")
for name in ("backup-pre-docsplit", "2backup", "snapshot-note"):
self.assertNotIn(name, guessed)
self.assert_commit_listed(guessed, "head work")
def test_prerelease_order_and_requested_ref_bound(self):
self.make_repo()
base = self.commit_tag("base", 1, "2.41.1")
rc0 = self.commit_tag("rc zero", 2, "2.42.0-rc0")
rc1 = self.commit_tag("rc one", 3, "2.42.0-rc1")
rc2 = self.commit_tag("rc two", 4, "2.42.0-rc2")
rc3 = self.commit_tag("rc three", 5, "2.42.0-rc3")
final = self.commit_tag("final release", 6, "2.42.0")
self.commit("head work", 7)
output = self.changelog("2.42.1").stdout
self.assertEqual(
self.changelog_versions(output),
[
"2.42.1",
"2.42.0",
"2.42.0~~rc3",
"2.42.0~~rc2",
"2.42.0~~rc1",
"2.42.0~~rc0",
],
)
for subject in (
"head work",
"final release",
"rc three",
"rc two",
"rc one",
"rc zero",
):
self.assert_commit_listed(output, subject)
output = self.changelog("2.42.0-rc2").stdout
self.assertEqual(
self.changelog_versions(output),
["2.42.0~~rc2", "2.42.0~~rc1", "2.42.0~~rc0"],
)
for subject in ("rc two", "rc one", "rc zero"):
self.assert_commit_listed(output, subject)
self.assertNotIn("rc three", output)
self.assertNotIn("final release", output)
self.assertNotIn("head work", output)
def test_rc_package_version_sorts_below_final_release(self):
self.make_repo()
self.commit_tag("previous release", 0, "2.41.0")
self.commit_tag("rc one", 1, "2.42.0-rc1")
self.commit_tag("rc two", 2, "2.42.0-rc2")
self.commit_tag("final release", 3, "2.42.0")
output = self.changelog("2.42.0").stdout
self.assertIn(
"mergerfs (2.42.0~~rc1~debian-test) test; urgency=medium",
output,
)
self.assertNotIn("(2.42.0-rc1~debian-test)", output)
self.assertNotIn("(2.42.0-rc2~debian-test)", output)
# dpkg splits a package version at the last '-' and sorts '-'
# above '~', so the printed rc tags must double the '~' to sort
# below the final release while staying above the previous one.
rc1 = "2.42.0~~rc1~debian-test"
rc2 = "2.42.0~~rc2~debian-test"
final = "2.42.0~debian-test"
self.assert_deb_less("2.41.0~debian-test", rc1)
self.assert_deb_less(rc1, rc2)
self.assert_deb_less(rc2, final)
self.commit("head work", 4)
snapshot = self.changelog_versions(self.changelog().stdout)[0]
self.assertRegex(snapshot, r"^2\.42\.0-1-g[0-9a-f]+$")
self.assert_deb_less(final, "{}~debian-test".format(snapshot))
def test_incomparable_release_tags_skip_boundary(self):
self.make_repo()
base = self.commit_tag("base", 1, "1.0")
self.git("checkout", "-q", "-b", "side", base)
self.commit_tag("side release", 2, "1.1")
self.git("checkout", "-q", "-")
self.commit_tag("main release", 3, "2.0")
self.git(
"merge", "-q", "--no-ff", "--no-gpg-sign", "-m", "merge side",
"side", date=1700000900,
)
output = self.changelog("3.0").stdout
self.assertEqual(self.changelog_versions(output), ["3.0", "2.0"])
self.assertEqual(output.count("side release"), 1)
self.assert_commit_listed(output, "main release")
def test_same_commit_tags_keep_newer_nonempty_history(self):
self.make_repo()
base = self.commit_tag("base", 1, "1.0")
middle = self.commit("middle", 2)
self.tag("1.1", middle)
self.tag("1.2", middle)
self.commit("head work", 3)
output = self.changelog("2.0").stdout
self.assertEqual(self.changelog_versions(output), ["2.0", "1.2"])
self.assert_commit_listed(output, "head work")
self.assert_commit_listed(output, "middle")
output = self.changelog("1.0").stdout
self.assertEqual(self.changelog_versions(output), ["1.0"])
self.assert_commit_listed(output, "base")
def test_tagless_snapshot_and_explicit_version(self):
self.make_repo()
self.commit("tagless base", 1)
self.commit("tagless head", 2)
describe = self.git("rev-parse", "--short", "HEAD").stdout.strip()
output = self.changelog().stdout
self.assertEqual(
self.changelog_versions(output),
["0~git.2.{}".format(describe)],
)
self.assert_commit_listed(output, "tagless base")
self.assert_commit_listed(output, "tagless head")
output = self.changelog("2.42.4").stdout
self.assertEqual(self.changelog_versions(output), ["2.42.4"])
self.assert_commit_listed(output, "tagless base")
self.assert_commit_listed(output, "tagless head")
self.tag("2backup")
self.git(
"tag", "-a", "snapshot-note", "-m", "snapshot", "HEAD",
date=1700000900,
)
output = self.changelog().stdout
self.assertEqual(
self.changelog_versions(output),
["0~git.2.{}".format(describe)],
)
self.assertNotIn("2backup", output)
self.assertNotIn("snapshot-note", output)
def test_shallow_tagless_requires_explicit_version(self):
self.make_repo("source")
self.commit("base", 1)
self.commit("shallow head", 2)
source = self.repo
shallow = self.root / "shallow"
rv = self.run_command(
["git", "clone", "-q", "--no-local", "--depth", "1", "--no-tags",
"file://{}".format(source), shallow],
self.root,
)
self.assertEqual(rv.returncode, 0, msg=rv.stderr)
self.repo = shallow
failed = self.changelog(expected=1)
self.assertIn("tagless snapshots need full history", failed.stderr)
output = self.changelog("2.0").stdout
self.assertEqual(self.changelog_versions(output), ["2.0"])
self.assert_commit_listed(output, "shallow head")
build: make NDEBUG=1 and make release build the release profile - The RELEASE=1 profile replaced 2.42.0's NDEBUG=1 one, but the static archives and the container image still build with NDEBUG=1, which therefore selected the debug profile: -O0 -g3 with assertions on. Both Makefiles accept NDEBUG=1 again, as -O3 -DNDEBUG, and the debug profile defines DEBUG. The vendored libfuse follows the same profile as mergerfs. - make release first removes the objects, binaries and stamp under build/ and cleans vendored/libfuse, because make only compares timestamps: objects from an earlier debug build were otherwise linked into the release binary unchanged. Packages and build reports in build/pkgs are kept; TEST_release_pkg_preservation checks both. - make release also builds preload.so. It takes the release defines through its own PRELOAD_CPPFLAGS: the global CPPFLAGS add _FILE_OFFSET_BITS=64, which would hide its unsuffixed open/openat/fopen/creat interposers. - mergerfs.spec builds the release target, as debian/rules does. The distribution's CFLAGS, CXXFLAGS and LDFLAGS still apply. - The release driver mounts the repository with ":ro,z", not ":ro:z", which Podman read as an extra field instead of a mount option. TEST_release_metadata runs the driver against a fake podman and checks the volume argument and the build report. - Remove release-installer: build-release has no installer target. - make help printed a literal "\n" where /bin/sh is bash. Match the build.md transcript to its output and document the profiles. Performance: static archives and the container image go from -O0 with assertions back to optimized builds, now -O3 -DNDEBUG (2.42.0: -O2 -DNDEBUG). RPM packages keep the distribution's -O2 and no longer evaluate assertions. A plain make is unoptimized, as before.
2026-11-29 23:10:53 -05:00
if __name__ == "__main__":
unittest.main()