Skip to content

Commit

Permalink
better use if-then-else then && || in shell script
Browse files Browse the repository at this point in the history
* Fix the "01-test" file with shellcheck

Its code has a problem SC2015.
https://github.com/koalaman/shellcheck/wiki/SC2015

* Add the ".idea" file in ".gitignore"

".idea" file is created by IDE made by IntelliJ IDEA

* Removed .idea folder

* Update 01-test

Co-authored-by: Jens Getreu <getreu@web.de>
  • Loading branch information
iyj6707 and getreu committed Jan 24, 2020
1 parent 559f19d commit e80859d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ target
*.1.gz
.vscode/
tests/functional/output
.idea
36 changes: 24 additions & 12 deletions 01-test
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

# Unit testing

cargo test \
&& echo Cargo test succeeded. \
|| ( echo Cargo test failed. && exit 1 )
if cargo test
then
echo Cargo test succeeded.
else
( echo Cargo test failed. && exit 1 )
fi


# Functional tests
Expand All @@ -17,23 +20,32 @@ cargo build
../../target/debug/stringsext -q 16 -g 63 -tx -a All-Ctrl -u Common \
-e UTF-8 -e utf-16le -e utf-16be input1 > output

diff output expected_output1 \
&& echo Commandline test 1 succeeded. \
|| ( echo Commandline test 1 failed. && exit 2 )
if diff output expected_output1
then
echo Commandline test 1 succeeded.
else
( echo Commandline test 1 failed. && exit 2 )
fi

# We search for `:`.
../../target/debug/stringsext -n 10 -q 32 -g 58 -tx -a All-Ctrl -u Common \
-e UTF-8 -e utf-16le -e utf-16be input1 input2 > output

diff output expected_output2 \
&& echo Commandline test 2 succeeded. \
|| ( echo Commandline test 2 failed. && exit 3 )
if diff output expected_output2
then
echo Commandline test 2 succeeded.
else
( echo Commandline test 2 failed. && exit 3 )
fi

# We search for nothing. Do we get nothing?
../../target/debug/stringsext -q 32 -tx -a None -u None \
-e UTF-8 -e utf-16le -e utf-16be input1 input2 > output

diff output expected_output3 \
&& echo Commandline test 3 succeeded. \
|| ( echo Commandline test 3 failed. && exit 4 )
if diff output expected_output3
then
echo Commandline test 3 succeeded.
else
( echo Commandline test 3 failed. && exit 4 )
fi

0 comments on commit e80859d

Please sign in to comment.