From: Bastian Dehn Date: Fri, 25 Sep 2026 16:34:46 +0000 (+0200) Subject: add check programs for vorbis library X-Git-Tag: v1.0.0^2~7^2~6 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=36bb12a05184d5559b33e3ed5ea4ddb96cad2370;p=albentohandy.git add check programs for vorbis library --- diff --git a/src/lib/vorbis.sh b/src/lib/vorbis.sh index e69de29..f25fc56 100644 --- a/src/lib/vorbis.sh +++ b/src/lib/vorbis.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +vorbis_errlog() +{ + local lastexit=$? + local msg="$1" + + echo "❌ ERROR: $msg" + return $lastexit +} + +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 $? + command -v vorbiscomment > /dev/null \ + || vorbis_errlog "command vorbiscomment not found" \ + || return $? + command -v parallel > /dev/null \ + || vorbis_errlog "command parallel not found" \ + || return $? +} + +vorbis_check_programs || return $? \ No newline at end of file diff --git a/tests/vorbis.bats b/tests/vorbis.bats new file mode 100755 index 0000000..4dc23d1 --- /dev/null +++ b/tests/vorbis.bats @@ -0,0 +1,67 @@ +#!/usr/bin/bats + +setup() { + bats_load_library 'bats-support' + bats_load_library 'bats-assert' + source "src/lib/vorbis.sh" +} + +# 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" != "oggenc" ] || return 1 + } + + run vorbis_check_programs + + assert_failure + assert_line --index 0 "❌ ERROR: command oggenc not found" +} + +# bats test_tags=vorbis:check_programs +@test "failed: check programs missing vorbiscomment" { + command() { + [ "$2" != "vorbiscomment" ] || return 1 + } + + run vorbis_check_programs + + assert_failure + assert_line --index 0 "❌ ERROR: command vorbiscomment not found" +} + +# bats test_tags=vorbis:check_programs +@test "failed: check programs missing parallel" { + command() { + [ "$2" != "parallel" ] || return 1 + } + + run vorbis_check_programs + + assert_failure + assert_line --index 0 "❌ ERROR: command parallel not found" +} \ No newline at end of file