| 1 | #!/bin/bash |
| 2 | # Test various interactive scenarios |
| 3 | echo "Testing interactive mode..." |
| 4 | |
| 5 | # Test 1: Basic typing and execution |
| 6 | echo -e "echo 'Test 1 passed'" | timeout 2 ./bin/fortsh 2>&1 | grep -q "Test 1 passed" && echo "✓ Basic typing works" || echo "✗ Basic typing failed" |
| 7 | |
| 8 | # Test 2: Variable assignment |
| 9 | echo -e "X=hello\necho \$X" | timeout 2 ./bin/fortsh 2>&1 | grep -q "hello" && echo "✓ Variable assignment works" || echo "✗ Variable assignment failed" |
| 10 | |
| 11 | # Test 3: Tab completion simulation (just press tab, shouldn't crash) |
| 12 | echo -e "ec\t\n" | timeout 2 ./bin/fortsh 2>&1 > /dev/null && echo "✓ Tab key doesn't crash" || echo "✗ Tab key causes issues" |
| 13 | |
| 14 | # Test 4: History navigation (up arrow would be \033[A but we'll test with echo) |
| 15 | echo -e "echo first\necho second\n!!" | timeout 2 ./bin/fortsh 2>&1 | grep -q "second" && echo "✓ History expansion works" || echo "✗ History expansion failed" |
| 16 | |
| 17 | # Test 5: Long command |
| 18 | LONG_CMD="echo '$(printf 'X%.0s' {1..100})'" |
| 19 | echo -e "$LONG_CMD" | timeout 2 ./bin/fortsh 2>&1 | grep -q "XXX" && echo "✓ Long commands work" || echo "✗ Long commands failed" |
| 20 | |
| 21 | echo "Interactive mode test complete!" |