From 834a54abae6f5f6f8b96cb91ccfcfc0ddeec118f Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Fri, 25 Sep 2026 20:20:35 +0200 Subject: [PATCH] add opus check programs --- src/lib/opus.sh | 22 ++++++++++++++++++++++ tests/opus.bats | 31 +++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 src/lib/opus.sh create mode 100755 tests/opus.bats 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 -- 2.47.3