diff options
Diffstat (limited to 'cli-tests/sort-img')
| -rwxr-xr-x | cli-tests/sort-img/check.sh | 74 | ||||
| -rwxr-xr-x | cli-tests/sort-img/run.sh | 25 | ||||
| -rwxr-xr-x | cli-tests/sort-img/setup.sh | 9 | ||||
| -rwxr-xr-x | cli-tests/sort-img/teardown.sh | 4 |
4 files changed, 112 insertions, 0 deletions
diff --git a/cli-tests/sort-img/check.sh b/cli-tests/sort-img/check.sh new file mode 100755 index 0000000..3efc9d2 --- /dev/null +++ b/cli-tests/sort-img/check.sh @@ -0,0 +1,74 @@ +#!/bin/bash +set -e + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +LOG_FILE=$(ls -t "$SCRIPT_DIR"/*_run.log 2>/dev/null | head -1) + +PASS=0 +FAIL=0 + +log_pass() { + echo "[PASS] $1" + PASS=$((PASS + 1)) +} + +log_fail() { + echo "[FAIL] $1" + FAIL=$((FAIL + 1)) +} + +echo "=== Checking results ===" +echo "" + +# Check has-animals directory exists +if [ -d "/tmp/sort-img/has-animals" ]; then + log_pass "has-animals directory exists" +else + log_fail "has-animals directory missing" +fi + +# Check no-animals directory exists +if [ -d "/tmp/sort-img/no-animals" ]; then + log_pass "no-animals directory exists" +else + log_fail "no-animals directory missing" +fi + +# Check has-animals contains at least one image +HAS_ANIMALS_FILES=$(ls -1 /tmp/sort-img/has-animals 2>/dev/null | wc -l) +if [ "$HAS_ANIMALS_FILES" -gt 0 ]; then + log_pass "has-animals contains images ($HAS_ANIMALS_FILES files)" +else + log_fail "has-animals is empty" +fi + +# Check no-animals contains at least one image +NO_ANIMALS_FILES=$(ls -1 /tmp/sort-img/no-animals 2>/dev/null | wc -l) +if [ "$NO_ANIMALS_FILES" -gt 0 ]; then + log_pass "no-animals contains images ($NO_ANIMALS_FILES files)" +else + log_fail "no-animals is empty" +fi + +# Check total files sorted correctly (3 original files should be in subdirs) +TOTAL_SORTED=$((HAS_ANIMALS_FILES + NO_ANIMALS_FILES)) +if [ "$TOTAL_SORTED" -eq 3 ]; then + log_pass "all 3 files sorted into subdirectories" +else + log_fail "expected 3 files sorted, got $TOTAL_SORTED" +fi + +echo "" +echo "=== Summary ===" +echo "PASSED: $PASS" +echo "FAILED: $FAIL" + +if [ $FAIL -gt 0 ]; then + echo "" + echo "Log file: $LOG_FILE" + exit 1 +fi + +echo "" +echo "All tests passed!" +exit 0 diff --git a/cli-tests/sort-img/run.sh b/cli-tests/sort-img/run.sh new file mode 100755 index 0000000..5cd5d3e --- /dev/null +++ b/cli-tests/sort-img/run.sh @@ -0,0 +1,25 @@ +#!/bin/bash +set -e + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +TIMESTAMP=$(date +%Y%m%d_%H%M%S) +LOG_FILE="$SCRIPT_DIR/${TIMESTAMP}_run.log" + +exec > "$LOG_FILE" 2>&1 + +echo "=== Running teardown ===" +"$SCRIPT_DIR/teardown.sh" + +echo "" +echo "=== Running setup ===" +"$SCRIPT_DIR/setup.sh" + +echo "" +echo "=== Running task ===" +TASK=$(cat "$SCRIPT_DIR/task.txt") +cd /home/grail/projects/plays/goplays/gf-lt +go run . -cli -msg "$TASK" + +echo "" +echo "=== Done ===" +echo "Log file: $LOG_FILE" diff --git a/cli-tests/sort-img/setup.sh b/cli-tests/sort-img/setup.sh new file mode 100755 index 0000000..6b89be8 --- /dev/null +++ b/cli-tests/sort-img/setup.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +mkdir -p /tmp/sort-img + +cp ../../../assets/ex01.png /tmp/sort-img/file1.png +cp ../../../assets/helppage.png /tmp/sort-img/file2.png +cp ../../../assets/yt_thumb.jpg /tmp/sort-img/file3.jpg diff --git a/cli-tests/sort-img/teardown.sh b/cli-tests/sort-img/teardown.sh new file mode 100755 index 0000000..691155b --- /dev/null +++ b/cli-tests/sort-img/teardown.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -e + +rm -rf /tmp/sort-img |
