]> gitweb.hhaalo.de Git - albentohandy.git/commitdiff
add check programs for vorbis library
authorBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 16:34:46 +0000 (18:34 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 16:42:49 +0000 (18:42 +0200)
src/lib/vorbis.sh
tests/vorbis.bats [new file with mode: 0755]

index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f25fc560dc7e96156f231d3d72b0a407b1ab63f6 100644 (file)
@@ -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 (executable)
index 0000000..4dc23d1
--- /dev/null
@@ -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