From 9a09536cf325283ca5f9696497fafe5716e4516a Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Fri, 25 Sep 2026 19:56:42 +0200 Subject: [PATCH] add mp3 check programs --- src/lib/mp3.sh | 28 +++++++++++++++++++++++++ tests/mp3.bats | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 src/lib/mp3.sh create mode 100755 tests/mp3.bats diff --git a/src/lib/mp3.sh b/src/lib/mp3.sh new file mode 100644 index 0000000..b2e195e --- /dev/null +++ b/src/lib/mp3.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +vorbis_errlog() +{ + local lastexit=$? + local msg="$1" + + echo "❌ ERROR: $msg" + return $lastexit +} + +mp3_check_programs() +{ + command -v flac > /dev/null \ + || vorbis_errlog "command flac not found" \ + || return $? + command -v lame > /dev/null \ + || vorbis_errlog "command lame not found" \ + || return $? + command -v eyeD3 > /dev/null \ + || vorbis_errlog "command eyeD3 not found" \ + || return $? + command -v parallel > /dev/null \ + || vorbis_errlog "command parallel not found" \ + || return $? +} + +mp3_check_programs || return $? \ No newline at end of file diff --git a/tests/mp3.bats b/tests/mp3.bats new file mode 100755 index 0000000..e5ab777 --- /dev/null +++ b/tests/mp3.bats @@ -0,0 +1,55 @@ +#!/usr/bin/bats + +setup() { + bats_load_library 'bats-support' + bats_load_library 'bats-assert' + 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() { + [ "$2" != "lame" ] || return 1 + } + + run mp3_check_programs + + assert_failure + assert_line --index 0 "❌ ERROR: command lame not found" +} + +# bats test_tags=mp3:check_programs +@test "failed: check programs eyeD3 oggenc" { + command() { + [ "$2" != "eyeD3" ] || return 1 + } + + run mp3_check_programs + + assert_failure + assert_line --index 0 "❌ ERROR: command eyeD3 not found" +} + +# bats test_tags=mp3:check_programs +@test "failed: check programs missing parallel" { + command() { + [ "$2" != "parallel" ] || return 1 + } + + run mp3_check_programs + + assert_failure + assert_line --index 0 "❌ ERROR: command parallel not found" +} \ No newline at end of file -- 2.47.3