about summary refs log tree commit homepage
path: root/t/watch_filter_rubylang.t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-09-24 05:42:14 +0000
committerEric Wong <e@80x24.org>2023-09-24 18:56:18 +0000
commit21146412fdc32f8e6707b4e290ad715b35f20845 (patch)
tree53f4f32d1858ccae2ad8d24694da02cdc16ad9b4 /t/watch_filter_rubylang.t
parentf170d220f8765e952c9a102dd35eb694810739df (diff)
downloadpublic-inbox-21146412fdc32f8e6707b4e290ad715b35f20845.tar.gz
It's a needless branch to maintain exclusively for our tests.
The `git config -l' output isn't pleasant to write in tests,
anyways.  So just use heredocs to write git configs in their
native format rather than emulate the output of `git config -l'.

This does make the test suite do more work with temporary files
and process invocations, but it doesn't seem very measurable
when testing on tmpfs (TMPDIR=/dev/shm).

We'll make a minor improvement to TestCommon::tmpdir by allowing
it to return a single value (which I suspect we can rely on in
more places since File::Temp::Dir overloads stringification).
Diffstat (limited to 't/watch_filter_rubylang.t')
-rw-r--r--t/watch_filter_rubylang.t30
1 files changed, 13 insertions, 17 deletions
diff --git a/t/watch_filter_rubylang.t b/t/watch_filter_rubylang.t
index a6153e46..f72feb9f 100644
--- a/t/watch_filter_rubylang.t
+++ b/t/watch_filter_rubylang.t
@@ -1,11 +1,8 @@
-# Copyright (C) 2019-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
-use strict;
-use warnings;
+use v5.12;
 use PublicInbox::TestCommon;
-use Test::More;
 use PublicInbox::Eml;
-use PublicInbox::Config;
 require_mods(qw(DBD::SQLite Xapian));
 use_ok 'PublicInbox::Watch';
 use_ok 'PublicInbox::Emergency';
@@ -25,7 +22,6 @@ SKIP: {
 for my $v (@v) {
         my @warn;
         local $SIG{__WARN__} = sub { push @warn, @_ };
-        my $cfgpfx = "publicinbox.$v";
         my $inboxdir = "$tmpdir/$v";
         my $maildir = "$tmpdir/md-$v";
         my $spamdir = "$tmpdir/spam-$v";
@@ -60,16 +56,16 @@ Date: Sat, 05 Jan 2019 04:19:17 +0000
 spam
 EOF
         PublicInbox::Emergency->new($maildir)->prepare(\"$spam");
-
-        my $orig = <<EOF;
-$cfgpfx.address=$addr
-$cfgpfx.inboxdir=$inboxdir
-$cfgpfx.watch=maildir:$maildir
-$cfgpfx.filter=PublicInbox::Filter::RubyLang
-$cfgpfx.altid=serial:alerts:file=msgmap.sqlite3
-publicinboxwatch.watchspam=maildir:$spamdir
-EOF
-        my $cfg = PublicInbox::Config->new(\$orig);
+        my $cfg = cfg_new $tmpdir, <<EOM;
+[publicinbox "$v"]
+        address = $addr
+        inboxdir = $inboxdir
+        watch = maildir:$maildir
+        filter = PublicInbox::Filter::RubyLang
+        altid = serial:alerts:file=msgmap.sqlite3
+[publicinboxwatch]
+        watchspam = maildir:$spamdir
+EOM
         my $ibx = $cfg->lookup_name($v);
         $ibx->{-no_fsync} = 1;
         ok($ibx, 'found inbox by name');
@@ -102,7 +98,7 @@ EOF
         # ensure orderly destruction to avoid SQLite segfault:
         PublicInbox::DS->Reset;
 
-        $cfg = PublicInbox::Config->new(\$orig);
+        $cfg = PublicInbox::Config->new($cfg->{-f});
         $ibx = $cfg->lookup_name($v);
         $ibx->{-no_fsync} = 1;
         is($ibx->search->reopen->mset('b:spam')->size, 0, 'spam removed');