mirror of
https://github.com/wavetermdev/waveterm
synced 2026-04-21 14:37:16 +00:00
feat: print test text when the test fails (#1927)
Adds the following changes to copy tests: - print the body of the test if the test fails - add a count of how many tests passed out of the total - remove the -r flag from the tests
This commit is contained in:
parent
134a1f1ab8
commit
8b262445d5
21 changed files with 38 additions and 112 deletions
|
|
@ -1,13 +0,0 @@
|
|||
# copy an empty directory to a non-existing directory without -r flag
|
||||
# ensure the operation fails and the new file doesn't exist
|
||||
|
||||
set -e
|
||||
cd "$HOME/testcp"
|
||||
mkdir foo
|
||||
|
||||
wsh file copy foo bar >/dev/null 2>&1 && echo "the command should have failed" && exit 1
|
||||
|
||||
if [ -d bar ]; then
|
||||
echo "bar should not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
# copy an empty directory to a non-existing directory with -r flag
|
||||
# copy an empty directory to a non-existing directory
|
||||
# ensure the empty directory is copied to one with the new name
|
||||
|
||||
set -e
|
||||
cd "$HOME/testcp"
|
||||
mkdir foo
|
||||
|
||||
wsh file copy -r foo bar
|
||||
wsh file copy foo bar
|
||||
|
||||
if [ ! -d bar ]; then
|
||||
echo "bar does not exist"
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
# copy an empty directory ending with / to a non-existing directory without -r flag
|
||||
# ensure the copy fails and the new directory doesn't exist
|
||||
|
||||
set -e
|
||||
cd "$HOME/testcp"
|
||||
mkdir bar
|
||||
|
||||
wsh file copy bar/ baz >/dev/null 2>&1 && echo "this command was supposed to fail" && exit 1
|
||||
|
||||
if [ -d baz ]; then
|
||||
echo "baz should not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
# copy an empty directory ending with / to a non-existing directory with -r flag
|
||||
# copy an empty directory ending with / to a non-existing directory
|
||||
# ensure the copy succeeds and the new directory exists
|
||||
|
||||
set -e
|
||||
cd "$HOME/testcp"
|
||||
mkdir bar
|
||||
|
||||
wsh file copy -r bar/ baz
|
||||
wsh file copy bar/ baz
|
||||
if [ ! -d baz ]; then
|
||||
echo "baz does not exist"
|
||||
exit 1
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
# copy an empty directory to a non-existing directory ending with / without -r flag
|
||||
# ensure the copy fails and the new directory doesn't exist
|
||||
|
||||
set -e
|
||||
cd "$HOME/testcp"
|
||||
mkdir bar
|
||||
|
||||
wsh file copy bar baz/ >/dev/null 2>&1 && echo "this command was supposed to fail" && exit 1
|
||||
if [ -d baz ]; then
|
||||
echo "baz should not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
# copy an empty directory to a non-existing directory ending with / with -r flag
|
||||
# copy an empty directory to a non-existing directory ending with /
|
||||
# ensure the copy succeeds and the new directory exists
|
||||
|
||||
set -e
|
||||
cd "$HOME/testcp"
|
||||
mkdir bar
|
||||
|
||||
wsh file copy -r bar baz/
|
||||
wsh file copy bar baz/
|
||||
|
||||
if [ ! -d baz ]; then
|
||||
echo "baz does not exist"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
# copy an empty directory ending with // to a non-existing directory with -r flag
|
||||
# copy an empty directory ending with // to a non-existing directory
|
||||
# ensure the copy succeeds and the new directory exists
|
||||
|
||||
set -e
|
||||
cd "$HOME/testcp"
|
||||
mkdir bar
|
||||
|
||||
wsh file copy -r bar// baz
|
||||
wsh file copy bar// baz
|
||||
|
||||
if [ ! -d baz ]; then
|
||||
echo "baz does not exist"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
# copy an empty directory to a non-existing directory ending with // with -r flag
|
||||
# copy an empty directory to a non-existing directory ending with //
|
||||
# ensure the copy succeeds and the new directory exists
|
||||
|
||||
set -e
|
||||
cd "$HOME/testcp"
|
||||
mkdir bar
|
||||
|
||||
wsh file copy -r bar baz//
|
||||
wsh file copy bar baz//
|
||||
|
||||
if [ ! -d baz ]; then
|
||||
echo "baz does not exist"
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
# copy a directory containing a file to a new directory without -r flag
|
||||
# ensure this fails and the new files don't exist
|
||||
|
||||
set -e
|
||||
cd "$HOME/testcp"
|
||||
mkdir bar
|
||||
touch bar/foo.txt
|
||||
|
||||
wsh file copy bar baz >/dev/null 2>&1 && echo "this command should have failed" && exit 1
|
||||
|
||||
if [ -f baz/foo.txt ]; then
|
||||
echo "baz/foo.txt should not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
# copy a directory containing a file to a new directory with -r flag
|
||||
# copy a directory containing a file to a new directory
|
||||
# ensure this succeeds and the new files exist
|
||||
|
||||
set -e
|
||||
|
|
@ -6,7 +6,7 @@ cd "$HOME/testcp"
|
|||
mkdir bar
|
||||
touch bar/foo.txt
|
||||
|
||||
wsh file copy -r bar baz
|
||||
wsh file copy bar baz
|
||||
|
||||
if [ ! -f baz/foo.txt ]; then
|
||||
echo "baz/foo.txt does not exist"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# copy a directory containing a file to an existing directory with -r flag
|
||||
# copy a directory containing a file to an existing directory
|
||||
# ensure this succeeds and the new files are nested in the existing directory
|
||||
|
||||
set -e
|
||||
|
|
@ -7,7 +7,7 @@ mkdir bar
|
|||
touch bar/foo.txt
|
||||
mkdir baz
|
||||
|
||||
wsh file -r bar baz
|
||||
wsh file copy bar baz
|
||||
|
||||
if [ ! -f baz/bar/foo.txt ]; then
|
||||
echo "baz/bar/foo.txt does not exist"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# copy a directory containing a file to an existing directory ending with / with -r flag
|
||||
# copy a directory containing a file to an existing directory ending with /
|
||||
# ensure this succeeds and the new files are nested in the existing directory
|
||||
|
||||
set -e
|
||||
|
|
@ -7,7 +7,7 @@ mkdir bar
|
|||
touch bar/foo.txt
|
||||
mkdir baz
|
||||
|
||||
wsh file copy -r bar baz/
|
||||
wsh file copy bar baz/
|
||||
|
||||
if [ ! -f baz/bar/foo.txt ]; then
|
||||
echo "baz/bar/foo.txt does not exist"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# copy a directory containing a file to an existing directory ending with /. with -r flag
|
||||
# copy a directory containing a file to an existing directory ending with /.
|
||||
# ensure this succeeds and the new files are nested in the existing directory
|
||||
|
||||
set -e
|
||||
|
|
@ -7,7 +7,7 @@ mkdir bar
|
|||
touch bar/foo.txt
|
||||
mkdir baz
|
||||
|
||||
wsh file copy -r bar baz/.
|
||||
wsh file copy bar baz/.
|
||||
|
||||
if [ ! -f baz/bar/foo.txt ]; then
|
||||
echo "baz/bar/foo.txt does not exist"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# copy a doubly nested directory containing a file to a non-existant directory with the -r flag
|
||||
# copy a doubly nested directory containing a file to a non-existant directory
|
||||
# ensure this succeeds and the new files exist with the first directory renamed
|
||||
|
||||
set -e
|
||||
|
|
@ -7,7 +7,7 @@ mkdir foo
|
|||
mkdir foo/bar
|
||||
touch foo/bar/baz.txt
|
||||
|
||||
wsh file copy -r foo qux
|
||||
wsh file copy foo qux
|
||||
|
||||
if [ ! -f qux/bar/baz.txt ]; then
|
||||
echo "qux/bar/baz.txt does not exist"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# copy a doubly nested directory containing a file to an existing directory with the -r flag
|
||||
# copy a doubly nested directory containing a file to an existing directory
|
||||
# ensure this succeeds and the new files exist and are nested in the existing directory
|
||||
|
||||
set -e
|
||||
|
|
@ -8,7 +8,7 @@ mkdir foo/bar
|
|||
touch foo/bar/baz.txt
|
||||
mkdir qux
|
||||
|
||||
wsh file copy -r foo qux
|
||||
wsh file copy foo qux
|
||||
|
||||
if [ ! -f qux/foo/bar/baz.txt ]; then
|
||||
echo "qux/foo/bar/baz.txt does not exist"
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
# copy the current directory into an existing directory without the -r flag
|
||||
# ensure the copy fails and the output doesn't exist
|
||||
|
||||
set -e
|
||||
cd "$HOME/testcp"
|
||||
mkdir foo
|
||||
touch foo/bar.txt
|
||||
mkdir baz
|
||||
cd foo
|
||||
|
||||
wsh file copy . ../baz >/dev/null 2>&1 && echo "command should have failed" && exit 1
|
||||
|
||||
if [ -f baz/bar.txt ]; then
|
||||
echo "baz/bar.txt should not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
# copy the current directory into an existing directory with the -r flag
|
||||
# copy the current directory into an existing directory
|
||||
# ensure the copy succeeds and the output exists
|
||||
|
||||
set -e
|
||||
|
|
@ -8,7 +8,7 @@ touch foo/bar.txt
|
|||
mkdir baz
|
||||
cd foo
|
||||
|
||||
wsh file copy -r . ../baz
|
||||
wsh file copy . ../baz
|
||||
cd ..
|
||||
|
||||
if [ ! -f baz/bar.txt ]; then
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
# copy the current directory into a non-existing directory without the -r flag
|
||||
# ensure the copy fails and the output does not exist
|
||||
|
||||
set -e
|
||||
cd "$HOME/testcp"
|
||||
mkdir foo
|
||||
touch foo/bar.txt
|
||||
cd foo
|
||||
|
||||
wsh file copy . ../baz >/dev/null 2>&1 && echo "command should have failed" && exit 1
|
||||
|
||||
if [ -f baz/bar.txt ]; then
|
||||
echo "baz/bar.txt should not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
# copy the current directory into a non-existing directory with the -r flag
|
||||
# copy the current directory into a non-existing directory
|
||||
# ensure the copy succeeds and the output exists
|
||||
|
||||
set -e
|
||||
|
|
@ -7,7 +7,7 @@ mkdir foo
|
|||
touch foo/bar.txt
|
||||
cd foo
|
||||
|
||||
wsh file copy -r . ../baz
|
||||
wsh file copy . ../baz
|
||||
cd ..
|
||||
|
||||
if [ ! -f baz/bar.txt ]; then
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ mkdir corge
|
|||
# we need a nested corge/foo so the foo.zip contains the same exact file names
|
||||
# in other words, if one file was named foo and the other was corge, they would
|
||||
# not match. this allows them to be the same.
|
||||
wsh file copy -r foo corge/foo
|
||||
wsh file copy foo corge/foo
|
||||
|
||||
|
||||
zip -r foo.zip foo >/dev/null 2>&1
|
||||
|
|
|
|||
|
|
@ -3,13 +3,22 @@
|
|||
cd "$(dirname "$0")"
|
||||
source testutil.sh
|
||||
|
||||
TOTAL_COPY_TESTS_RUN=0
|
||||
TOTAL_COPY_TESTS_PASSED=0
|
||||
|
||||
for fname in cases/*.sh; do
|
||||
setup_testcp
|
||||
#"${fname}" | read outerr && printf "\e[32mPASS $fname\n\n\e[0m" || printf "\e[31mFAIL $fname: $outerr \n\n\e[0m"
|
||||
if ! outerr=$("${fname}" 2>&1); then
|
||||
printf "\e[31mFAIL $fname:\n$outerr \n\n\e[0m"
|
||||
printf "\e[31mFAIL $fname:\n$outerr \n\e[0m"
|
||||
cat "${fname}"
|
||||
printf "\n"
|
||||
else
|
||||
printf "\e[32mPASS $fname\n\n\e[0m"
|
||||
((TOTAL_COPY_TESTS_PASSED++))
|
||||
fi
|
||||
cleanup_testcp
|
||||
done
|
||||
((TOTAL_COPY_TESTS_RUN++))
|
||||
done
|
||||
|
||||
printf "\n\e[32m${TOTAL_COPY_TESTS_PASSED} of ${TOTAL_COPY_TESTS_RUN} Tests Passed \e[0m\n\n"
|
||||
Loading…
Reference in a new issue