-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from zimmski/19-create-simpler-simple.sh
Create an exec script to test only the package under test
- Loading branch information
Showing
6 changed files
with
114 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/bin/bash | ||
|
||
# This exec script implements | ||
# - the replacement of the original file with the mutation, | ||
# - the execution of all tests originating from the package of the mutated file, | ||
# - and the reporting if the mutation was killed. | ||
|
||
if [ -z ${MUTATE_CHANGED+x} ]; then echo "MUTATE_CHANGED is not set"; exit 1; fi | ||
if [ -z ${MUTATE_ORIGINAL+x} ]; then echo "MUTATE_ORIGINAL is not set"; exit 1; fi | ||
if [ -z ${MUTATE_PACKAGE+x} ]; then echo "MUTATE_PACKAGE is not set"; exit 1; fi | ||
|
||
function clean_up { | ||
if [ -f $MUTATE_ORIGINAL.tmp ]; | ||
then | ||
mv $MUTATE_ORIGINAL.tmp $MUTATE_ORIGINAL | ||
fi | ||
} | ||
|
||
function sig_handler { | ||
clean_up | ||
|
||
exit $GOMUTESTING_RESULT | ||
} | ||
trap sig_handler SIGHUP SIGINT SIGTERM | ||
|
||
export GOMUTESTING_DIFF=$(diff -u $MUTATE_ORIGINAL $MUTATE_CHANGED) | ||
|
||
mv $MUTATE_ORIGINAL $MUTATE_ORIGINAL.tmp | ||
cp $MUTATE_CHANGED $MUTATE_ORIGINAL | ||
|
||
export MUTATE_TIMEOUT=${MUTATE_TIMEOUT:-10} | ||
|
||
if [ -n "$TEST_RECURSIVE" ]; then | ||
TEST_RECURSIVE="/..." | ||
fi | ||
|
||
GOMUTESTING_TEST=$(go test -timeout $(printf '%ds' $MUTATE_TIMEOUT) $MUTATE_PACKAGE$TEST_RECURSIVE 2>&1) | ||
export GOMUTESTING_RESULT=$? | ||
|
||
if [ "$MUTATE_DEBUG" = true ] ; then | ||
echo "$GOMUTESTING_TEST" | ||
fi | ||
|
||
clean_up | ||
|
||
case $GOMUTESTING_RESULT in | ||
0) # tests passed -> FAIL | ||
echo "$GOMUTESTING_DIFF" | ||
|
||
exit 1 | ||
;; | ||
1) # tests failed -> PASS | ||
if [ "$MUTATE_DEBUG" = true ] ; then | ||
echo "$GOMUTESTING_DIFF" | ||
fi | ||
|
||
exit 0 | ||
;; | ||
2) # did not compile -> SKIP | ||
if [ "$MUTATE_VERBOSE" = true ] ; then | ||
echo "Mutation did not compile" | ||
fi | ||
|
||
if [ "$MUTATE_DEBUG" = true ] ; then | ||
echo "$GOMUTESTING_DIFF" | ||
fi | ||
|
||
exit 2 | ||
;; | ||
*) # Unkown exit code -> SKIP | ||
echo "Unknown exit code" | ||
echo "$GOMUTESTING_DIFF" | ||
|
||
exit $GOMUTESTING_RESULT | ||
;; | ||
esac |