* [PATCH 05/10] lei_mirror: don't show success on failure
2021-03-25 4:20 6% [PATCH 00/10] lei testing improvements Eric Wong
@ 2021-03-25 4:20 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-03-25 4:20 UTC (permalink / raw)
To: meta
While we were exiting with a error code, showing a successful
"# mirrored $URL" message is misleading and wrong. Don't show
success until everything is complete and the config is written.
---
lib/PublicInbox/LeiMirror.pm | 11 ++++++++---
t/lei-mirror.t | 18 ++++++++++++++++++
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm
index d68cd6c1..c83386c6 100644
--- a/lib/PublicInbox/LeiMirror.pm
+++ b/lib/PublicInbox/LeiMirror.pm
@@ -12,8 +12,14 @@ use PublicInbox::Spawn qw(popen_rd spawn);
sub do_finish_mirror { # dwaitpid callback
my ($arg, $pid) = @_;
my ($mrr, $lei) = @$arg;
- if ($? == 0 && unlink("$mrr->{dst}/mirror.done")) {
+ my $f = "$mrr->{dst}/mirror.done";
+ if ($?) {
+ $lei->child_error($?);
+ } elsif (!unlink($f)) {
+ $lei->err("unlink($f): $!");
+ } else {
$lei->add_external_finish($mrr->{dst});
+ $lei->qerr("# mirrored $mrr->{src} => $mrr->{dst}");
}
$lei->dclose;
}
@@ -262,8 +268,7 @@ sub do_mirror { # via wq_io_do
return start_clone_url($self) if $self->{src} =~ m!://!;
die "TODO: cloning local directories not supported, yet";
};
- return $lei->fail($@) if $@;
- $lei->qerr("# mirrored $self->{src} => $self->{dst}");
+ $lei->fail($@) if $@;
}
sub start {
diff --git a/t/lei-mirror.t b/t/lei-mirror.t
index 9769f31b..6039e568 100644
--- a/t/lei-mirror.t
+++ b/t/lei-mirror.t
@@ -41,6 +41,24 @@ test_lei({ tmpdir => $tmpdir }, sub {
ok(!-d "$t2-fail", 'destination not created on failure');
lei_ok('ls-external');
unlike($lei_out, qr!\Q$t2-fail\E!, 'not added to ls-external');
+
+ my %phail = (
+ HTTPS => 'https://public-inbox.org/' . 'phail',
+ ONION => 'http://ou63pmih66umazou.onion/' . 'phail,'
+ );
+ for my $t (qw(HTTPS ONION)) {
+ SKIP: {
+ my $k = "TEST_LEI_EXTERNAL_$t";
+ $ENV{$k} or skip "$k unset", 1;
+ my $url = $phail{$t};
+ my $dir = "phail-$t";
+ ok(!lei(qw(add-external -Lmedium --mirror),
+ $url, $dir), '--mirror non-existent v2');
+ is($? >> 8, 22, 'curl 404');
+ ok(!-d $dir, 'directory not created');
+ unlike($lei_err, qr/# mirrored/, 'no success message');
+ } # SKIP
+ } # for
});
ok($td->kill, 'killed -httpd');
^ permalink raw reply related [relevance 7%]
* [PATCH 00/10] lei testing improvements
@ 2021-03-25 4:20 6% Eric Wong
2021-03-25 4:20 7% ` [PATCH 05/10] lei_mirror: don't show success on failure Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-03-25 4:20 UTC (permalink / raw)
To: meta
[7/10] is the centerpiece and gives a ~10% speedup for tests,
which are still slow to me. Speedup or not, it's uncovered a
bunch of subtle bugs over the past few days so I'm glad I
worked on it.
There's still some rare errors that come from looping
"make check-run TEST_LEI_ERR_LOUD" which I'm still trying
to figure out...
Eric Wong (10):
test_common: cleanup inbox objects after use
lei: janky $PATH2CFG garbage collection
test_common: TEST_LEI_ERR_LOUD does not hide path names
lei add-external: do not initialize writable store
lei_mirror: don't show success on failure
t/*: drop unnecessary v1-specific index calls
tests: "check-run" uses persistent lei daemon
lei import: force store, improve test diagnostics
t/cmd_ipc: workaround signal handling raciness
t/lei: add more diagnostics for failures
lib/PublicInbox/LEI.pm | 6 +++++
lib/PublicInbox/LeiExternal.pm | 2 --
lib/PublicInbox/LeiImport.pm | 6 ++---
lib/PublicInbox/LeiMirror.pm | 11 ++++++---
lib/PublicInbox/TestCommon.pm | 41 +++++++++++++++++++++++-----------
t/cmd_ipc.t | 28 ++++++++++++++++-------
t/inbox_idle.t | 2 --
t/lei-externals.t | 7 ++++--
t/lei-import-maildir.t | 13 +++++++----
t/lei-mark.t | 2 +-
t/lei-mirror.t | 18 +++++++++++++++
t/lei-q-kw.t | 6 ++---
t/lei-q-thread.t | 15 +++++++------
t/nntpd.t | 4 ----
t/run.perl | 19 ++++++++++++++++
t/v2mda.t | 4 ----
t/watch_filter_rubylang.t | 7 ++----
17 files changed, 130 insertions(+), 61 deletions(-)
^ permalink raw reply [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-03-25 4:20 6% [PATCH 00/10] lei testing improvements Eric Wong
2021-03-25 4:20 7% ` [PATCH 05/10] lei_mirror: don't show success on failure Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
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).