mirror of
https://github.com/oSoWoSo/DistroHopper.git
synced 2026-06-14 17:36:40 +00:00
qget: - Add QGET_TEST_MODE guard so the script can be sourced for unit testing without executing the main logic dh: - Auto-detect getter tool (qget preferred, quickget fallback) in set_variables(); export as GETTER - Add getter_list_os() wrapper using GETTER --list for portable OS enumeration - Replace hard-coded quickget calls with $GETTER in renew_supported_vms(), renew_ready_vms(), and execmd strings - Fix releases/editions/description parsing (sed instead of cut -f2 which fails on colon-space separators) - Add DH_TEST_MODE guard to prevent execution when sourcing for tests action: - Auto-detect getter tool at startup; export as GETTER - Add --qget / -q and --quickget / -Q flags to override detection tests/: - tests/lib.sh: shared assert helpers (assert_eq, assert_ne, assert_match, assert_cmd, assert_fn_exists) with pass/fail counting - tests/test_dh.sh: 31 unit tests covering set_variables, GETTER, getter_list_os, root_check, wayland_check, and all required function definitions - tests/test_qget.sh: 23 unit tests covering os_support, test_result formatting, is_valid_language, check_hash, and all utility functions - tests/test_action_files.sh: 784 structural tests verifying every action file has OSNAME, PRETTY, HOMEPAGE (valid URL), DESCRIPTION, releases_() and get_() functions - tests/run_tests.sh: top-level runner executing all three suites https://claude.ai/code/session_01M2UXTtQwzcGCNRnFiP2efQ
33 lines
1.1 KiB
Bash
Executable file
33 lines
1.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Tests for structure and metadata of every file in actions/
|
|
|
|
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
source "$REPO_ROOT/tests/lib.sh"
|
|
|
|
echo "=== Testing action files ==="
|
|
|
|
ACTIONS_DIR="$REPO_ROOT/actions"
|
|
file_count=0
|
|
|
|
for action_file in "$ACTIONS_DIR"/*; do
|
|
OS=$(basename "$action_file")
|
|
file_count=$((file_count + 1))
|
|
|
|
# Required metadata: grep without ^ to handle case-block indentation
|
|
for field in OSNAME PRETTY HOMEPAGE DESCRIPTION; do
|
|
val=$(grep "${field}=" "$action_file" | head -1 | cut -d'=' -f2- | tr -d '"' | tr -d "'" | xargs)
|
|
assert_ne "$OS: $field is set" "" "$val"
|
|
done
|
|
|
|
# HOMEPAGE must look like a URL
|
|
homepage=$(grep "HOMEPAGE=" "$action_file" | head -1 | cut -d'=' -f2- | tr -d '"' | tr -d "'" | xargs)
|
|
assert_match "$OS: HOMEPAGE is a URL" '^https?://' "$homepage"
|
|
|
|
# Required functions (windows uses get_windows() instead of get_())
|
|
assert_cmd "$OS: has releases_() function" grep -q 'function releases_()' "$action_file"
|
|
assert_cmd "$OS: has get_() function" grep -q 'function get_' "$action_file"
|
|
done
|
|
|
|
echo ""
|
|
echo "Checked $file_count action files."
|
|
summary
|