From 98d41d74f3e56be2fb4b1fb68c32e5051c1b55db Mon Sep 17 00:00:00 2001 From: cxb23 <cxb23@tux4.cci.drexel.edu> Date: Sat, 22 Feb 2025 20:03:20 -0500 Subject: [PATCH] added to student_test.sh and passed tests. fully finished with coding assigmment --- 4-ShellP2/student_test.sh | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) mode change 100644 => 100755 4-ShellP2/student_test.sh diff --git a/4-ShellP2/student_test.sh b/4-ShellP2/student_test.sh old mode 100644 new mode 100755 index 4e54a36..847461c --- a/4-ShellP2/student_test.sh +++ b/4-ShellP2/student_test.sh @@ -5,7 +5,7 @@ # Create your unit tests suit in this file @test "Example: check ls runs without errors" { - run ./dsh <<EOF + run "./dsh" <<EOF ls EOF @@ -13,11 +13,27 @@ EOF [ "$status" -eq 0 ] } -@test "Change directory to bats" { - run ./dsh <<EOF -cd bats +@test "Change directory, then remove directory" { + run "./dsh" <<EOF +cd dsh-test +cd .. +rm dsh-test EOF + + [ "$status" -eq 0 ] +} + +@test "check echo runs without errors" { + run "./dsh" << EOF +echo "helloooooo sailor" +EOF + # Strip all whitespace (spaces, tabs, newlines) from the output + stripped_output=$(echo "$output" | tr -d '\t\n\r\f\v') + + # Expected output with all whitespace removed for easier matching + expected_output="helloooooo sailordsh2> dsh2> cmd loop returned 0" + [ "$stripped_output" = "$expected_output" ] - [ "$status" -eq 0] + [ "$status" -eq 0 ] } -- GitLab