-require './t/common.perl';
-require_git(2.6);
-my $this = (split('/', __FILE__))[-1];
-
-foreach my $mod (qw(DBD::SQLite)) {
- eval "require $mod";
- plan skip_all => "$mod missing for $this" if $@;
-}
-
-my $path = 'blib/script';
-my $index = "$path/public-inbox-index";
-my @xcpdb = ("$path/public-inbox-xcpdb", '-q');
-
-my $mime = PublicInbox::MIME->create(
- header => [
- From => 'a@example.com',
- To => 'test@example.com',
- Subject => 'this is a subject',
- Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
- ],
- body => "hello world\n",
-);
-
-sub import_index_incremental {
- my ($v, $level) = @_;
- my $tmpdir = tempdir("pi-$this-tmp-XXXXXX", TMPDIR => 1, CLEANUP => 1);
- my $ibx = PublicInbox::Inbox->new({
- mainrepo => "$tmpdir/testbox",
- name => "$this-$v",
- version => $v,
- -primary_address => 'test@example.com',
- indexlevel => $level,
- });
- my $im = PublicInbox::InboxWritable->new($ibx, {nproc=>1})->importer;
- $mime->header_set('Message-ID', '<m@1>');
- ok($im->add($mime), 'first message added');
- $im->done;
+my $PI_TEST_VERSION = $ENV{PI_TEST_VERSION} || 2;
+require_git('2.6') if $PI_TEST_VERSION == 2;
+require_mods(qw(DBD::SQLite));
+
+my $mime = PublicInbox::Eml->new(<<'EOF');
+From: a@example.com
+To: test@example.com
+Subject: this is a subject
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+
+hello world
+EOF
+
+my $import_index_incremental = sub {
+ my ($v, $level, $mime) = @_;
+ my $err = '';
+ my $this = "pi-$v-$level-indexlevels";
+ my ($tmpdir, $for_destroy) = tmpdir();
+ my $ibx = create_inbox "testbox$v", indexlevel => $level,
+ version => $v, tmpdir => "$tmpdir/v$v", sub {
+ $mime->header_set('Message-ID', '<m@1>');
+ $_[0]->add($mime) or BAIL_OUT;
+ };
+ my $im = $ibx->importer(0);
+ local $ENV{PI_CONFIG} = "$tmpdir/config";