diff --git a/LCS/Messaging/python/messaging/test/t_RPC.run b/LCS/Messaging/python/messaging/test/t_RPC.run index 35f4ed77a3da3126de74fee94a4770d7e74a115d..425d6e5804747dd93ce539c2fa49dac358a74d87 100755 --- a/LCS/Messaging/python/messaging/test/t_RPC.run +++ b/LCS/Messaging/python/messaging/test/t_RPC.run @@ -10,5 +10,29 @@ queue=$(< /dev/urandom tr -dc [:alnum:] | head -c16) qpid-config add exchange topic $queue # Run the unit test -python t_RPC.py $queue +# either with or without code coverage measurements, +# depending wheter coverage has been installed +if type "coverage" > /dev/null; then + #run test using python coverage tool + + #erase previous results + coverage erase + + #setup coverage config file + printf "[report]\nexclude_lines = \n if __name__ == .__main__.\n def main\n" > .coveragerc + + coverage run --branch --include=*Messaging/python* t_RPC.py $queue + RESULT=$? + if [ $RESULT -eq 0 ]; then + echo " *** Code coverage results *** " + coverage report -m + echo " *** End coverage results *** " + fi + exit $RESULT +else + #coverage not available + echo "Please run: 'pip install coverage' to enable code coverage reporting of the unit tests" + #run plain test script + python t_RPC.py $queue +fi diff --git a/LCS/Messaging/python/messaging/test/t_messagebus.run b/LCS/Messaging/python/messaging/test/t_messagebus.run index 51050da2237e96f8a2b41bf86c42b6a0f026851c..a4f60936f26653a1b80028b60e0a4092f54ab3d1 100755 --- a/LCS/Messaging/python/messaging/test/t_messagebus.run +++ b/LCS/Messaging/python/messaging/test/t_messagebus.run @@ -10,4 +10,29 @@ queue=$(< /dev/urandom tr -dc [:alnum:] | head -c16) qpid-config add queue $queue # Run the unit test -python t_messagebus.py $queue +# either with or without code coverage measurements, +# depending wheter coverage has been installed + +if type "coverage" > /dev/null; then + #run test using python coverage tool + + #erase previous results + coverage erase + + #setup coverage config file + printf "[report]\nexclude_lines = \n if __name__ == .__main__.\n def main\n" > .coveragerc + + coverage run --branch --include=*Messaging/python* t_messagebus.py $queue + RESULT=$? + if [ $RESULT -eq 0 ]; then + echo " *** Code coverage results *** " + coverage report -m + echo " *** End coverage results *** " + fi + exit $RESULT +else + #coverage not available + echo "Please run: 'pip install coverage' to enable code coverage reporting of the unit tests" + #run plain test script + python t_messagebus.py $queue +fi