diff --git a/Assignment-06/starter/assignment_tests.sh b/Assignment-06/starter/assignment_tests.sh new file mode 100644 index 0000000000000000000000000000000000000000..5246ee441c5e049315e4d3191569dd6314c40bb9 --- /dev/null +++ b/Assignment-06/starter/assignment_tests.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bats + +############################ DO NOT EDIT THIS FILE ##################################### +# File: assignement_tests.sh +# +# DO NOT EDIT THIS FILE +# +# Add/Edit Student tests in student_tests.sh +# +# All tests in this file must pass - it is used as part of grading! +######################################################################################## + +@test "Pipes" { + run "./dsh" <<EOF +ls | grep dshlib.c +EOF + + # Strip all whitespace (spaces, tabs, newlines) from the output + stripped_output=$(echo "$output" | tr -d '[:space:]') + + # Expected output with all whitespace removed for easier matching + expected_output="dshlib.clocalmodedsh4>dsh4>cmdloopreturned0" + + # These echo commands will help with debugging and will only print + #if the test fails + echo "Captured stdout:" + echo "Output: $output" + echo "Exit Status: $status" + echo "${stripped_output} -> ${expected_output}" + + # Check exact match + [ "$stripped_output" = "$expected_output" ] + + # Assertions + [ "$status" -eq 0 ] +} diff --git a/Assignment-06/starter/student_tests.sh b/Assignment-06/starter/student_tests.sh new file mode 100644 index 0000000000000000000000000000000000000000..638bc341446f7580a80c2aff52971b8023407ea8 --- /dev/null +++ b/Assignment-06/starter/student_tests.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bats + +# File: student_tests.sh +# +# Create your unit tests suit in this file + +@test "Example: check ls runs without errors" { + run ./dsh <<EOF +ls +EOF + + # Assertions + [ "$status" -eq 0 ] +}