command line: fixed '--dry-run' error message

Running a sync in "dry run" mode is not supported. The error
message about that was reported like an internal error.

Also added tests covering such output.
This commit is contained in:
Patrick Ohly 2012-06-05 13:20:38 +02:00
parent eafc81c08d
commit 4c8cf8fa9f
2 changed files with 36 additions and 1 deletions

View File

@ -1605,7 +1605,8 @@ bool Cmdline::run() {
SyncContext::DATABASE_BEFORE_SYNC);
} else {
if (m_dryrun) {
SyncContext::throwError("--dry-run not supported for running a synchronization");
usage(false, "--dry-run not supported for running a synchronization");
return false;
}
// safety catch: if props are given, then --run

View File

@ -6596,6 +6596,40 @@ END:VCARD
re.MULTILINE)
return p.sub('| start xxx, duration a:bcmin |', out)
@property("debug", False)
@timeout(200)
def testSyncOutputErrors(self):
"""TestCmdline.testSyncOutputErrors - check error messages for sync operations"""
self.setUpLocalSyncConfigs()
self.session.Detach()
# error message for --dry-run
out, err, code = self.runCmdline(["--dry-run", "server"],
expectSuccess=False)
self.expectUsageError(out, err, '[ERROR] --dry-run not supported for running a synchronization\n')
# ambiguous command line
out, err, code = self.runCmdline(["sync=two-way", "server"],
expectSuccess=False)
self.expectUsageError(out, err, "[ERROR] Properties specified, but neither '--configure' nor '--run' - what did you want?\n")
# ambiguous command line, empty source property
out, err, code = self.runCmdline(["database=", "server"],
expectSuccess=False)
self.expectUsageError(out, err, "[ERROR] Properties specified, but neither '--configure' nor '--run' - what did you want?\n")
# ambiguous command line, empty sync property
out, err, code = self.runCmdline(["logdir=", "server"],
expectSuccess=False)
self.expectUsageError(out, err, "[ERROR] Properties specified, but neither '--configure' nor '--run' - what did you want?\n")
# empty global property allowed
out, err, code = self.runCmdline(["keyring=", "server"],
sessionFlags=[],
expectSuccess=True)
@property("debug", False)
@timeout(200)
def testSyncOutput(self):