use v5.12;
use PublicInbox::TestCommon;
use PublicInbox::Import;
+use PublicInbox::IO qw(write_file);
use_ok 'PublicInbox';
ok(defined(eval('$PublicInbox::VERSION')), 'VERSION defined');
use_ok 'PublicInbox::Config';
{
my $f = "$tmpdir/bool_config";
- open my $fh, '>', $f;
- print $fh <<EOM;
+ write_file '>', $f, <<EOM;
[imap]
debug
port = 2
EOM
- close $fh;
my $cfg = PublicInbox::Config->git_config_dump($f);
$validate_git_behavior and
is(xqx([qw(git config -f), $f, qw(--bool imap.debug)]),
my $inboxdir = "$tmpdir/new\nline";
my @cmd = ('git', "--git-dir=$tmpdir",
qw(config publicinbox.foo.inboxdir), $inboxdir);
- is(xsys(@cmd), 0, "set config");
+ xsys_e(@cmd);
my $tmp = PublicInbox::Config->new("$tmpdir/config");
{
my $f = "$tmpdir/ordered";
- open my $fh, '>', $f or die "open: $!";
+ open my $fh, '>', $f;
my @expect;
foreach my $i (0..3) {
push @expect, "$i";
- print $fh <<"" or die "print: $!";
+ print $fh <<"";
[publicinbox "$i"]
inboxdir = /path/to/$i.git
address = $i\@example.com
}
- close $fh or die "close: $!";
+ close $fh;
my $cfg = PublicInbox::Config->new($f);
my @result;
$cfg->each_inbox(sub { push @result, $_[0]->{name} });
use PublicInbox::Spawn qw(run_qx which);
use File::Path qw(remove_tree);
use PublicInbox::IO qw(write_file);
-use autodie qw(symlink unlink);
+use autodie qw(close mkdir open rename symlink unlink);
require_mods qw(DBD::SQLite Xapian);
require PublicInbox::SolverGit;
my $rdr = { 2 => \(my $null) };
};
my $md = "$tmpdir/md";
File::Path::make_path(map { $md.$_ } (qw(/cur /new /tmp)));
-symlink(abs_path('t/solve/0001-simple-mod.patch'), "$md/cur/foo:2,") or
- xbail "symlink: $!";
+symlink abs_path('t/solve/0001-simple-mod.patch'), "$md/cur/foo:2,";
my $v1_0_0_rev = '8a918a8523bc9904123460f85999d75f6d604916';
my $v1_0_0_tag = 'cb7c42b1e15577ed2215356a2bf925aef59cdd8d';
my $non_existent = 'ee5e32211bf62ab6531bdf39b84b6920d0b6775a';
my $stderr_empty = sub {
my ($msg) = @_;
- open my $efh, '<', "$tmpdir/stderr.log" or xbail $!;
+ open my $efh, '<', "$tmpdir/stderr.log";
my @l = <$efh>;
@l = grep(!/reverse ?proxy/i, @l);
is_xdeeply(\@l, [], $msg // 'stderr.log is empty');
$ibx->{-repo_objs} = [ $git ];
my $res;
my $solver = PublicInbox::SolverGit->new($ibx, sub { $res = $_[0] });
-open my $log, '+>>', "$tmpdir/solve.log" or die "open: $!";
+open my $log, '+>>', "$tmpdir/solve.log";
my $psgi_env = { 'psgi.errors' => \*STDERR, 'psgi.url_scheme' => 'http',
'HTTP_HOST' => 'example.com' };
$solver->solve($psgi_env, $log, '69df7d5', {});
my $lk = PublicInbox::Lock->new($l);
my $acq = $lk->lock_for_scope;
my $stamp = "$binfoo/stamp-";
- if (open my $fh, '<', $stamp) {
+ if (CORE::open my $fh, '<', $stamp) {
%oid = map { chomp; split(/=/, $_) } (<$fh>);
} else {
PublicInbox::Import::init_bare($binfoo);
$oid{$label} = $x;
}
- open my $null, '<', '/dev/null' or xbail "open /dev/null: $!";
+ open my $null, '<', '/dev/null';
my $t = xqx([qw(git mktree)], $env, { 0 => $null });
xbail "mktree: $?" if $?;
chomp($t);
chomp($c);
$oid{'8859-parent'} = $c;
- open my $fh, '>', "$stamp.$$" or BAIL_OUT;
+ open my $fh, '>', "$stamp.$$";
while (my ($k, $v) = each %oid) {
- print $fh "$k=$v\n" or xbail "print: $!";
+ print $fh "$k=$v\n";
}
- close $fh or BAIL_OUT;
- rename("$stamp.$$", $stamp) or BAIL_OUT;
+ close $fh;
+ rename "$stamp.$$", $stamp;
}
undef $acq;
# ensure the PSGI frontend (ViewVCS) works:
my $name = $ibx->{name};
my $cfgpfx = "publicinbox.$name";
my $cfgpath = "$tmpdir/httpd-config";
- open my $cfgfh, '>', $cfgpath or die;
- print $cfgfh <<EOF or die;
+ write_file '>', $cfgpath, <<EOF;
[coderepo]
snapshots = tar.gz
[publicinbox "$name"]
[coderepo "goner"]
dir = $gone_repo
EOF
- close $cfgfh or die;
my $exp_digest;
{
my $exp = xqx([qw(git archive --format=tar.gz
if (defined $ENV{PLACK_TEST_EXTERNALSERVER_URI}) {
$stderr_empty->('nothing in stderr.log, yet');
} else {
- open $olderr, '>&', \*STDERR or xbail "open: $!";
- open STDERR, '+>>', "$tmpdir/stderr.log" or
- xbail "open: $!";
+ open $olderr, '>&', \*STDERR;
+ open STDERR, '+>>', "$tmpdir/stderr.log";
}
$res = $cb->(GET('/binfoo/'));
defined($ENV{PLACK_TEST_EXTERNALSERVER_URI}) or
- open STDERR, '>&', $olderr or xbail "open: $!";
+ open STDERR, '>&', $olderr;
is($res->code, 200, 'coderepo summary (binfoo)');
$stderr_empty->();
test_httpd($env, $client, 7, sub {
SKIP: {
require_cmd('curl', 1) or skip 'no curl', 1;
- mkdir "$tmpdir/ext" // xbail "mkdir $!";
+ mkdir "$tmpdir/ext";
my $rurl = "$ENV{PLACK_TEST_EXTERNALSERVER_URI}/$name";
test_lei({tmpdir => "$tmpdir/ext"}, sub {
lei_ok(qw(blob --no-mail 69df7d5 -I), $rurl);