Merge remote-tracking branch 'origin/feat/quiet' into dev
# Conflicts: # src/client/client_send.c
This commit is contained in:
@@ -35,6 +35,39 @@ class TestDryRun:
|
||||
assert result.returncode == 0, f"Exit {result.returncode}: {result.stderr[:100]}"
|
||||
assert "Dry run:" in result.stdout, f"No dry run output: {result.stdout[:200]}"
|
||||
|
||||
def test_quiet_suppresses_dry_run_output(self):
|
||||
result, dur = run_client(
|
||||
SOURCE_DIR, DEST_DIR,
|
||||
flags=["-q", "-n", "--progress", "--stats"],
|
||||
)
|
||||
assert result.returncode == 0, f"Exit {result.returncode}: {result.stderr[:100]}"
|
||||
assert result.stdout == ""
|
||||
assert result.stderr == ""
|
||||
|
||||
def test_quiet_preserves_errors(self):
|
||||
result, dur = run_client(
|
||||
SOURCE_DIR, DEST_DIR,
|
||||
flags=["--quiet", "--server-port", "1"],
|
||||
)
|
||||
assert result.returncode != 0
|
||||
assert result.stderr != ""
|
||||
|
||||
@pytest.mark.parametrize("flags", [["-q", "-v"], ["-v", "-q"]])
|
||||
def test_quiet_successful_transfer_and_verbose_order(self, shared_server, flags):
|
||||
clean_dir(DEST_DIR)
|
||||
result, dur = run_client(
|
||||
SOURCE_DIR, DEST_DIR,
|
||||
flags=flags,
|
||||
port=shared_server.port,
|
||||
)
|
||||
assert result.returncode == 0, f"Exit {result.returncode}: {result.stderr[:100]}"
|
||||
assert result.stdout == ""
|
||||
assert result.stderr == ""
|
||||
received = get_dest_received_dir(DEST_DIR, SOURCE_DIR)
|
||||
mismatches, missing = verify_transfer(SOURCE_DIR, received)
|
||||
assert not missing, f"Missing: {missing}"
|
||||
assert not mismatches, f"Mismatch: {mismatches}"
|
||||
|
||||
|
||||
class TestRemoveSourceFiles:
|
||||
def test_removes_only_transferred_regular_files(self, shared_server):
|
||||
|
||||
+18
-3
@@ -283,9 +283,7 @@ static void test_parse_args_unknown_option() {
|
||||
|
||||
/* Parsed-but-unimplemented options must fail instead of being silently accepted. */
|
||||
static void test_parse_args_rejects_unimplemented_options() {
|
||||
static const char* const options[] = {"-q",
|
||||
"--quiet",
|
||||
"--silent",
|
||||
static const char* const options[] = {"--silent",
|
||||
"--queue-size",
|
||||
"-H",
|
||||
"--hard-links",
|
||||
@@ -344,6 +342,22 @@ static void test_parse_args_rejects_unimplemented_options() {
|
||||
}
|
||||
}
|
||||
|
||||
/* Test both rsync-compatible quiet spellings and option ordering. */
|
||||
static void test_parse_args_quiet() {
|
||||
static const char* const options[][2] = {
|
||||
{"-q", "-v"}, {"-v", "-q"}, {"--quiet", "-v"}, {"-v", "--quiet"}};
|
||||
for (size_t i = 0; i < sizeof(options) / sizeof(options[0]); i++) {
|
||||
Config* cfg = config_create();
|
||||
char* argv[] = {"fastsync", (char*)options[i][0], (char*)options[i][1], "/src", "/dst"};
|
||||
int positional_args[2];
|
||||
int positional_count = 0;
|
||||
|
||||
EXPECT_EQ_INT(parse_args(cfg, 5, argv, positional_args, &positional_count), 0);
|
||||
EXPECT_TRUE(cfg->quiet);
|
||||
config_delete(cfg);
|
||||
}
|
||||
}
|
||||
|
||||
/* Test parse_args with --archive flag */
|
||||
static void test_parse_args_archive() {
|
||||
Config* cfg = config_create();
|
||||
@@ -393,6 +407,7 @@ void test_client_cli() {
|
||||
test_parse_args_valid_compression_level();
|
||||
test_parse_args_unknown_option();
|
||||
test_parse_args_rejects_unimplemented_options();
|
||||
test_parse_args_quiet();
|
||||
test_parse_args_archive();
|
||||
test_parse_args_fsync();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user