test: Update 3 files
Some checks failed
Build-Test-Publish / build (linux/arm64) (push) Failing after 13s
Build-Test-Publish / build (linux/amd64) (push) Failing after 20s
Build-Test-Publish / test-install-from-scratch (linux/amd64) (push) Has been skipped
Build-Test-Publish / test-install-from-scratch (linux/arm64) (push) Has been skipped

This commit is contained in:
Your Name
2025-06-25 19:17:50 +12:00
parent 31dcb29555
commit 6e920bd236
3 changed files with 11 additions and 12 deletions

View File

@ -1,10 +1,9 @@
#!/bin/bash
# Don't use set -e because we want to continue even if tests fail
set -uo pipefail
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT="dehydrate"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
DEHYDRATE="${SCRIPT_DIR}/output/${PROJECT}"
TEST_DIR="${SCRIPT_DIR}/test_temp"
@ -24,10 +23,10 @@ print_test_result() {
local result="$2"
if [ "$result" -eq 0 ]; then
echo -e "${GREEN}${NC} $test_name"
((TESTS_PASSED++))
TESTS_PASSED=$((TESTS_PASSED + 1))
else
echo -e "${RED}${NC} $test_name"
((TESTS_FAILED++))
TESTS_FAILED=$((TESTS_FAILED + 1))
fi
}
@ -71,7 +70,7 @@ else
fi
# Test 2: Help command (shows help when no args provided)
echo -e "\nTest 2: Help command"
printf "\nTest 2: Help command\n"
HELP_OUTPUT=$("$DEHYDRATE" 2>&1 || true)
if [[ "$HELP_OUTPUT" =~ "Usage: dehydrate" ]] && [[ "$HELP_OUTPUT" =~ "Converts existing files" ]]; then
print_test_result "Help command output" 0
@ -88,7 +87,7 @@ echo "int main() { return 0; }" > "$TEST_SRC_DIR/main.cpp"
echo "#include <iostream>" > "$TEST_SRC_DIR/header.hpp"
# Run dehydrate on the test source
DEHYDRATE_OUTPUT=$("$DEHYDRATE" "$TEST_SRC_DIR" "$TEST_DIR" 2>&1 || true)
"$DEHYDRATE" -s "$TEST_SRC_DIR" "$TEST_DIR"
# Dehydrate creates files with pattern _<source_dir_name>.{cpp,hpp}
if [ -f "$TEST_DIR/_test_src.hpp" ] && [ -f "$TEST_DIR/_test_src.cpp" ]; then
print_test_result "Basic dehydration creates output files" 0