diff options
| author | aur-build <aur-build@localhost> | 2026-11-19 19:40:38 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-19 19:40:38 +0000 |
| commit | bc4916d4a7de6a60d8b73ed7e3ccc0ec0695d580 (patch) | |
| tree | cff4b8b2976579b565462467fba478b6209367b1 /tools | |
| parent | 8e4e88946e52455e78065257a46a7e6d63147101 (diff) | |
| download | aur-build-bc4916d4a7de6a60d8b73ed7e3ccc0ec0695d580.tar.gz aur-build-bc4916d4a7de6a60d8b73ed7e3ccc0ec0695d580.zip | |
tests: record the vercmp oracle instead of spawning it 1,089 times
The differential against pacman's vercmp is the suite's second biggest
process cost, and its verdicts are a function of two strings plus the pacman
that produced them. They are recorded in testcorpus/vercmp-oracle.tsv now and
compared in process on every run, antisymmetry of the table included. The live
differential is still there - AUR_LIVE_VERCMP=1 runs it and says so when it is
not run.
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/gen-vercmp-oracle.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tools/gen-vercmp-oracle.py b/tools/gen-vercmp-oracle.py new file mode 100755 index 0000000..992e10c --- /dev/null +++ b/tools/gen-vercmp-oracle.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +"""Regenerate testcorpus/vercmp-oracle.tsv from pacman's `vercmp`. + +The suite used to shell out to `vercmp` 1,090 times per run to differential-test +pkgver::vercmp_string. The verdicts are a function of the two strings and the +pacman version that produced them, so they are recorded once here and compared +in process instead. The live differential still exists — tests/versions.rs runs +it when AUR_LIVE_VERCMP is set — this is the part that runs on every run. + +Usage: tools/gen-vercmp-oracle.py [path] +""" + +import os +import subprocess +import sys + +FRAGMENTS = [ + "1", "1.0", "1.0.0", "1.0.1", "1.1", "2", "2.0", "1.0a", "1.0rc1", "1.0.2a", "1.0.2.1", + "1.0.2.a", "1.0.2.aa", "1.0.2.b", "1.0.2z", "1.0z", "1.0.z", "0.9", "10", "2.24", "2.5", + "1.02", "1.0_2", "1.0.p", "1.0.3a", "1.0.3b", "1.a", "1a", "1.0+git", "1.0~beta", "2.0_1", + "1.0.x", "2024.01", +] + +ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +OUT = sys.argv[1] if len(sys.argv) > 1 else os.path.join(ROOT, "testcorpus", "vercmp-oracle.tsv") + + +def main(): + pacman = subprocess.run(["pacman", "-Q", "pacman"], capture_output=True, text=True).stdout.strip() + rows = [] + for a in FRAGMENTS: + for b in FRAGMENTS: + verdict = int(subprocess.run(["vercmp", a, b], capture_output=True, text=True).stdout.strip()) + rows.append(f"{a}\t{b}\t{verdict}") + + with open(OUT, "w") as handle: + handle.write("# pkgver::vercmp_string differential, generated by tools/gen-vercmp-oracle.py\n") + handle.write(f"# oracle: {pacman or 'vercmp not owned by pacman'}\n") + handle.write("# columns: a <TAB> b <TAB> sign(vercmp a b)\n") + handle.write("\n".join(rows) + "\n") + print(f"{OUT}: {len(rows)} rows") + + +if __name__ == "__main__": + main() |
