From 2df67377e165c731f03d7cd21eea9f80fa14301e Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Wed, 30 Sep 2026 16:15:23 +0200 Subject: [PATCH] change builder smaller --- builder/Containerfile.template | 6 ------ src/lib/flac.sh | 23 +---------------------- src/lib/mp3.sh | 4 +--- src/lib/opus.sh | 1 + src/lib/vorbis.sh | 7 +------ tests/flac.bats | 21 +-------------------- tests/mp3.bats | 13 +------------ tests/opus.bats | 1 + tests/vorbis.bats | 25 +------------------------ 9 files changed, 8 insertions(+), 93 deletions(-) diff --git a/builder/Containerfile.template b/builder/Containerfile.template index 77d28fe..c4706da 100644 --- a/builder/Containerfile.template +++ b/builder/Containerfile.template @@ -18,12 +18,6 @@ RUN apt-get update \ bats-support \ bats-assert \ shellcheck \ - flac \ - lame \ - eyed3 \ - opus-tools \ - vorbis-tools \ - parallel \ && apt-get clean \ && rm --recursive --force /var/lib/apt/lists/* COPY run /app/run diff --git a/src/lib/flac.sh b/src/lib/flac.sh index 3acf7c6..7a07b1f 100644 --- a/src/lib/flac.sh +++ b/src/lib/flac.sh @@ -1,14 +1,5 @@ #!/bin/bash -flac_errlog() -{ - local lastexit=$? - local msg="$1" - - echo "❌ ERROR: $msg" - return $lastexit -} - flac_add_picture() { local work_path="$1" @@ -29,20 +20,8 @@ flac_add_picture() done } -flac_check_programs() -{ - command -v metaflac > /dev/null \ - || flac_errlog "command metaflac not found" \ - || return $? -} - flac_encode() { local work_path="$1" - [ -n "$work_path" ] \ - || flac_errlog "missing work path" \ - || return $? flac_add_picture "$work_path" -} - -flac_check_programs || return $? \ No newline at end of file +} \ No newline at end of file diff --git a/src/lib/mp3.sh b/src/lib/mp3.sh index 4174645..979d8fe 100644 --- a/src/lib/mp3.sh +++ b/src/lib/mp3.sh @@ -11,9 +11,6 @@ mp3_errlog() mp3_check_programs() { - command -v flac > /dev/null \ - || mp3_errlog "command flac not found" \ - || return $? command -v lame > /dev/null \ || mp3_errlog "command lame not found" \ || return $? @@ -125,6 +122,7 @@ mp3_encode() mp3_encode_flac "{}" } +[ "$TEST_MODE" == "ON" ] && return 0 mp3_check_programs || return $? export -f mp3_encode_flac export -f mp3_flacmetadata_to_mp3_tag \ No newline at end of file diff --git a/src/lib/opus.sh b/src/lib/opus.sh index 5dc52f6..48b2e08 100644 --- a/src/lib/opus.sh +++ b/src/lib/opus.sh @@ -50,5 +50,6 @@ opus_encode() opus_encode_flac "{}" } +[ "$TEST_MODE" == "ON" ] && return 0 opus_check_programs || return $? export -f opus_encode_flac \ No newline at end of file diff --git a/src/lib/vorbis.sh b/src/lib/vorbis.sh index 612fbd0..3364637 100644 --- a/src/lib/vorbis.sh +++ b/src/lib/vorbis.sh @@ -11,12 +11,6 @@ vorbis_errlog() vorbis_check_programs() { - command -v flac > /dev/null \ - || vorbis_errlog "command flac not found" \ - || return $? - command -v metaflac > /dev/null \ - || vorbis_errlog "command metaflac not found" \ - || return $? command -v oggenc > /dev/null \ || vorbis_errlog "command oggenc not found" \ || return $? @@ -122,6 +116,7 @@ vorbis_encode() vorbis_encode_flac "{}" } +[ "$TEST_MODE" == "ON" ] && return 0 vorbis_check_programs || return $? export -f vorbis_write_number_to_byte export -f vorbis_cover_to_metadata diff --git a/tests/flac.bats b/tests/flac.bats index af592f5..d3ee989 100755 --- a/tests/flac.bats +++ b/tests/flac.bats @@ -4,6 +4,7 @@ setup() { bats_load_library 'bats-support' bats_load_library 'bats-assert' export METAFLAC_LOG="build/metaflac.log" + export TEST_MODE="ON" source "src/lib/flac.sh" } @@ -20,26 +21,6 @@ teardown_file() { rm --recursive --force "build/tests" } -# bats test_tags=flac:check_programs -@test "failed: check programs missing metaflac" { - command() { - [ "$2" != "metaflac" ] || return 1 - } - - run flac_check_programs - - assert_failure - assert_line --index 0 "❌ ERROR: command metaflac not found" -} - -# bats test_tags=flac:params -@test "failed: mising work path" { - run flac_encode - - assert_failure - assert_line --index 0 "❌ ERROR: missing work path" -} - # bats test_tags=flac:addpicture @test "success: add picture to flac" { echo "testfile" > "build/tests/output/file.flac" diff --git a/tests/mp3.bats b/tests/mp3.bats index e5ab777..e9dca9a 100755 --- a/tests/mp3.bats +++ b/tests/mp3.bats @@ -3,21 +3,10 @@ setup() { bats_load_library 'bats-support' bats_load_library 'bats-assert' + export TEST_MODE="ON" source "src/lib/mp3.sh" } -# bats test_tags=mp3:check_programs -@test "failed: check programs missing flac" { - command() { - [ "$2" != "flac" ] || return 1 - } - - run mp3_check_programs - - assert_failure - assert_line --index 0 "❌ ERROR: command flac not found" -} - # bats test_tags=mp3:check_programs @test "failed: check programs missing lame" { command() { diff --git a/tests/opus.bats b/tests/opus.bats index 28439fe..bd187df 100755 --- a/tests/opus.bats +++ b/tests/opus.bats @@ -3,6 +3,7 @@ setup() { bats_load_library 'bats-support' bats_load_library 'bats-assert' + export TEST_MODE="ON" source "src/lib/opus.sh" } diff --git a/tests/vorbis.bats b/tests/vorbis.bats index eadff22..a0d429f 100755 --- a/tests/vorbis.bats +++ b/tests/vorbis.bats @@ -3,6 +3,7 @@ setup() { bats_load_library 'bats-support' bats_load_library 'bats-assert' + export TEST_MODE="ON" source "src/lib/vorbis.sh" } @@ -14,30 +15,6 @@ teardown_file() { rm --recursive --force "build/tests" } -# bats test_tags=vorbis:check_programs -@test "failed: check programs missing flac" { - command() { - [ "$2" != "flac" ] || return 1 - } - - run vorbis_check_programs - - assert_failure - assert_line --index 0 "❌ ERROR: command flac not found" -} - -# bats test_tags=vorbis:check_programs -@test "failed: check programs missing metaflac" { - command() { - [ "$2" != "metaflac" ] || return 1 - } - - run vorbis_check_programs - - assert_failure - assert_line --index 0 "❌ ERROR: command metaflac not found" -} - # bats test_tags=vorbis:check_programs @test "failed: check programs missing oggenc" { command() { -- 2.47.3