]> gitweb.hhaalo.de Git - albentohandy.git/commitdiff
change load lib and encode with prefix
authorBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 16:18:28 +0000 (18:18 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 16:18:28 +0000 (18:18 +0200)
src/albentohandy
tests/albentohandy.bats

index 69f817161a8c7d8b4ee60eaafb512a2c5dd20b29..789f8966370071c56ab73ca2d1dc0ebd707560f0 100755 (executable)
@@ -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 \
index 4e34abf6bb9bc69837a7991452369791be754593..3eb6d4d624b5919484473ad68a0992d40183e65e 100755 (executable)
@@ -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
        }