diff options
Diffstat (limited to 't')
-rw-r--r-- | t/admin.t | 3 | ||||
-rw-r--r-- | t/altid.t | 2 | ||||
-rw-r--r-- | t/cgi.t | 3 | ||||
-rw-r--r-- | t/config.t | 3 | ||||
-rw-r--r-- | t/convert-compact.t | 3 | ||||
-rw-r--r-- | t/feed.t | 2 | ||||
-rw-r--r-- | t/git.t | 5 | ||||
-rw-r--r-- | t/html_index.t | 2 | ||||
-rw-r--r-- | t/import.t | 3 | ||||
-rw-r--r-- | t/mda.t | 3 | ||||
-rw-r--r-- | t/nulsubject.t | 2 | ||||
-rw-r--r-- | t/psgi_attach.t | 2 | ||||
-rw-r--r-- | t/psgi_mount.t | 2 | ||||
-rw-r--r-- | t/psgi_text.t | 2 | ||||
-rw-r--r-- | t/search-thr-index.t | 3 | ||||
-rw-r--r-- | t/solver_git.t | 3 | ||||
-rw-r--r-- | t/v1-add-remove-add.t | 2 | ||||
-rw-r--r-- | t/v1reindex.t | 2 | ||||
-rw-r--r-- | t/watch_maildir.t | 3 | ||||
-rw-r--r-- | t/watch_maildir_v2.t | 3 | ||||
-rw-r--r-- | t/www_listing.t | 5 |
21 files changed, 33 insertions, 25 deletions
@@ -4,13 +4,14 @@ use strict; use warnings; use Test::More; use PublicInbox::TestCommon; +use PublicInbox::Import; use_ok 'PublicInbox::Admin', qw(resolve_repo_dir); my ($tmpdir, $for_destroy) = tmpdir(); my $git_dir = "$tmpdir/v1"; my $v2_dir = "$tmpdir/v2"; my ($res, $err, $v); -is(0, system(qw(git init -q --bare), $git_dir), 'git init v1'); +PublicInbox::Import::init_bare($git_dir); # v1 is(resolve_repo_dir($git_dir), $git_dir, 'top-level GIT_DIR resolved'); @@ -23,9 +23,9 @@ my $ibx; } { - is(system(qw(git init -q --bare), $git_dir), 0, 'git init ok'); my $git = PublicInbox::Git->new($git_dir); my $im = PublicInbox::Import->new($git, 'testbox', 'test@example'); + $im->init_bare; $im->add(Email::MIME->create( header => [ From => 'a@example.com', @@ -7,6 +7,7 @@ use warnings; use Test::More; use Email::MIME; use PublicInbox::TestCommon; +use PublicInbox::Import; require_mods(qw(Plack::Handler::CGI Plack::Util)); my ($tmpdir, $for_destroy) = tmpdir(); my $home = "$tmpdir/pi-home"; @@ -18,7 +19,7 @@ my $addr = 'test-public@example.com'; { is(1, mkdir($home, 0755), "setup ~/ for testing"); is(1, mkdir($pi_home, 0755), "setup ~/.public-inbox"); - is(0, system(qw(git init -q --bare), $maindir), "git init (main)"); + PublicInbox::Import::init_bare($maindir); open my $fh, '>', "$maindir/description" or die "open: $!\n"; print $fh "test for public-inbox\n"; @@ -5,10 +5,11 @@ use warnings; use Test::More; use PublicInbox::Config; use PublicInbox::TestCommon; +use PublicInbox::Import; my ($tmpdir, $for_destroy) = tmpdir(); { - is(system(qw(git init -q --bare), $tmpdir), 0, "git init successful"); + PublicInbox::Import::init_bare($tmpdir); my @cmd = ('git', "--git-dir=$tmpdir", qw(config foo.bar), "hi\nhi"); is(system(@cmd), 0, "set config"); diff --git a/t/convert-compact.t b/t/convert-compact.t index 70609c7d..af16b701 100644 --- a/t/convert-compact.t +++ b/t/convert-compact.t @@ -20,8 +20,7 @@ my $ibx = { -primary_address => 'test@example.com', }; -ok(PublicInbox::Import::run_die([qw(git init --bare -q), $ibx->{inboxdir}]), - 'initialized v1 repo'); +PublicInbox::Import::init_bare($ibx->{inboxdir}); ok(umask(077), 'set restrictive umask'); ok(PublicInbox::Import::run_die([qw(git) , "--git-dir=$ibx->{inboxdir}", qw(config core.sharedRepository 0644)]), 'set sharedRepository'); @@ -34,7 +34,7 @@ my $git = $ibx->git; my $im = PublicInbox::Import->new($git, $ibx->{name}, 'test@example'); { - is(0, system(qw(git init -q --bare), $git_dir), "git init"); + $im->init_bare; local $ENV{GIT_DIR} = $git_dir; foreach my $i (1..6) { @@ -6,11 +6,12 @@ use Test::More; use PublicInbox::TestCommon; my ($dir, $for_destroy) = tmpdir(); use PublicInbox::Spawn qw(popen_rd); +use PublicInbox::Import; use_ok 'PublicInbox::Git'; { - is(system(qw(git init -q --bare), $dir), 0, 'created git directory'); + PublicInbox::Import::init_bare($dir); my $fi_data = './t/git.fast-import-data'; ok(-r $fi_data, "fast-import data readable (or run test at top level)"); local $ENV{GIT_DIR} = $dir; @@ -90,7 +91,7 @@ if (1) { if ('alternates reloaded') { my ($alt, $alt_obj) = tmpdir(); my @cmd = ('git', "--git-dir=$alt", qw(hash-object -w --stdin)); - is(system(qw(git init -q --bare), $alt), 0, 'create alt directory'); + PublicInbox::Import::init_bare($alt); open my $fh, '<', "$alt/config" or die "open failed: $!\n"; my $rd = popen_rd(\@cmd, {}, { 0 => $fh } ); close $fh or die "close failed: $!"; diff --git a/t/html_index.t b/t/html_index.t index 158a7862..fda3962a 100644 --- a/t/html_index.t +++ b/t/html_index.t @@ -22,7 +22,7 @@ my $im = PublicInbox::Import->new($git, 'tester', 'test@example'); # setup { - is(0, system(qw(git init -q --bare), $git_dir), "git init"); + $im->init_bare; my $prev = ""; foreach my $i (1..6) { @@ -12,10 +12,9 @@ use File::Temp qw/tempfile/; use PublicInbox::TestCommon; my ($dir, $for_destroy) = tmpdir(); -is(system(qw(git init -q --bare), $dir), 0, 'git init successful'); my $git = PublicInbox::Git->new($dir); - my $im = PublicInbox::Import->new($git, 'testbox', 'test@example'); +$im->init_bare; my $mime = PublicInbox::MIME->create( header => [ From => 'a@example.com', @@ -9,6 +9,7 @@ use PublicInbox::MID qw(mid2path); use PublicInbox::Git; use PublicInbox::InboxWritable; use PublicInbox::TestCommon; +use PublicInbox::Import; my ($tmpdir, $for_destroy) = tmpdir(); my $home = "$tmpdir/pi-home"; my $pi_home = "$home/.public-inbox"; @@ -48,7 +49,7 @@ my $fail_bad_header = sub ($$$) { "spamc mock found (run in top of source tree"); is(1, mkdir($home, 0755), "setup ~/ for testing"); is(1, mkdir($pi_home, 0755), "setup ~/.public-inbox"); - is(0, system(qw(git init -q --bare), $maindir), "git init (main)"); + PublicInbox::Import::init_bare($maindir); open my $fh, '>>', $pi_config or die; print $fh <<EOF or die; diff --git a/t/nulsubject.t b/t/nulsubject.t index fec6c1ae..b21507c2 100644 --- a/t/nulsubject.t +++ b/t/nulsubject.t @@ -11,9 +11,9 @@ my ($tmpdir, $for_destroy) = tmpdir(); my $git_dir = "$tmpdir/a.git"; { - is(system(qw(git init -q --bare), $git_dir), 0, 'git init ok'); my $git = PublicInbox::Git->new($git_dir); my $im = PublicInbox::Import->new($git, 'testbox', 'test@example'); + $im->init_bare; $im->add(Email::MIME->create( header => [ From => 'a@example.com', diff --git a/t/psgi_attach.t b/t/psgi_attach.t index 297e92e1..a47f3754 100644 --- a/t/psgi_attach.t +++ b/t/psgi_attach.t @@ -21,9 +21,9 @@ my $config = PublicInbox::Config->new(\<<EOF); $cfgpfx.address=$addr $cfgpfx.inboxdir=$maindir EOF -is(0, system(qw(git init -q --bare), $maindir), "git init (main)"); my $git = PublicInbox::Git->new($maindir); my $im = PublicInbox::Import->new($git, 'test', $addr); +$im->init_bare; { open my $fh, '<', '/dev/urandom' or die "unable to open urandom: $!\n"; diff --git a/t/psgi_mount.t b/t/psgi_mount.t index 8cac3502..3afb1fb5 100644 --- a/t/psgi_mount.t +++ b/t/psgi_mount.t @@ -21,9 +21,9 @@ my $config = PublicInbox::Config->new(\<<EOF); $cfgpfx.address=$addr $cfgpfx.inboxdir=$maindir EOF -is(0, system(qw(git init -q --bare), $maindir), "git init (main)"); my $git = PublicInbox::Git->new($maindir); my $im = PublicInbox::Import->new($git, 'test', $addr); +$im->init_bare; { my $mime = Email::MIME->new(<<EOF); From: Me <me\@example.com> diff --git a/t/psgi_text.t b/t/psgi_text.t index 6d8a518d..77fc9ee2 100644 --- a/t/psgi_text.t +++ b/t/psgi_text.t @@ -21,7 +21,7 @@ my $config = PublicInbox::Config->new(\<<EOF); $cfgpfx.address=$addr $cfgpfx.inboxdir=$maindir EOF -is(0, system(qw(git init -q --bare), $maindir), "git init (main)"); +PublicInbox::Import::init_bare($maindir); my $www = PublicInbox::WWW->new($config); test_psgi(sub { $www->call(@_) }, sub { diff --git a/t/search-thr-index.t b/t/search-thr-index.t index f073304a..6c564b19 100644 --- a/t/search-thr-index.t +++ b/t/search-thr-index.t @@ -11,10 +11,11 @@ require_mods(qw(DBD::SQLite Search::Xapian)); require PublicInbox::SearchIdx; require PublicInbox::Smsg; require PublicInbox::Inbox; +use PublicInbox::Import; my ($tmpdir, $for_destroy) = tmpdir(); my $git_dir = "$tmpdir/a.git"; -is(0, system(qw(git init -q --bare), $git_dir), "git init (main)"); +PublicInbox::Import::init_bare($git_dir); my $ibx = PublicInbox::Inbox->new({inboxdir => $git_dir}); my $rw = PublicInbox::SearchIdx->new($ibx, 1); ok($rw, "search indexer created"); diff --git a/t/solver_git.t b/t/solver_git.t index 7f0cd999..b5231d2c 100644 --- a/t/solver_git.t +++ b/t/solver_git.t @@ -109,7 +109,8 @@ SKIP: { require_mods(@psgi, 7 + scalar(@psgi)); use_ok($_) for @psgi; my $binfoo = "$inboxdir/binfoo.git"; - system(qw(git init --bare -q), $binfoo) == 0 or die "git init: $?"; + require PublicInbox::Import; + PublicInbox::Import::init_bare($binfoo); require_ok 'PublicInbox::ViewVCS'; my $big_size = do { no warnings 'once'; diff --git a/t/v1-add-remove-add.t b/t/v1-add-remove-add.t index 736e414e..fdf06a96 100644 --- a/t/v1-add-remove-add.t +++ b/t/v1-add-remove-add.t @@ -9,7 +9,6 @@ use PublicInbox::TestCommon; require_mods(qw(DBD::SQLite Search::Xapian)); require PublicInbox::SearchIdx; my ($inboxdir, $for_destroy) = tmpdir(); -is(system(qw(git init --bare -q), $inboxdir), 0); my $ibx = { inboxdir => $inboxdir, name => 'test-add-remove-add', @@ -27,6 +26,7 @@ my $mime = PublicInbox::MIME->create( body => "hello world\n", ); my $im = PublicInbox::Import->new($ibx->git, undef, undef, $ibx); +$im->init_bare; ok($im->add($mime), 'message added'); ok($im->remove($mime), 'message removed'); ok($im->add($mime), 'message added again'); diff --git a/t/v1reindex.t b/t/v1reindex.t index 240e28f9..378c8efb 100644 --- a/t/v1reindex.t +++ b/t/v1reindex.t @@ -12,7 +12,6 @@ require_mods(qw(DBD::SQLite Search::Xapian)); use_ok 'PublicInbox::SearchIdx'; use_ok 'PublicInbox::Import'; my ($inboxdir, $for_destroy) = tmpdir(); -is(system(qw(git init -q --bare), $inboxdir), 0); my $ibx_config = { inboxdir => $inboxdir, name => 'test-v1reindex', @@ -35,6 +34,7 @@ my ($mark1, $mark2, $mark3, $mark4); my %config = %$ibx_config; my $ibx = PublicInbox::Inbox->new(\%config); my $im = PublicInbox::Import->new($ibx->git, undef, undef, $ibx); + $im->init_bare; foreach my $i (1..10) { $mime->header_set('Message-Id', "<$i\@example.com>"); ok($im->add($mime), "message $i added"); diff --git a/t/watch_maildir.t b/t/watch_maildir.t index 5fb908fb..9ed04cab 100644 --- a/t/watch_maildir.t +++ b/t/watch_maildir.t @@ -6,6 +6,7 @@ use Email::MIME; use Cwd; use PublicInbox::Config; use PublicInbox::TestCommon; +use PublicInbox::Import; require_mods(qw(Filesys::Notify::Simple)); my ($tmpdir, $for_destroy) = tmpdir(); my $git_dir = "$tmpdir/test.git"; @@ -15,7 +16,7 @@ use_ok 'PublicInbox::WatchMaildir'; use_ok 'PublicInbox::Emergency'; my $cfgpfx = "publicinbox.test"; my $addr = 'test-public@example.com'; -is(system(qw(git init -q --bare), $git_dir), 0, 'initialized git dir'); +PublicInbox::Import::init_bare($git_dir); my $msg = <<EOF; From: user\@example.com diff --git a/t/watch_maildir_v2.t b/t/watch_maildir_v2.t index 685cd6ed..dd5030ea 100644 --- a/t/watch_maildir_v2.t +++ b/t/watch_maildir_v2.t @@ -6,6 +6,7 @@ use PublicInbox::MIME; use Cwd; use PublicInbox::Config; use PublicInbox::TestCommon; +use PublicInbox::Import; require_git(2.6); require_mods(qw(Search::Xapian DBD::SQLite Filesys::Notify::Simple)); require PublicInbox::V2Writable; @@ -141,7 +142,7 @@ More majordomo info at http://vger.kernel.org/majordomo-info.html\n); my $v1repo = "$tmpdir/v1"; my $v1pfx = "publicinbox.v1"; my $v1addr = 'v1-public@example.com'; - is(system(qw(git init -q --bare), $v1repo), 0, 'v1 init OK'); + PublicInbox::Import::init_bare($v1repo); my $cfg2 = <<EOF; $orig$v1pfx.address=$v1addr $v1pfx.inboxdir=$v1repo diff --git a/t/www_listing.t b/t/www_listing.t index 9230329c..c132edbc 100644 --- a/t/www_listing.t +++ b/t/www_listing.t @@ -6,6 +6,7 @@ use warnings; use Test::More; use PublicInbox::Spawn qw(which); use PublicInbox::TestCommon; +use PublicInbox::Import; require_mods(qw(URI::Escape Plack::Builder Digest::SHA IO::Compress::Gzip IO::Uncompress::Gunzip HTTP::Tiny)); require PublicInbox::WwwListing; @@ -18,7 +19,7 @@ use_ok 'PublicInbox::Git'; my ($tmpdir, $for_destroy) = tmpdir(); my $bare = PublicInbox::Git->new("$tmpdir/bare.git"); -is(system(qw(git init -q --bare), $bare->{git_dir}), 0, 'git init --bare'); +PublicInbox::Import::init_bare($bare->{git_dir}); is(PublicInbox::WwwListing::fingerprint($bare), undef, 'empty repo has no fingerprint'); { @@ -77,7 +78,7 @@ SKIP: { my @clone = qw(git clone -q -s --bare); is(system(@clone, $bare->{git_dir}, $alt), 0, 'clone shared repo'); - system(qw(git init --bare -q), "$v2/all.git") == 0 or die; + PublicInbox::Import::init_bare("$v2/all.git"); for my $i (0..2) { is(system(@clone, $alt, "$v2/git/$i.git"), 0, "clone epoch $i"); } |