unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH v2 4/4] t/v2writable: use 5.10.1 and autodie more
Date: Fri, 26 Jul 2024 21:31:11 +0000	[thread overview]
Message-ID: <20240726214311.4092940-5-e@80x24.org> (raw)
In-Reply-To: <20240726214311.4092940-1-e@80x24.org>

Switching to Perl v5.12 will require more review due to
unicode_strings, but 5.10.1 is an easy change and we can rely
more on autodie to simplify error checking.
---
 t/v2writable.t | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/t/v2writable.t b/t/v2writable.t
index 0493f90e..496eba2c 100644
--- a/t/v2writable.t
+++ b/t/v2writable.t
@@ -1,15 +1,14 @@
-# Copyright (C) 2018-2021 all contributors <meta@public-inbox.org>
+#!perl -w
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
-use strict;
-use warnings;
-use Test::More;
+use v5.10.1; # FIXME: check 5.12 unicode_strings compat
 use PublicInbox::Eml;
 use PublicInbox::ContentHash qw(content_digest content_hash);
 use PublicInbox::TestCommon;
 use PublicInbox::Spawn qw(popen_rd);
 use Config;
 use Cwd qw(abs_path);
-use autodie qw(kill open read);
+use autodie qw(chmod close kill open read);
 require_git(2.6);
 require_mods(qw(DBD::SQLite Xapian));
 local $ENV{HOME} = abs_path('t');
@@ -157,16 +156,15 @@ SELECT COUNT(*) FROM over WHERE num > 0
 	my $out = "$inboxdir/stdout.log";
 	my $group = 'inbox.comp.test.v2writable';
 	my $pi_config = "$inboxdir/pi_config";
-	open my $fh, '>', $pi_config or die "open: $!\n";
-	print $fh <<EOF
+	open my $fh, '>', $pi_config;
+	print $fh <<EOF;
 [publicinbox "test-v2writable"]
 	inboxdir = $inboxdir
 	version = 2
 	address = test\@example.com
 	newsgroup = $group
 EOF
-	;
-	close $fh or die "close: $!\n";
+	close $fh;
 	my $sock = tcp_server();
 	my $len;
 	my $cmd = [ '-nntpd', '-W0', "--stdout=$out", "--stderr=$err" ];
@@ -320,15 +318,15 @@ ok($@, 'V2Writable fails on non-existent dir');
 	$v2w->{parallel} = 0;
 	$v2w->init_inbox(0);
 	my $alt = "$tmp->{inboxdir}/all.git/objects/info/alternates";
-	open my $fh, '>>', $alt or die $!;
-	print $fh "$inboxdir/all.git/objects\n" or die $!;
-	chmod(0664, $fh) or die "fchmod: $!";
-	close $fh or die $!;
-	open $fh, '<', $alt or die $!;
+	open my $fh, '>>', $alt;
+	print $fh "$inboxdir/all.git/objects\n";
+	chmod 0664, $fh;
+	close $fh;
+	open $fh, '<', $alt;
 	my $before = do { local $/; <$fh> };
 
 	ok($v2w->{mg}->add_epoch(3), 'init a new epoch');
-	open $fh, '<', $alt or die $!;
+	open $fh, '<', $alt;
 	my $after = do { local $/; <$fh> };
 	ok(index($after, $before) > 0,
 		'old contents preserved after adding epoch');

      parent reply	other threads:[~2024-07-26 21:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-23 21:28 [PATCH 0/4] fix ENOSPC on writes Eric Wong
2024-07-23 21:28 ` [PATCH 1/4] t/msgmap: updates for Perl 5.12+ and copyrights Eric Wong
2024-07-23 21:28 ` [PATCH 2/4] msgmap: mid_insert: reraise on unexpected errors Eric Wong
2024-07-24  7:22   ` [PATCH 2/4] msgmap: mid_insert: reraise on unexpected errors, [PATCH 3/4] t/v2writable: test ENOSPC from fast-import Štěpán Němec
2024-07-25  0:38     ` Eric Wong
2024-07-25  6:42       ` Štěpán Němec
2024-07-23 21:28 ` Eric Wong
2024-07-23 21:28 ` [PATCH 4/4] t/v2writable: use 5.10.1 and autodie more Eric Wong
2024-07-26 21:31 ` [PATCH v2 0/4] fix ENOSPC on writes Eric Wong
2024-07-26 21:31   ` [PATCH v2 1/4] t/msgmap: updates for Perl 5.12+ and copyrights Eric Wong
2024-07-26 21:31   ` [PATCH v2 2/4] msgmap: mid_insert: reraise on unexpected errors Eric Wong
2024-07-26 21:31   ` [PATCH v2 3/4] t/v2writable: test ENOSPC from fast-import Eric Wong
2024-07-26 21:31   ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240726214311.4092940-5-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).