From 595b4f1f4cbfe9bc8c611a6fd150267387dfa1ca Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Tue, 3 Oct 2023 15:26:26 -0300 Subject: [PATCH] tests: Check if program exists before using it The tests/make-test-runtime.sh scripts sets '-e' in lieu of implementing useful error checking, but doesn't actually check if the programs it uses exist in the first place; and aborts silently when they're not available. It is more useful to warn about them, and stop execution earlier. This leaves some leftover files, but arguably that's better than leaving leftover files AND people scratching their heads. Warn about missing required programs. Related: https://github.com/flatpak/flatpak/issues/5020 (cherry picked from commit 6a57fa42e4da08e71f02156115d441cd6e244156) --- tests/make-test-runtime.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/make-test-runtime.sh b/tests/make-test-runtime.sh index 4ba950df..6345ff58 100755 --- a/tests/make-test-runtime.sh +++ b/tests/make-test-runtime.sh @@ -47,6 +47,12 @@ add_bin() { local f=$1 shift + # Check if the program is installed + if ! command -v "${f}" &> /dev/null; then + echo "${f} not found" + exit 1 + fi + if grep -qFe "${f}" $BINS; then # Already handled return 0