From 799dc602a69109326b61075fc9e835bf8ce456ee Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Fri, 25 Sep 2026 18:18:28 +0200 Subject: [PATCH] change load lib and encode with prefix --- src/albentohandy | 20 +++++++++++++------- tests/albentohandy.bats | 13 +++++++++++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/albentohandy b/src/albentohandy index 69f8171..789f896 100755 --- a/src/albentohandy +++ b/src/albentohandy @@ -55,6 +55,17 @@ load_config() OUTPUT_PATH=${OUTPUT_PATH:-"work.$$"} } +load_library() +{ + local lib="$1" + [ -f "$LIB_PATH/$lib" ] \ + || errlog "lib $LIB_PATH/$lib not found" \ + || return $? + source "$LIB_PATH/$lib" \ + || errlog "could not load library $LIB_PATH/$lib" \ + || return $? +} + make_symlinks_to_work() { local albumlist="$1" @@ -125,12 +136,7 @@ main() esac done - [ -f "$LIB_PATH/$lib" ] \ - || errlog "lib $LIB_PATH/$lib not found" \ - || return $? - source "$LIB_PATH/$lib" \ - || errlog "could not load library $LIB_PATH/$lib" \ - || return $? + load_library "$lib" || return $? [ -f "$albumlist" ] \ || errlog "file $albumlist does not exists" \ @@ -138,7 +144,7 @@ main() mkdir --parents "$OUTPUT_PATH" || return $? make_symlinks_to_work "$albumlist" || return $? - encode "$OUTPUT_PATH" \ + "${lib/.sh/}_encode" "$OUTPUT_PATH" \ || errlog "could not encode $OUTPUT_PATH" \ || return $? cleanup_cover \ diff --git a/tests/albentohandy.bats b/tests/albentohandy.bats index 4e34abf..3eb6d4d 100755 --- a/tests/albentohandy.bats +++ b/tests/albentohandy.bats @@ -24,6 +24,12 @@ setup() { printf "%s\n" "$@" } > "$ENCODE_LOG" } + vorbis_encode() { + encode "$@" + } + flac_encode() { + encode "$@" + } } teardown() { @@ -305,6 +311,10 @@ teardown() { # bats test_tags=albentohandy:cleanup @test "success: not cleanup flac with flac lib" { + load_library() { + : + } + run main -i "build/tests/albumlist" -f assert_success @@ -313,6 +323,9 @@ teardown() { # bats test_tags=albentohandy:cleanup @test "failed: could not cleanup flac" { + load_library() { + : + } cleanup_flac() { return 1 } -- 2.47.3