2 # Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use PublicInbox::TestCommon;
8 use PublicInbox::Config;
9 use List::Util qw(shuffle);
10 require_mods(qw(DBD::SQLite));
13 chomp(my @msgs = split(/\n\n/, <<'EOF')); # "git log" order
14 Subject: [bug#45000] [PATCH 1/9]
15 References: <20201202045335.31096-1-j@example.com>
16 Message-Id: <20201202045540.31248-1-j@example.com>
18 Subject: [bug#45000] [PATCH 0/9]
19 Message-Id: <20201202045335.31096-1-j@example.com>
21 Subject: [bug#45000] [PATCH 0/9]
22 References: <20201202045335.31096-1-j@example.com>
23 Message-ID: <86sg8o1mou.fsf@example.com>
25 Subject: [bug#45000] [PATCH 8/9]
26 Message-Id: <20201202045540.31248-8-j@example.com>
27 References: <20201202045540.31248-1-j@example.com>
31 my ($home, $for_destroy) = tmpdir();
32 for my $msgs (['orig', reverse @msgs], ['shuffle', shuffle(@msgs)]) {
33 my $desc = shift @$msgs;
34 my $n = "index-cap-$desc-basic";
35 # yes, the shuffle case gets memoized by create_inbox, oh well
36 my $ibx = create_inbox $desc, version => 2, indexlevel => 'basic',
37 tmpdir => "$home/$desc", sub {
40 my $x = "$m\nFrom: x\@example.com\n\n";
41 $im->add(PublicInbox::Eml->new(\$x));
44 my $over = $ibx->over;
46 my $tid = $dbh->selectall_arrayref('SELECT DISTINCT(tid) FROM over');
47 is(scalar(@$tid), 1, "only one thread initially ($desc)");
49 my $env = { HOME => $home };
50 run_script([qw(-index --no-fsync --reindex --rethread),
51 $ibx->{inboxdir}], $env) or BAIL_OUT 'rethread';
52 $tid = $dbh->selectall_arrayref('SELECT DISTINCT(tid) FROM over');
53 is(scalar(@$tid), 1, "only one thread after rethread ($desc)");