From: Bastian Dehn Date: Fri, 25 Sep 2026 18:20:35 +0000 (+0200) Subject: add opus check programs X-Git-Tag: v1.0.0^2~7^2~1 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=834a54abae6f5f6f8b96cb91ccfcfc0ddeec118f;p=albentohandy.git add opus check programs --- diff --git a/src/lib/opus.sh b/src/lib/opus.sh new file mode 100644 index 0000000..e3b22f0 --- /dev/null +++ b/src/lib/opus.sh @@ -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 index 0000000..28439fe --- /dev/null +++ b/tests/opus.bats @@ -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