Skip to content
Snippets Groups Projects
Commit 00a71248 authored by Vanshika Mohan Bongade's avatar Vanshika Mohan Bongade
Browse files

Upload New File

parent 3ab7bf5d
Branches
No related tags found
No related merge requests found
#!/usr/bin/env bats
@test "Basic piping: ls | grep .c" {
run ./dsh <<EOF
ls | grep .c
EOF
[ "$status" -eq 0 ]
}
@test "Count words using wc -w" {
run ./dsh <<EOF
echo "Hello World" | wc -w
EOF
output_trimmed=$(echo "$output" | tr -cd '0-9') # Remove non-numeric characters
echo "DEBUG: Output was '$output_trimmed'"
[ "$output_trimmed" = "2" ]
}
@test "Invalid command in pipe" {
run ./dsh <<EOF
ls | invalid_cmd
EOF
echo "DEBUG: Output was '$output'"
[[ "$output" == *"error: command not found"* ]] || [[ "$output" == *"command not found"* ]]
}
@test "Multiple pipes working" {
run ./dsh <<EOF
cat dshlib.c | grep "int" | wc -l
EOF
[ "$status" -eq 0 ]
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment