Skip to content
Snippets Groups Projects
Commit 6f12b849 authored by Ziheng Chen's avatar Ziheng Chen
Browse files

Edit student_tests.sh

parent 5b6246b2
Branches
No related tags found
No related merge requests found
......@@ -79,33 +79,3 @@ EOF
}
# Test: Append Redirection (`>>`)
@test "Append Redirection: echo Hello > test_append.txt && echo World >> test_append.txt" {
rm -f test_append.txt # Ensure file does not exist
run ./dsh <<EOF
echo Hello > test_append.txt
echo World >> test_append.txt
EOF
sleep 1 # Ensure file is written
[ "$status" -eq 0 ]
[ -f test_append.txt ] # Ensure file exists
trimmed_output=$(cat test_append.txt | tr -d '\r')
echo "Captured output: $trimmed_output" # Debugging
[[ "$trimmed_output" == *"Hello"* && "$trimmed_output" == *"World"* ]]
rm -f test_append.txt
}
# Extra Credit: Combining Pipes and Redirection
@test "Extra Credit: ls | grep .c > output.txt" {
rm -f output.txt # Ensure file does not exist
run ./dsh <<EOF
ls | grep .c > output.txt
EOF
sleep 1 # Ensure file is written
[ "$status" -eq 0 ]
[ -f output.txt ] # Ensure file exists
trimmed_output=$(cat output.txt | tr -d '\r')
echo "Captured output: $trimmed_output" # Debugging
[[ "$trimmed_output" == *"dshlib.c"* ]]
rm -f output.txt
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment