From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id AFF6B1F5BF for ; Fri, 15 Nov 2019 09:51:04 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 21/29] t/convert-compact: convert to run_script Date: Fri, 15 Nov 2019 09:50:52 +0000 Message-Id: <20191115095100.25633-22-e@80x24.org> In-Reply-To: <20191115095100.25633-1-e@80x24.org> References: <20191115095100.25633-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: While this didn't use IPC::Run, having to reload several Perl modules and scripts is slow and inefficient, so roughly double the speed of this test. --- t/convert-compact.t | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/t/convert-compact.t b/t/convert-compact.t index dbccfbad..0661ed14 100644 --- a/t/convert-compact.t +++ b/t/convert-compact.t @@ -62,22 +62,20 @@ foreach (@xdir) { 'sharedRepository respected on file after convert'); } -local $ENV{PATH} = "blib/script:$ENV{PATH}"; local $ENV{PI_CONFIG} = '/dev/null'; -open my $err, '>>', "$tmpdir/err.log" or die "open: err.log $!\n"; -open my $out, '>>', "$tmpdir/out.log" or die "open: out.log $!\n"; -my $rdr = { 1 => fileno($out), 2 => fileno($err) }; +my ($out, $err) = ('', ''); +my $rdr = { 1 => \$out, 2 => \$err }; -my $cmd = [ 'public-inbox-compact', $ibx->{inboxdir} ]; -ok(PublicInbox::Import::run_die($cmd, undef, $rdr), 'v1 compact works'); +my $cmd = [ '-compact', $ibx->{inboxdir} ]; +ok(run_script($cmd, undef, $rdr), 'v1 compact works'); @xdir = glob("$ibx->{inboxdir}/public-inbox/xap*"); is(scalar(@xdir), 1, 'got one xapian directory after compact'); is(((stat($xdir[0]))[2]) & 07777, 0755, 'sharedRepository respected on v1 compact'); -$cmd = [ 'public-inbox-convert', $ibx->{inboxdir}, "$tmpdir/v2" ]; -ok(PublicInbox::Import::run_die($cmd, undef, $rdr), 'convert works'); +$cmd = [ '-convert', $ibx->{inboxdir}, "$tmpdir/v2" ]; +ok(run_script($cmd, undef, $rdr), 'convert works'); @xdir = glob("$tmpdir/v2/xap*/*"); foreach (@xdir) { my @st = stat($_); @@ -85,9 +83,9 @@ foreach (@xdir) { 'sharedRepository respected after convert'); } -$cmd = [ 'public-inbox-compact', "$tmpdir/v2" ]; +$cmd = [ '-compact', "$tmpdir/v2" ]; my $env = { NPROC => 2 }; -ok(PublicInbox::Import::run_die($cmd, $env, $rdr), 'v2 compact works'); +ok(run_script($cmd, $env, $rdr), 'v2 compact works'); $ibx->{inboxdir} = "$tmpdir/v2"; $ibx->{version} = 2;