diff --git a/.gitattributes b/.gitattributes index f73871a38fcc6edfb6a4fefc2872914ac2662891..cde8637838151348e1f4715cc8bf4d1220ed8da8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2648,6 +2648,7 @@ LCS/PyCommon/CMakeLists.txt -text LCS/PyCommon/__init__.py -text LCS/PyCommon/datetimeutils.py -text LCS/PyCommon/factory.py -text +LCS/PyCommon/test/t_dbcredentials.run eol=lf LCS/PyCommon/test/t_dbcredentials.sh eol=lf LCS/PyCommon/util.py -text LCS/Tools/src/checkcomp.py -text diff --git a/LCS/PyCommon/test/t_dbcredentials.run b/LCS/PyCommon/test/t_dbcredentials.run new file mode 100755 index 0000000000000000000000000000000000000000..f1676a41d648f5c3a1f05712679a43cfa1a323f8 --- /dev/null +++ b/LCS/PyCommon/test/t_dbcredentials.run @@ -0,0 +1,33 @@ +#!/bin/bash + +if type "coverage" >& /dev/null; then + COVERAGE=coverage +elif type "python-coverage" >& /dev/null; then + COVERAGE=python-coverage +else + COVERAGE="" +fi + +if [ -n "$COVERAGE" ]; then + #run test using python python-coverage tool + + #erase previous results + $COVERAGE erase + + #setup python-coverage config file + printf "[report]\nexclude_lines = \n if __name__ == .__main__.\n def main\n" > .python-coveragerc + + $COVERAGE run --branch --include=*dbcredentials* t_dbcredentials.py + RESULT=$? + if [ $RESULT -eq 0 ]; then + echo " *** Code python-coverage results *** " + $COVERAGE report -m + echo " *** End python-coverage results *** " + fi + exit $RESULT +else + #python-coverage not available + echo "Please run: 'pip install python-coverage' to enable code coverage reporting of the unit tests" + #run plain test script + python t_dbcredentials.py +fi