diff --git a/.gitignore b/.gitignore index 1c6ae15..15c3b77 100644 --- a/.gitignore +++ b/.gitignore @@ -83,7 +83,7 @@ test/*.trs test/*.txt test/*.eps test/test_cscripts.sh -test/test_examples.sh +test/test_examples.py test/reports/*.xml test/butterfly.txt test/.coverage diff --git a/configure.ac b/configure.ac index c191943..9578d78 100644 --- a/configure.ac +++ b/configure.ac @@ -1025,7 +1025,7 @@ AC_CONFIG_FILES([Makefile test/test_cscripts.sh test/test_python_ctools.sh test/test_python_cscripts.sh - test/test_examples.sh + test/test_examples.py pyext/Makefile pyext/setup.py pyext/ctools/__init__.py @@ -1039,7 +1039,7 @@ AC_CONFIG_FILES([Makefile [if test -f test/test_cscripts.sh; then chmod +x test/test_cscripts.sh; fi; if test -f test/test_python_ctools.sh; then chmod +x test/test_python_ctools.sh; fi; if test -f test/test_python_cscripts.sh; then chmod +x test/test_python_cscripts.sh; fi; - if test -f test/test_examples.sh; then chmod +x test/test_examples.sh; fi; + if test -f test/test_examples.py; then chmod +x test/test_examples.py; fi; if test -f testconf.sh; then chmod +x testconf.sh; fi]) AC_OUTPUT diff --git a/examples/generate_prod3_irfs.py b/examples/generate_prod3_irfs.py index 174d318..e70f144 100755 --- a/examples/generate_prod3_irfs.py +++ b/examples/generate_prod3_irfs.py @@ -69,31 +69,31 @@ if __name__ == '__main__': for entry in entries: # Set optional attributes - if entry.has_key('rebin'): + if 'rebin' in entry: rebin = entry['rebin'] else: rebin = False - if entry.has_key('eascale'): + if 'eascale' in entry: eascale = entry['eascale'] else: eascale = 1.0 - if entry.has_key('bgdscale'): + if 'bgdscale' in entry: bgdscale = entry['bgdscale'] else: bgdscale = 1.0 - if entry.has_key('bgdethres'): + if 'bgdethres' in entry: bgdethres = entry['bgdethres'] else: bgdethres = 1000.0 - if entry.has_key('bgdinfill'): + if 'bgdinfill' in entry: bgdinfill = entry['bgdinfill'] else: bgdinfill = False - if entry.has_key('oversample'): + if 'oversample' in entry: oversample = entry['oversample'] else: oversample = 1 - if entry.has_key('norm1d'): + if 'norm1d' in entry: norm1d = entry['norm1d'] else: norm1d = False diff --git a/sonar-project.properties b/sonar-project.properties index 5c75e43..0d54b9f 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -15,17 +15,13 @@ sonar.links.scm=https://cta-gitlab.irap.omp.eu/ctools/ctools # Path to source directories sonar.sources=. -# Path to tests -#sonar.tests=test - # Path to include directories sonar.cxx.includeDirectories=pyext,/home/jenkins/gcc/gcc492/include/c++/4.9.2,/home/jenkins/gcc/gcc492/include/c++/4.9.2/tr1,/home/jenkins/gcc/gcc492/include/c++/4.9.2/ext,/home/jenkins/gcc/gcc492/include/c++/4.9.2/x86_64-unknown-linux-gnu,/home/jenkins/gcc/gcc492/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/include,/usr/include,/usr/include/bits,/usr/include/gnu,/usr/include/linux sonar.cxx.missingIncludeWarnings=False # Exclusions -sonar.exclusions=pyext/ctools/**,pyext/build/**,pyext/setup.py,doc/**,test/dev/** -sonar.coverage.exclusions=pyext/ctools/**,pyext/build/**,examples/**,doc/**,test/dev/** -#sonar.test.exclusions= +sonar.exclusions=cscripts/tests/**,pyext/build/**,pyext/ctools/*_wrap.cpp,pyext/ctools/tests/**,doc/**,test/dev/** +sonar.coverage.exclusions=test/science_verification.py,test/test_examples.py # C++ configuration sonar.cxx.cppcheck.reportPath=cppcheck-result.xml diff --git a/test/Makefile.am b/test/Makefile.am index 2213dab..ef10ca1 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -9,7 +9,7 @@ if WITH_PYTHON TEST_CSCRIPTS = test_cscripts.sh TEST_PYTHON_CTOOLS = test_python_ctools.sh TEST_PYTHON_CSCRIPTS = test_python_cscripts.sh - TEST_PYTHON_EXAMPLES = test_examples.sh + TEST_PYTHON_EXAMPLES = test_examples.py TEST_PYTHON_ENV = PYTHONPATH=$(top_builddir):$(top_builddir)/pyext:$(top_builddir)/pyext/build/ctools/ctools:$(pythondir):$(pyexecdir):$(PYTHONPATH) endif diff --git a/test/test_examples.py b/test/test_examples.py.in index 21032ee..54aa4bf 100755 --- a/test/test_examples.py +++ b/test/test_examples.py.in @@ -58,7 +58,7 @@ class Test(gammalib.GPythonTestSuite): String with name to be used for logging """ # Setup command - cmd = '../examples/' + name + '.py' + cmd = '@PYTHON_COVERAGE@../examples/' + name + '.py' if len(args) > 0: cmd += ' ' + args diff --git a/test/test_examples.sh.in b/test/test_examples.sh.in deleted file mode 100755 index fc5d689..0000000 --- a/test/test_examples.sh.in +++ /dev/null @@ -1,25 +0,0 @@ -#! /bin/sh -# ========================================================================== -# This script launches the examples unit tests -# -# Copyright (C) 2016 Juergen Knoedlseder -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# ========================================================================== - -# -# Run the examples test -# ===================== -@PYTHON_COVERAGE@./test_examples.py