diff --git a/tests/additional_edge_tests.sh b/tests/additional_edge_tests.sh index 4303912..081907f 100644 --- a/tests/additional_edge_tests.sh +++ b/tests/additional_edge_tests.sh @@ -54,6 +54,9 @@ if [ -d "$PROJECT_DIR/src" ]; then fi TM="./tm" +# Ensure orchestration enforcement allows non-interactive test commands. +export TM_AGENT_ID="test_suite_agent" + TEST_COUNT=0 PASS_COUNT=0 @@ -65,7 +68,7 @@ cleanup() { # Add delay for WSL if [ $IS_WSL -eq 1 ]; then sleep 0.5 - sync + sleep 0.1 fi cd "$SAVED_DIR" 2>/dev/null || cd /tmp diff --git a/tests/run_all_tests_safe.sh b/tests/run_all_tests_safe.sh index c2f94e6..6fe1386 100644 --- a/tests/run_all_tests_safe.sh +++ b/tests/run_all_tests_safe.sh @@ -112,7 +112,6 @@ run_test_safe() { if [ $IS_WSL -eq 1 ]; then echo "Waiting 2 seconds before next test (WSL safety)..." sleep 2 - sync else sleep 0.5 fi @@ -163,4 +162,4 @@ if [ $FAILED_TESTS -eq 0 ] && [ $PASSED_TESTS -gt 0 ]; then else echo -e "${RED}Some tests failed. Please review the results.${NC}" exit 1 -fi \ No newline at end of file +fi diff --git a/tests/stress_test.sh b/tests/stress_test.sh index e08141d..86bf59f 100644 --- a/tests/stress_test.sh +++ b/tests/stress_test.sh @@ -54,6 +54,9 @@ if [ -d "$PROJECT_DIR/src" ]; then fi TM="./tm" +# Ensure orchestration enforcement allows non-interactive stress commands. +export TM_AGENT_ID="test_suite_agent" + TEST_COUNT=0 PASS_COUNT=0 FAIL_COUNT=0 @@ -67,7 +70,7 @@ cleanup() { # Add delay for WSL if [ $IS_WSL -eq 1 ]; then sleep 0.5 - sync + sleep 0.1 fi cd "$SAVED_DIR" 2>/dev/null || cd /tmp @@ -88,10 +91,16 @@ function stress_test() { local END_TIME=$(date +%s.%N) local DURATION=$(echo "$END_TIME - $START_TIME" | bc -l) - # Check if completed within reasonable time (adjust as needed) - if (( $(echo "$DURATION < 10.0" | bc -l) )); then + # WSL is slower under filesystem-heavy loops; use a higher threshold there. + local DURATION_LIMIT="10.0" + if [ $IS_WSL -eq 1 ]; then + DURATION_LIMIT="30.0" + fi + + # Check if completed within reasonable time. + if (( $(echo "$DURATION < $DURATION_LIMIT" | bc -l) )); then if [ -n "$EXPECTED_COUNT" ]; then - local ACTUAL_COUNT=$($TM list | grep -c "○\|◐\|●\|⊘\|✗") + local ACTUAL_COUNT=$($TM export --format json 2>/dev/null | grep -o '"id"' | wc -l | tr -d ' ') if [ $ACTUAL_COUNT -ge $EXPECTED_COUNT ]; then echo "PASS (${DURATION}s, $ACTUAL_COUNT tasks)" PASS_COUNT=$((PASS_COUNT + 1)) @@ -303,7 +312,7 @@ echo "╔═══════════════════════ echo "║ STRESS TEST SUMMARY ║" echo "╚══════════════════════════════════════════════════════╝" -TOTAL_TASKS=$($TM list | grep -c "○\|◐\|●\|⊘\|✗" 2>/dev/null || echo 0) +TOTAL_TASKS=$($TM export --format json 2>/dev/null | grep -o '"id"' | wc -l | tr -d ' ' || echo 0) echo "Total tasks created: $TOTAL_TASKS" echo "Total stress tests: $TEST_COUNT" echo "Passed: $PASS_COUNT" @@ -322,4 +331,4 @@ else fi # Cleanup is handled by trap -exit $EXIT_CODE \ No newline at end of file +exit $EXIT_CODE diff --git a/tests/test_agent_specialization.sh b/tests/test_agent_specialization.sh index b513ba8..46840bd 100644 --- a/tests/test_agent_specialization.sh +++ b/tests/test_agent_specialization.sh @@ -42,6 +42,7 @@ if [ -d "$PROJECT_DIR/src" ]; then fi chmod +x ./tm TM="./tm" +export TM_AGENT_ID="test_suite_agent" echo -e "${BLUE}===================================${NC}" echo -e "${BLUE} Agent Specialization Tests ${NC}" diff --git a/tests/test_collaboration.sh b/tests/test_collaboration.sh index 4ddeccb..0bb9ce2 100644 --- a/tests/test_collaboration.sh +++ b/tests/test_collaboration.sh @@ -39,6 +39,7 @@ else fi chmod +x tm +export TM_AGENT_ID="test_suite_agent" echo -e "${BLUE}===================================${NC}" echo -e "${BLUE} Collaboration Features Tests ${NC}" diff --git a/tests/test_context_sharing.sh b/tests/test_context_sharing.sh index 083608d..cbab5ba 100644 --- a/tests/test_context_sharing.sh +++ b/tests/test_context_sharing.sh @@ -61,11 +61,12 @@ setup() { fi TM="./tm" chmod +x "$TM" + export TM_AGENT_ID="test_suite_agent" - # Add WSL-specific delay for filesystem sync + # Add WSL-specific delay without host-wide sync (can hang on mounted filesystems) if [ $IS_WSL -eq 1 ]; then sleep 0.5 - sync + sleep 0.1 fi git init > /dev/null 2>&1 @@ -103,7 +104,7 @@ cleanup() { # Add delay for WSL if [ $IS_WSL -eq 1 ]; then sleep 0.5 - sync + sleep 0.1 fi cd / 2>/dev/null || cd /tmp diff --git a/tests/test_durability.sh b/tests/test_durability.sh index 6ab32b4..2d4e785 100644 --- a/tests/test_durability.sh +++ b/tests/test_durability.sh @@ -42,6 +42,7 @@ if [ -d "$PROJECT_DIR/src" ]; then fi chmod +x ./tm TM="./tm" +export TM_AGENT_ID="test_suite_agent" echo -e "${BLUE}===================================${NC}" echo -e "${BLUE} Durability & Resilience Tests ${NC}" @@ -83,8 +84,8 @@ test_basic_persistence() { # Backup database cp .task-orchestrator/tasks.db .task-orchestrator/tasks.db.backup - # Simulate restart by clearing any cache (if exists) - sync + # Simulate restart without calling host-wide sync (can hang on mounted filesystems). + sleep 0.1 # Verify data persists $TM show $TASK1 | grep -q "in_progress" && \ @@ -191,8 +192,8 @@ test_wal_recovery() { # Create tasks TASK=$($TM add "WAL test task" | grep -o '[a-f0-9]\{8\}') - # Force checkpoint - sync + # Force checkpoint simulation without host-wide sync. + sleep 0.1 # Verify WAL files exist (if WAL enabled) if [ -f .task-orchestrator/tasks.db-wal ]; then diff --git a/tests/test_edge_cases.sh b/tests/test_edge_cases.sh index a3422b8..66b4d1b 100644 --- a/tests/test_edge_cases.sh +++ b/tests/test_edge_cases.sh @@ -53,6 +53,9 @@ if [ -d "$PROJECT_DIR/src" ]; then fi TM="./tm" +# Ensure orchestration enforcement allows non-interactive test commands. +export TM_AGENT_ID="test_suite_agent" + TEST_COUNT=0 PASS_COUNT=0 FAIL_COUNT=0 @@ -67,7 +70,7 @@ cleanup() { # Add delay for WSL if [ $IS_WSL -eq 1 ]; then sleep 0.5 - sync + sleep 0.1 fi cd "$SAVED_DIR" 2>/dev/null || cd /tmp diff --git a/tests/test_tm.sh b/tests/test_tm.sh index ce667ef..a90f6ee 100644 --- a/tests/test_tm.sh +++ b/tests/test_tm.sh @@ -27,10 +27,10 @@ fi echo "Running tests in isolated directory: $TEST_DIR" cd "$TEST_DIR" -# Add WSL-specific delay for filesystem sync +# Add WSL-specific delay without host-wide sync (can hang on mounted filesystems) if [ $IS_WSL -eq 1 ]; then sleep 0.5 - sync + sleep 0.1 fi # Find tm executable safely @@ -54,6 +54,9 @@ if [ -d "$PROJECT_DIR/src" ]; then fi TM="./tm" +# Ensure orchestration enforcement allows non-interactive test commands. +export TM_AGENT_ID="test_suite_agent" + # Set environment variables for WSL safety if [ $IS_WSL -eq 1 ]; then export SQLITE_TMPDIR="$TEST_DIR" @@ -71,10 +74,10 @@ cleanup() { # Kill any remaining tm processes pkill -f "tm.*$TEST_DIR" 2>/dev/null || true - # Add delay for WSL + # Add delay for WSL without host-wide sync if [ $IS_WSL -eq 1 ]; then sleep 0.5 - sync + sleep 0.1 fi cd "$SAVED_DIR" 2>/dev/null || cd /tmp @@ -319,4 +322,4 @@ else fi # Cleanup is handled by trap -exit $EXIT_CODE \ No newline at end of file +exit $EXIT_CODE