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 212A61F463 for ; Sun, 5 Jan 2020 00:06:02 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] tests: remove some "git config" calls after "git init" Date: Sun, 5 Jan 2020 00:06:01 +0000 Message-Id: <20200105000601.11674-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Creating a hash and iterating through it just to run "git config" is ugly and slow. Just write out the text file in a human-friendly way since the git-config file format is stable and won't break randomly. --- t/cgi.t | 18 ++++++++---------- t/mda.t | 15 +++++++-------- t/plack.t | 20 +++++++++----------- 3 files changed, 24 insertions(+), 29 deletions(-) diff --git a/t/cgi.t b/t/cgi.t index 424b738e..90543a7a 100644 --- a/t/cgi.t +++ b/t/cgi.t @@ -13,7 +13,6 @@ my $pi_home = "$home/.public-inbox"; my $pi_config = "$pi_home/config"; my $maindir = "$tmpdir/main.git"; my $addr = 'test-public@example.com'; -my $cfgpfx = "publicinbox.test"; { is(1, mkdir($home, 0755), "setup ~/ for testing"); @@ -23,15 +22,14 @@ my $cfgpfx = "publicinbox.test"; open my $fh, '>', "$maindir/description" or die "open: $!\n"; print $fh "test for public-inbox\n"; close $fh or die "close: $!\n"; - my %cfg = ( - "$cfgpfx.address" => $addr, - "$cfgpfx.inboxdir" => $maindir, - "$cfgpfx.indexlevel" => 'basic', - ); - while (my ($k,$v) = each %cfg) { - is(0, system(qw(git config --file), $pi_config, $k, $v), - "setup $k"); - } + open $fh, '>>', $pi_config or die; + print $fh < $addr, - "$cfgpfx.inboxdir" => $maindir, - ); - while (my ($k,$v) = each %cfg) { - is(0, system(qw(git config --file), $pi_config, $k, $v), - "setup $k"); - } + open my $fh, '>>', $pi_config or die; + print $fh <', "$maindir/description" or die "open: $!\n"; print $fh "test for public-inbox\n"; close $fh or die "close: $!\n"; - my %cfg = ( - "$cfgpfx.address" => $addr, - "$cfgpfx.inboxdir" => $maindir, - "$cfgpfx.url" => 'http://example.com/test/', - "$cfgpfx.newsgroup" => 'inbox.test', - ); - while (my ($k,$v) = each %cfg) { - is(0, system(qw(git config --file), $pi_config, $k, $v), - "setup $k"); - } + open $fh, '>>', $pi_config or die; + print $fh <