| 1 | #!/bin/bash |
| 2 | echo "=== Comprehensive Interactive Mode Test ===" |
| 3 | |
| 4 | # Test 1: Basic typing |
| 5 | echo -e "echo 'Test 1'" | timeout 2 ./bin/fortsh 2>&1 | grep -q "Test 1" && echo "✓ Basic typing" || echo "✗ Basic typing" |
| 6 | |
| 7 | # Test 2: cd with space (previously caused segfault) |
| 8 | echo -e "cd \npwd" | timeout 2 ./bin/fortsh 2>&1 > /dev/null && echo "✓ cd with space" || echo "✗ cd with space" |
| 9 | |
| 10 | # Test 3: Multiple spaces |
| 11 | echo -e "echo 'spaces'" | timeout 2 ./bin/fortsh 2>&1 | grep -q "spaces" && echo "✓ Multiple spaces" || echo "✗ Multiple spaces" |
| 12 | |
| 13 | # Test 4: Tab after command |
| 14 | echo -e "echo\t'tab'" | timeout 2 ./bin/fortsh 2>&1 | grep -q "tab" && echo "✓ Tab after command" || echo "✗ Tab after command" |
| 15 | |
| 16 | # Test 5: Variable with spaces |
| 17 | echo -e "X='hello world'\necho \$X" | timeout 2 ./bin/fortsh 2>&1 | grep -q "hello world" && echo "✓ Variable with spaces" || echo "✗ Variable with spaces" |
| 18 | |
| 19 | # Test 6: Command with multiple arguments |
| 20 | echo -e "echo one two three" | timeout 2 ./bin/fortsh 2>&1 | grep -q "one two three" && echo "✓ Multiple arguments" || echo "✗ Multiple arguments" |
| 21 | |
| 22 | # Test 7: Empty command (just Enter) |
| 23 | echo -e "\necho 'after empty'" | timeout 2 ./bin/fortsh 2>&1 | grep -q "after empty" && echo "✓ Empty command" || echo "✗ Empty command" |
| 24 | |
| 25 | # Test 8: History expansion |
| 26 | echo -e "echo first\necho second\n!!" | timeout 2 ./bin/fortsh 2>&1 | grep -q "second" && echo "✓ History expansion" || echo "✗ History expansion" |
| 27 | |
| 28 | # Test 9: cd followed by typing (previously caused segfault with buffer_ref) |
| 29 | echo -e "cd ../\necho test" | timeout 2 ./bin/fortsh 2>&1 | grep -q "test" && echo "✓ cd then typing" || echo "✗ cd then typing" |
| 30 | |
| 31 | echo "=== Test Complete ===" |