]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
test_common: support `require_mods "v2"' for v2 inboxes
authorEric Wong <e@80x24.org>
Wed, 1 Jan 2025 22:36:59 +0000 (22:36 +0000)
committerEric Wong <e@80x24.org>
Thu, 2 Jan 2025 22:23:44 +0000 (22:23 +0000)
For our purposes, `v2' should be interpreted as a public-inbox
format and not as a Perl version (e.g. `use v5.12').  This ensures
v2index-late-dupe.t correctly depends on DBD::SQLite and git
v2.6+ via `require_mods "v2"' instead of requiring Perl v2.x.

On a side note, it's unlikely public-inbox-v3 format will ever
be necessary as the v2 format appears scalable enough; thus we
won't hit v5 and risk conflicting with in-use Perl versions.
However, I'm not ruling out a v2.112 format for (nearly)
transparent v1->v2 migrations.

lib/PublicInbox/TestCommon.pm

index 0f5b107dca854b78b8b7d9006b4e16b965fca02a..a887fef8f440c7da702a0f6b532afa03702bde0a 100644 (file)
@@ -209,6 +209,13 @@ sub require_mods (@) {
                        push @mods, qw(DBD::SQLite Xapian +SCM_RIGHTS);
                        $mod = 'json'; # fall-through
                }
+               if ($mod eq 'v2') {
+                       require_git v2.6, $maybe ? $maybe : 0;
+                       push @mods, 'DBD::SQLite';
+                       next;
+               } elsif ($mod =~ /\Av/) { # don't confuse with Perl versions
+                       Carp::croak "BUG: require_mods `$mod' ambiguous";
+               }
                if ($mod eq 'json') {
                        $mod = 'Cpanel::JSON::XS||JSON::MaybeXS||JSON||JSON::PP'
                } elsif ($mod eq '-httpd') {