about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-03-15 12:57:52 +0100
committerEric Wong <e@80x24.org>2021-03-15 16:53:59 -0400
commitaf9a34eba5696fc881d2d61864fa62220ccf8ba5 (patch)
treea263c854edd686394bfa06eb96a5344a1cbe93a7 /t
parentd5bc3deb285453d777f253dc36cf4b1ae694a6f8 (diff)
downloadpublic-inbox-af9a34eba5696fc881d2d61864fa62220ccf8ba5.tar.gz
This saves over 100ms in t/lei-q-remote-import.t so far when
TMPDIR is on an SSD.  If we can memoize inbox creation to save a
few dozen milliseconds every test, this could add up to
noticeable savings across our entire test suite.
Diffstat (limited to 't')
-rw-r--r--t/data-gen/.gitignore2
-rw-r--r--t/lei-q-remote-import.t20
2 files changed, 7 insertions, 15 deletions
diff --git a/t/data-gen/.gitignore b/t/data-gen/.gitignore
new file mode 100644
index 00000000..11e8933b
--- /dev/null
+++ b/t/data-gen/.gitignore
@@ -0,0 +1,2 @@
+# read-only test data generated by create_inbox
+*
diff --git a/t/lei-q-remote-import.t b/t/lei-q-remote-import.t
index 8b82579c..2293489a 100644
--- a/t/lei-q-remote-import.t
+++ b/t/lei-q-remote-import.t
@@ -5,7 +5,6 @@ use strict; use v5.10.1; use PublicInbox::TestCommon;
 require_git 2.6;
 require_mods(qw(json DBD::SQLite Search::Xapian));
 use PublicInbox::MboxReader;
-use PublicInbox::InboxWritable;
 my ($ro_home, $cfg_path) = setup_public_inboxes;
 my $sock = tcp_server;
 my ($tmpdir, $for_destroy) = tmpdir;
@@ -61,20 +60,11 @@ test_lei({ tmpdir => $tmpdir }, sub {
         lei_ok(@cmd, '--lock=dotlock,timeout=0.000001',
                 \'succeeds after lock removal');
 
-        # XXX memoize this external creation
-        my $inboxdir = "$ENV{HOME}/tmp_git";
-        my $ibx = PublicInbox::InboxWritable->new({
-                name => 'tmp',
-                -primary_address => 'lei@example.com',
-                inboxdir => $inboxdir,
-                indexlevel => 'medium',
-        }, { nproc => 1 });
-        my $im = $ibx->importer(0);
-        $im->add(eml_load('t/utf8.eml')) or BAIL_OUT '->add';
-        $im->done;
-
-        run_script(['-index', $inboxdir], undef) or BAIL_OUT '-init';
-        lei_ok(qw(add-external -q), $inboxdir);
+        my $ibx = create_inbox 'local-external', indexlevel => 'medium', sub {
+                my ($im) = @_;
+                $im->add(eml_load('t/utf8.eml')) or BAIL_OUT '->add';
+        };
+        lei_ok(qw(add-external -q), $ibx->{inboxdir});
         lei_ok(qw(q -o), "mboxrd:$o", '--only', $url,
                 'm:testmessage@example.com');
         ok(-s $o, 'got result from remote external');