consolidate testing options behind common switch

don't pollute the namespace with random uppercase switches. instead,
have a new -T switch with suboptions, just like -D.
This commit is contained in:
Oswald Buddenhagen 2020-12-16 13:49:27 +01:00
parent c3d91ae1e8
commit 30af61fb24
2 changed files with 19 additions and 10 deletions

View File

@ -710,13 +710,22 @@ main( int argc, char **argv )
op = DEBUG_ALL | VERBOSE; op = DEBUG_ALL | VERBOSE;
DFlags |= op; DFlags |= op;
break; break;
case 'J': case 'T':
for (; *ochar; ) {
switch (*ochar++) {
case 'j':
DFlags |= KEEPJOURNAL; DFlags |= KEEPJOURNAL;
JLimit = strtol( ochar, &ochar, 10 ); JLimit = strtol( ochar, &ochar, 10 );
break; break;
case 'Z': case 'z':
DFlags |= ZERODELAY; DFlags |= ZERODELAY;
break; break;
default:
error( "Unknown -T flag '%c'\n", *(ochar - 1) );
return 1;
}
}
break;
case 'v': case 'v':
version(); version();
case 'h': case 'h':

View File

@ -345,7 +345,7 @@ sub runsync($$)
} else { } else {
$flags .= " -D"; $flags .= " -D";
} }
$cmd .= "$mbsync -Z $flags -c .mbsyncrc test"; $cmd .= "$mbsync -Tz $flags -c .mbsyncrc test";
open FILE, "$cmd 2>&1 |"; open FILE, "$cmd 2>&1 |";
my @out = <FILE>; my @out = <FILE>;
close FILE or push(@out, $! ? "*** error closing mbsync: $!\n" : "*** mbsync exited with signal ".($?&127).", code ".($?>>8)."\n"); close FILE or push(@out, $! ? "*** error closing mbsync: $!\n" : "*** mbsync exited with signal ".($?&127).", code ".($?>>8)."\n");
@ -692,7 +692,7 @@ sub test($$$@)
mkchan($$sx[0], $$sx[1], @{ $$sx[2] }); mkchan($$sx[0], $$sx[1], @{ $$sx[2] });
my ($xc, @ret) = runsync("-J", "1-initial.log"); my ($xc, @ret) = runsync("-Tj", "1-initial.log");
if ($xc || ckchan("near/.mbsyncstate.new", $tx)) { if ($xc || ckchan("near/.mbsyncstate.new", $tx)) {
print "Input:\n"; print "Input:\n";
printchan($sx); printchan($sx);
@ -752,7 +752,7 @@ sub test($$$@)
for (my $l = 1; $l <= $njl; $l++) { for (my $l = 1; $l <= $njl; $l++) {
mkchan($$sx[0], $$sx[1], @{ $$sx[2] }); mkchan($$sx[0], $$sx[1], @{ $$sx[2] });
my ($nxc, @nret) = runsync("-J$l", "4-interrupt.log"); my ($nxc, @nret) = runsync("-Tj$l", "4-interrupt.log");
if ($nxc != (100 + ($l & 1)) << 8) { if ($nxc != (100 + ($l & 1)) << 8) {
print "Interrupting at step $l/$njl failed.\n"; print "Interrupting at step $l/$njl failed.\n";
print "Debug output:\n"; print "Debug output:\n";
@ -760,7 +760,7 @@ sub test($$$@)
exit 1; exit 1;
} }
($nxc, @nret) = runsync("-J", "5-resume.log"); ($nxc, @nret) = runsync("-Tj", "5-resume.log");
if ($nxc || ckchan("near/.mbsyncstate.new", $tx)) { if ($nxc || ckchan("near/.mbsyncstate.new", $tx)) {
print "Resuming from step $l/$njl failed.\n"; print "Resuming from step $l/$njl failed.\n";
print "Input:\n"; print "Input:\n";