Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cs503zchen
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ziheng Chen
cs503zchen
Commits
421bc1b0
Commit
421bc1b0
authored
2 months ago
by
Ziheng Chen
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
7c5c6dba
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
w6/assignment_tests.sh
+118
-0
118 additions, 0 deletions
w6/assignment_tests.sh
with
118 additions
and
0 deletions
w6/assignment_tests.sh
0 → 100644
+
118
−
0
View file @
421bc1b0
#!/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
"Change directory"
{
current
=
$(
pwd
)
cd
/tmp
mkdir
-p
dsh-test
run
"
${
current
}
/dsh"
<<
EOF
cd dsh-test
pwd
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
=
"/tmp/dsh-testdsh2>dsh2>dsh2>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
]
}
@test
"Change directory - no args"
{
current
=
$(
pwd
)
cd
/tmp
mkdir
-p
dsh-test
run
"
${
current
}
/dsh"
<<
EOF
cd
pwd
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
=
"/tmpdsh2>dsh2>dsh2>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
]
}
@test
"Which which ... which?"
{
run
"./dsh"
<<
EOF
which which
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
=
"/usr/bin/whichdsh2>dsh2>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
"
]
}
@test
"It handles quoted spaces"
{
run
"./dsh"
<<
EOF
echo " hello world "
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
=
" hello world dsh2> dsh2> cmd loop returned 0"
# 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
"
]
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment