]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/lei-mirror.t
t/cmd_ipc: allow extra errors and add diagnostics
[public-inbox.git] / t / lei-mirror.t
index 44acbe95bac6711c8658791b3022d5eae7771d91..de5246b60bce27c707c2a6e833bfe2655f79771f 100644 (file)
@@ -19,6 +19,7 @@ test_lei({ tmpdir => $tmpdir }, sub {
        ok(-f "$t1/public-inbox/msgmap.sqlite3", 't1-mirror indexed');
        is(PublicInbox::Inbox::try_cat("$t1/description"),
                "mirror of $http/t1/\n", 'description set');
+       ok(-f "$t1/Makefile", 'convenience Makefile added (v1)');
 
        lei_ok('ls-external');
        like($lei_out, qr!\Q$t1\E!, 't1 added to ls-externals');
@@ -27,6 +28,7 @@ test_lei({ tmpdir => $tmpdir }, sub {
        lei_ok('add-external', $t2, '--mirror', "$http/t2/", \'--mirror v2');
        ok(-f "$t2/msgmap.sqlite3", 't2-mirror indexed');
        ok(-f "$t2/description", 't2 description');
+       ok(-f "$t2/Makefile", 'convenience Makefile added (v2)');
        is(PublicInbox::Inbox::try_cat("$t2/description"),
                "mirror of $http/t2/\n", 'description set');
 
@@ -63,6 +65,14 @@ test_lei({ tmpdir => $tmpdir }, sub {
        lei_ok('ls-external');
        unlike($lei_out, qr!\Q$d\E!s, 'not added to ls-external');
 
+       $d = "$home/bad-epoch";
+       ok(!lei(qw(add-external -q --epoch=0.. --mirror), "$http/t1/", $d),
+               'v1 fails on --epoch');
+       ok(!-d $d, 'destination not created on unacceptable --epoch');
+       ok(!lei(qw(add-external -q --epoch=1 --mirror), "$http/t2/", $d),
+               'v2 fails on bad epoch range');
+       ok(!-d $d, 'destination not created on bad epoch');
+
        my %phail = (
                HTTPS => 'https://public-inbox.org/' . 'phail',
                ONION =>
@@ -95,31 +105,48 @@ SKIP: {
 
        ok(run_script([qw(-clone -q -C), $d, "$http/t2"], undef, $opt),
                '-clone succeeds on v2');
-       ok(-d "$d/t2/git/0.git", 'epoch cloned');
+       ok(-f "$d/t2/git/0.git/config", 'epoch cloned');
+
+       # writeBitmaps is the default for bare repos in git 2.22+,
+       # so we may stop setting it ourselves.
+       0 and is(xqx(['git', "--git-dir=$d/t2/git/0.git", 'config',
+               qw(--bool repack.writeBitmaps)]), "true\n",
+               'write bitmaps set (via include.path=all.git/config');
+
+       is(xqx(['git', "--git-dir=$d/t2/git/0.git", 'config',
+               qw(include.path)]), "../../all.git/config\n",
+               'include.path set');
+
+       ok(-s "$d/t2/all.git/objects/info/alternates",
+               'all.git alternates created');
        ok(-f "$d/t2/manifest.js.gz", 'manifest saved');
        ok(!-e "$d/t2/mirror.done", 'no leftover mirror.done');
-       ok(run_script([qw(-fetch -C), "$d/t2"], undef, $opt),
+       ok(!run_script([qw(-fetch --exit-code -C), "$d/t2"], undef, $opt),
                '-fetch succeeds w/ manifest.js.gz');
-       unlike($err, qr/git fetch/, 'no fetch done w/ manifest');
+       is($? >> 8, 127, '--exit-code gave 127');
+       unlike($err, qr/git --git-dir=\S+ fetch/, 'no fetch done w/ manifest');
        unlink("$d/t2/manifest.js.gz") or xbail "unlink $!";
-       ok(run_script([qw(-fetch -C), "$d/t2"], undef, $opt),
+       ok(!run_script([qw(-fetch --exit-code -C), "$d/t2"], undef, $opt),
                '-fetch succeeds w/o manifest.js.gz');
-       like($err, qr/git fetch/, 'fetch forced w/o manifest');
+       is($? >> 8, 127, '--exit-code gave 127');
+       like($err, qr/git --git-dir=\S+ fetch/, 'fetch forced w/o manifest');
 
        ok(run_script([qw(-clone -q -C), $d, "$http/t1"], undef, $opt),
                'cloning v1 works');
        ok(-d "$d/t1", 'v1 cloned');
        ok(!-e "$d/t1/mirror.done", 'no leftover file');
        ok(-f "$d/t1/manifest.js.gz", 'manifest saved');
-       ok(run_script([qw(-fetch -C), "$d/t1"], undef, $opt),
+       ok(!run_script([qw(-fetch --exit-code -C), "$d/t1"], undef, $opt),
                'fetching v1 works');
-       unlike($err, qr/git fetch/, 'no fetch done w/ manifest');
+       is($? >> 8, 127, '--exit-code gave 127');
+       unlike($err, qr/git --git-dir=\S+ fetch/, 'no fetch done w/ manifest');
        unlink("$d/t1/manifest.js.gz") or xbail "unlink $!";
        my $before = [ glob("$d/t1/*") ];
-       ok(run_script([qw(-fetch -C), "$d/t1"], undef, $opt),
+       ok(!run_script([qw(-fetch --exit-code -C), "$d/t1"], undef, $opt),
                'fetching v1 works w/o manifest.js.gz');
+       is($? >> 8, 127, '--exit-code gave 127');
        unlink("$d/t1/FETCH_HEAD"); # git internal
-       like($err, qr/git fetch/, 'no fetch done w/ manifest');
+       like($err, qr/git --git-dir=\S+ fetch/, 'no fetch done w/ manifest');
        ok(unlink("$d/t1/manifest.js.gz"), 'manifest created');
        my $after = [ glob("$d/t1/*") ];
        is_deeply($before, $after, 'no new files created');