]> gitweb.hhaalo.de Git - albentohandy.git/commitdiff
add opus check programs
authorBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 18:20:35 +0000 (20:20 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 18:20:35 +0000 (20:20 +0200)
src/lib/opus.sh [new file with mode: 0644]
tests/opus.bats [new file with mode: 0755]

diff --git a/src/lib/opus.sh b/src/lib/opus.sh
new file mode 100644 (file)
index 0000000..e3b22f0
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+opus_errlog()
+{
+       local lastexit=$?
+       local msg="$1"
+
+       echo "❌ ERROR: $msg"
+       return $lastexit
+}
+
+opus_check_programs()
+{
+       command -v opusenc > /dev/null \
+               || opus_errlog "command opusenc not found" \
+               || return $?
+       command -v parallel > /dev/null \
+               || opus_errlog "command parallel not found" \
+               || return $?
+}
+
+opus_check_programs || return $?
\ No newline at end of file
diff --git a/tests/opus.bats b/tests/opus.bats
new file mode 100755 (executable)
index 0000000..28439fe
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/bats
+
+setup() {
+       bats_load_library 'bats-support'
+       bats_load_library 'bats-assert'
+       source "src/lib/opus.sh"
+}
+
+# bats test_tags=opus:check_programs
+@test "failed: check programs missing opusenc" {
+       command() {
+               [ "$2" != "opusenc" ] || return 1
+       }
+
+       run opus_check_programs
+
+       assert_failure
+       assert_line --index 0 "❌ ERROR: command opusenc not found"
+}
+
+# bats test_tags=opus:check_programs
+@test "failed: check programs missing parallel" {
+       command() {
+               [ "$2" != "parallel" ] || return 1
+       }
+
+       run opus_check_programs
+
+       assert_failure
+       assert_line --index 0 "❌ ERROR: command parallel not found"
+}
\ No newline at end of file