diff --git a/4-ShellP2/student_test.sh b/4-ShellP2/student_test.sh old mode 100644 new mode 100755 index 4e54a366ee094b60873c701fb0f68eec9f9f9217..847461c91dac7a737715338a9482a491f2c13ff8 --- 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 ] }