summaryrefslogtreecommitdiff
path: root/cli-tests/sort-text
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2026-03-17 09:23:35 +0300
committerGrail Finder <wohilas@gmail.com>2026-03-17 09:23:35 +0300
commit451e6f0381afe37c59f12703f8750407c27ba94a (patch)
treed4a76d7011f2da98bac2ee718afa587952c8ba4f /cli-tests/sort-text
parent47b3d37a9714e3e68e56f009ea1faee5223edeb4 (diff)
parent326a1a4d094c6349e0403d479384347c52964537 (diff)
Merge branch 'master' into feat/agent-flow
Diffstat (limited to 'cli-tests/sort-text')
-rwxr-xr-xcli-tests/sort-text/check.sh91
-rwxr-xr-xcli-tests/sort-text/run.sh25
-rwxr-xr-xcli-tests/sort-text/setup.sh10
-rw-r--r--cli-tests/sort-text/task.txt2
-rwxr-xr-xcli-tests/sort-text/teardown.sh4
5 files changed, 132 insertions, 0 deletions
diff --git a/cli-tests/sort-text/check.sh b/cli-tests/sort-text/check.sh
new file mode 100755
index 0000000..cc1d1df
--- /dev/null
+++ b/cli-tests/sort-text/check.sh
@@ -0,0 +1,91 @@
+#!/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 animals directory exists
+if [ -d "/tmp/sort-text/animals" ]; then
+ log_pass "animals directory exists"
+else
+ log_fail "animals directory missing"
+fi
+
+# Check colors directory exists
+if [ -d "/tmp/sort-text/colors" ]; then
+ log_pass "colors directory exists"
+else
+ log_fail "colors directory missing"
+fi
+
+# Check animals contain cat/dog
+ANIMALS_FILES=$(ls -1 /tmp/sort-text/animals 2>/dev/null | tr '\n' ' ')
+if echo "$ANIMALS_FILES" | grep -q "file1.txt" && echo "$ANIMALS_FILES" | grep -q "file3.txt"; then
+ log_pass "animals contains animal files"
+else
+ log_fail "animals missing animal files (got: $ANIMALS_FILES)"
+fi
+
+# Check colors contain red/blue
+COLORS_FILES=$(ls -1 /tmp/sort-text/colors 2>/dev/null | tr '\n' ' ')
+if echo "$COLORS_FILES" | grep -q "file2.txt" && echo "$COLORS_FILES" | grep -q "file4.txt"; then
+ log_pass "colors contains color files"
+else
+ log_fail "colors missing color files (got: $COLORS_FILES)"
+fi
+
+# Verify content
+if grep -q "cat" /tmp/sort-text/animals/file1.txt 2>/dev/null; then
+ log_pass "file1.txt contains 'cat'"
+else
+ log_fail "file1.txt missing 'cat'"
+fi
+
+if grep -q "dog" /tmp/sort-text/animals/file3.txt 2>/dev/null; then
+ log_pass "file3.txt contains 'dog'"
+else
+ log_fail "file3.txt missing 'dog'"
+fi
+
+if grep -q "red" /tmp/sort-text/colors/file2.txt 2>/dev/null; then
+ log_pass "file2.txt contains 'red'"
+else
+ log_fail "file2.txt missing 'red'"
+fi
+
+if grep -q "blue" /tmp/sort-text/colors/file4.txt 2>/dev/null; then
+ log_pass "file4.txt contains 'blue'"
+else
+ log_fail "file4.txt missing 'blue'"
+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-text/run.sh b/cli-tests/sort-text/run.sh
new file mode 100755
index 0000000..5cd5d3e
--- /dev/null
+++ b/cli-tests/sort-text/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-text/setup.sh b/cli-tests/sort-text/setup.sh
new file mode 100755
index 0000000..351ebe2
--- /dev/null
+++ b/cli-tests/sort-text/setup.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+set -e
+
+mkdir -p /tmp/sort-text
+
+printf "cat" > /tmp/sort-text/file1.txt
+printf "red" > /tmp/sort-text/file2.txt
+printf "dog" > /tmp/sort-text/file3.txt
+printf "blue" > /tmp/sort-text/file4.txt
diff --git a/cli-tests/sort-text/task.txt b/cli-tests/sort-text/task.txt
new file mode 100644
index 0000000..0d3a9e8
--- /dev/null
+++ b/cli-tests/sort-text/task.txt
@@ -0,0 +1,2 @@
+go to /tmp/sort-text, create directories: animals, colors
+sort /tmp/sort-text/*.txt into created directories by text content
diff --git a/cli-tests/sort-text/teardown.sh b/cli-tests/sort-text/teardown.sh
new file mode 100755
index 0000000..5a833ce
--- /dev/null
+++ b/cli-tests/sort-text/teardown.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+set -e
+
+rm -rf /tmp/sort-text