From a3ca7297133a2e096140e0ec90ef3aa69abfd512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20=C5=81aniewski-Wo=C5=82=C5=82k?= Date: Tue, 17 May 2016 12:59:29 +0200 Subject: [PATCH 1/4] Updated readme [ci:skip] --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2b11e90..e356957 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ You should test your functions before you submit them to us. Especially in this After you've solved all the excercises, push them all to your fork. Check if all your changes are visible on github.com and create a Pull Request (a nice green button on top of your fork page). The pull request will be automagickly tested with [Travis-CI](https://travis-ci.org/). The results will show as a green checkmark or a sad red x. +**IMPORTANT:**: *In this task, you cannot use `scipy`, `numpy`, or `matplotlib` + ### Open source and public work Yes, we know that you can open another person's fork and copy the solutions. Yay, you got an green checkmark for free! You can be proud of yourself. Have [another one](https://solidwize.com/wp-content/uploads/2012/04/Green-Check-Mark.jpg). Freshly copy-pasted from [google images](http://images.lmgtfy.com/?q=checkmark). From cc8fe34bca5a899bdfa8244576a3dc38c923f81b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20=C5=81aniewski-Wo=C5=82=C5=82k?= Date: Tue, 17 May 2016 13:00:13 +0200 Subject: [PATCH 2/4] corrected formating in readme [ci:skip] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e356957..2707c78 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ You should test your functions before you submit them to us. Especially in this After you've solved all the excercises, push them all to your fork. Check if all your changes are visible on github.com and create a Pull Request (a nice green button on top of your fork page). The pull request will be automagickly tested with [Travis-CI](https://travis-ci.org/). The results will show as a green checkmark or a sad red x. -**IMPORTANT:**: *In this task, you cannot use `scipy`, `numpy`, or `matplotlib` +**IMPORTANT:** *In this task, you cannot use `scipy`, `numpy`, or `matplotlib`* ### Open source and public work From ce6b7ba4e221a9c1a98cd65cfe52e0d5ca584702 Mon Sep 17 00:00:00 2001 From: Lukasz Laniewski-Wollk Date: Fri, 20 May 2016 21:49:31 +0200 Subject: [PATCH 3/4] Modified the test script so it runs all tests even if one of them fail --- .test/run | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.test/run b/.test/run index 4cba339..18e8952 100755 --- a/.test/run +++ b/.test/run @@ -18,12 +18,20 @@ then exit -2 fi +FAIL="" echo "--- Running Tests ---" for i in $(ls .test/test*.py) do if ! python $i then - echo "Test '$i' failed" - exit -3 + FAIL="$FAIL $i" + else + echo "-> Passed" fi done + +if ! test -z "$FAIL" +then + echo "Some tests failed: $FAIL" + exit -3 +fi From 8e0d02c1400a23d3a0322c90ffc85fa32f106191 Mon Sep 17 00:00:00 2001 From: Lukasz Laniewski-Wollk Date: Fri, 20 May 2016 21:59:28 +0200 Subject: [PATCH 4/4] Adding bash-level timeout --- .test/run | 7 ++-- .test/timeout | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 3 deletions(-) create mode 100755 .test/timeout diff --git a/.test/run b/.test/run index 18e8952..5c5690f 100755 --- a/.test/run +++ b/.test/run @@ -12,7 +12,7 @@ do done echo "--- Running test.py ---" -if ! python test.py >/dev/null +if ! .test/timeout -t 60 python test.py >/dev/null then echo "Running test.py failed" exit -2 @@ -22,9 +22,10 @@ FAIL="" echo "--- Running Tests ---" for i in $(ls .test/test*.py) do - if ! python $i + if ! .test/timeout -t 60 python $i then FAIL="$FAIL $i" + echo "-> Failed" else echo "-> Passed" fi @@ -32,6 +33,6 @@ done if ! test -z "$FAIL" then - echo "Some tests failed: $FAIL" + echo "Some tests failed." exit -3 fi diff --git a/.test/timeout b/.test/timeout new file mode 100755 index 0000000..5c19d2e --- /dev/null +++ b/.test/timeout @@ -0,0 +1,91 @@ +#!/bin/bash +# +# The Bash shell script executes a command with a time-out. +# Upon time-out expiration SIGTERM (15) is sent to the process. If the signal +# is blocked, then the subsequent SIGKILL (9) terminates it. +# +# Based on the Bash documentation example. + +# Hello Chet, +# please find attached a "little easier" :-) to comprehend +# time-out example. If you find it suitable, feel free to include +# anywhere: the very same logic as in the original examples/scripts, a +# little more transparent implementation to my taste. +# +# Dmitry V Golovashkin + +scriptName="${0##*/}" + +declare -i DEFAULT_TIMEOUT=9 +declare -i DEFAULT_INTERVAL=1 +declare -i DEFAULT_DELAY=1 + +# Timeout. +declare -i timeout=DEFAULT_TIMEOUT +# Interval between checks if the process is still alive. +declare -i interval=DEFAULT_INTERVAL +# Delay between posting the SIGTERM signal and destroying the process by SIGKILL. +declare -i delay=DEFAULT_DELAY + +function printUsage() { + cat < 0)); do + sleep $interval + kill -0 $$ || exit 0 + ((t -= interval)) + done + + # Be nice, post SIGTERM first. + # The 'exit 0' below will be executed if any preceeding command fails. + kill -s SIGTERM $$ && kill -0 $$ || exit 0 + sleep $delay + kill -s SIGKILL $$ +) 2> /dev/null & + +exec "$@"