summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-14 15:17:32 +0300
committerPaul Buetow <paul@buetow.org>2026-06-14 15:17:32 +0300
commit67231312ba2d80592e305b08bbf03f7aece2e4a3 (patch)
tree960a4cf09d741215b3d4c6a2fefbc8c52d09b0ac /tests
parentaabe2efbb79938dbbdb4f0ab496cdc22e7280736 (diff)
lm0 de-duplicate imagemagick detection and config-array parsing
Introduce a shared resolve_config_array helper in bootstrap.source.sh that parses a config variable declared as either a Bash array or a whitespace-separated scalar into a named output array. resolve_tar_opts and resolve_sync_destinations now both delegate to it, with resolve_tar_opts keeping its "-c" default for the empty/unset case. validate_imagemagick now reuses resolve_imagemagick_command instead of duplicating the magick/convert probing, reporting failures through config_error so the validation output is unchanged. Add a print-config test covering the empty TAR_OPTS (scalar and array) fallback to the default. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/cli.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/cli.sh b/tests/cli.sh
index d6fbbd4..b8b56f6 100755
--- a/tests/cli.sh
+++ b/tests/cli.sh
@@ -1677,6 +1677,34 @@ test_print_config_normalizes_scalar_and_array_tar_opts() {
test::teardown
}
+test_print_config_empty_tar_opts_falls_back_to_default() {
+ local config_file
+ local empty_array_output
+ local empty_scalar_output
+
+ test::setup
+ config_file="$TEST_TMPDIR/shuriken.conf"
+ test::write_album_config \
+ "$config_file" "$TEST_TMPDIR/incoming" "$TEST_TMPDIR/dist" \
+ 'Empty tar opts' 40
+
+ # An empty scalar TAR_OPTS must fall back to the default "-c" just like an
+ # unset value; the shared resolve_config_array helper yields an empty array
+ # and resolve_tar_opts supplies the default.
+ printf 'TAR_OPTS=%q\n' '' >> "$config_file"
+ empty_scalar_output=$("$TEST_SHURIKEN" --print-config --config "$config_file")
+ test::assert_contains 'TAR_OPTS=( -c )' "$empty_scalar_output"
+
+ # An empty array declaration must behave identically.
+ test::write_album_config \
+ "$config_file" "$TEST_TMPDIR/incoming" "$TEST_TMPDIR/dist" \
+ 'Empty array tar opts' 40
+ printf 'TAR_OPTS=()\n' >> "$config_file"
+ empty_array_output=$("$TEST_SHURIKEN" --print-config --config "$config_file")
+ test::assert_contains 'TAR_OPTS=( -c )' "$empty_array_output"
+ test::teardown
+}
+
test_print_config_quiet_and_verbose_keep_machine_output() {
local config_file
local plain_output
@@ -4856,6 +4884,9 @@ main() {
'--print-config normalizes scalar and array TAR_OPTS' \
test_print_config_normalizes_scalar_and_array_tar_opts
test::run_case \
+ '--print-config empty TAR_OPTS falls back to default' \
+ test_print_config_empty_tar_opts_falls_back_to_default
+ test::run_case \
'--print-config quiet and verbose keep machine output' \
test_print_config_quiet_and_verbose_keep_machine_output
test::run_case \