Commit 93edbeae845c2ac50f95dff763b8b44d37812114
1 parent
0181f940
Copy IRFs in cscripts test directory and setup temporary test directory before s…
…etting up the unit tests.
Showing
3 changed files
with
28 additions
and
24 deletions
cscripts/Makefile.am
| @@ -38,7 +38,7 @@ testdata = ../test/data/crab.xml \ | @@ -38,7 +38,7 @@ testdata = ../test/data/crab.xml \ | ||
| 38 | ../test/data/exclusion.reg | 38 | ../test/data/exclusion.reg |
| 39 | 39 | ||
| 40 | # Test IRFs to be distributed in $(pyexecdir)/cscripts/tests/irf | 40 | # Test IRFs to be distributed in $(pyexecdir)/cscripts/tests/irf |
| 41 | -#testirf = | 41 | +testirf = ../test/irf/irf_file.fits.gz |
| 42 | 42 | ||
| 43 | # Distribute scripts and parfiles | 43 | # Distribute scripts and parfiles |
| 44 | EXTRA_DIST = $(binscripts) $(pythonscripts) | 44 | EXTRA_DIST = $(binscripts) $(pythonscripts) |
| @@ -52,8 +52,8 @@ testscriptsdir = $(pyexecdir)/cscripts/tests | @@ -52,8 +52,8 @@ testscriptsdir = $(pyexecdir)/cscripts/tests | ||
| 52 | testscripts_DATA = $(testscripts) | 52 | testscripts_DATA = $(testscripts) |
| 53 | testdatadir = $(pyexecdir)/cscripts/tests/data | 53 | testdatadir = $(pyexecdir)/cscripts/tests/data |
| 54 | testdata_DATA = $(testdata) | 54 | testdata_DATA = $(testdata) |
| 55 | -#testirfdir = $(pyexecdir)/cscripts/tests/irf | ||
| 56 | -#testirf_DATA = $(testirf) | 55 | +testirfdir = $(pyexecdir)/cscripts/tests/irf |
| 56 | +testirf_DATA = $(testirf) | ||
| 57 | 57 | ||
| 58 | # Add hook rule to create symbolic links for cscripts | 58 | # Add hook rule to create symbolic links for cscripts |
| 59 | install-data-hook: | 59 | install-data-hook: |
test/test_csobs2caldb.py
| @@ -43,7 +43,7 @@ class Test(gammalib.GPythonTestSuite): | @@ -43,7 +43,7 @@ class Test(gammalib.GPythonTestSuite): | ||
| 43 | gammalib.GPythonTestSuite.__init__(self) | 43 | gammalib.GPythonTestSuite.__init__(self) |
| 44 | 44 | ||
| 45 | # Set members | 45 | # Set members |
| 46 | - self._inobs = "data/obs_unbinned.xml" | 46 | + self._inobs = "data/obs_unbinned.xml" |
| 47 | 47 | ||
| 48 | # Clean calibration database | 48 | # Clean calibration database |
| 49 | os.system("rm -rf caldb >/dev/null 2>&1") | 49 | os.system("rm -rf caldb >/dev/null 2>&1") |
test/test_python_cscripts.py
| @@ -31,28 +31,10 @@ import test_cslightcrv | @@ -31,28 +31,10 @@ import test_cslightcrv | ||
| 31 | # ================== # | 31 | # ================== # |
| 32 | # Perform unit tests # | 32 | # Perform unit tests # |
| 33 | # ================== # | 33 | # ================== # |
| 34 | -def test(installed=False): | 34 | +def test(installed=False, debug=False): |
| 35 | """ | 35 | """ |
| 36 | Perform cscripts unit testing. | 36 | Perform cscripts unit testing. |
| 37 | """ | 37 | """ |
| 38 | - # Allocate test suite container | ||
| 39 | - suites = gammalib.GTestSuites("cscripts unit testing") | ||
| 40 | - | ||
| 41 | - # Allocate test suites and append them to the container | ||
| 42 | - suite_cscaldb = test_cscaldb.Test() | ||
| 43 | - suite_csobs2caldb = test_csobs2caldb.Test() | ||
| 44 | - suite_cslightcrv = test_cslightcrv.Test() | ||
| 45 | - | ||
| 46 | - # Setup unit tests | ||
| 47 | - suite_cscaldb.set() | ||
| 48 | - suite_csobs2caldb.set() | ||
| 49 | - suite_cslightcrv.set() | ||
| 50 | - | ||
| 51 | - # Append tests to container | ||
| 52 | - suites.append(suite_cscaldb) | ||
| 53 | - suites.append(suite_csobs2caldb) | ||
| 54 | - suites.append(suite_cslightcrv) | ||
| 55 | - | ||
| 56 | # If we have an installed version then create a temporary directory and | 38 | # If we have an installed version then create a temporary directory and |
| 57 | # copy over all information that is needed | 39 | # copy over all information that is needed |
| 58 | if installed: | 40 | if installed: |
| @@ -69,7 +51,7 @@ def test(installed=False): | @@ -69,7 +51,7 @@ def test(installed=False): | ||
| 69 | 51 | ||
| 70 | # Copy over test data and irf | 52 | # Copy over test data and irf |
| 71 | os.system("cp -r %s %s" % (dirname+"/data", "data")) | 53 | os.system("cp -r %s %s" % (dirname+"/data", "data")) |
| 72 | - #os.system("cp -r %s %s" % (dirname+"/irf", "irf")) | 54 | + os.system("cp -r %s %s" % (dirname+"/irf", "irf")) |
| 73 | 55 | ||
| 74 | # ... otherwise set the calibration database | 56 | # ... otherwise set the calibration database |
| 75 | else: | 57 | else: |
| @@ -88,6 +70,24 @@ def test(installed=False): | @@ -88,6 +70,24 @@ def test(installed=False): | ||
| 88 | else: | 70 | else: |
| 89 | os.system("cp -r %s/syspfiles/*.par pfiles/" % (os.environ['CTOOLS'])) | 71 | os.system("cp -r %s/syspfiles/*.par pfiles/" % (os.environ['CTOOLS'])) |
| 90 | 72 | ||
| 73 | + # Allocate test suite container | ||
| 74 | + suites = gammalib.GTestSuites("cscripts unit testing") | ||
| 75 | + | ||
| 76 | + # Allocate test suites and append them to the container | ||
| 77 | + suite_cscaldb = test_cscaldb.Test() | ||
| 78 | + suite_csobs2caldb = test_csobs2caldb.Test() | ||
| 79 | + suite_cslightcrv = test_cslightcrv.Test() | ||
| 80 | + | ||
| 81 | + # Setup unit tests | ||
| 82 | + suite_cscaldb.set() | ||
| 83 | + suite_csobs2caldb.set() | ||
| 84 | + suite_cslightcrv.set() | ||
| 85 | + | ||
| 86 | + # Append tests to container | ||
| 87 | + suites.append(suite_cscaldb) | ||
| 88 | + suites.append(suite_csobs2caldb) | ||
| 89 | + suites.append(suite_cslightcrv) | ||
| 90 | + | ||
| 91 | # Run test suite | 91 | # Run test suite |
| 92 | success = suites.run() | 92 | success = suites.run() |
| 93 | 93 | ||
| @@ -95,6 +95,10 @@ def test(installed=False): | @@ -95,6 +95,10 @@ def test(installed=False): | ||
| 95 | if not installed: | 95 | if not installed: |
| 96 | suites.save("reports/cscripts.xml") | 96 | suites.save("reports/cscripts.xml") |
| 97 | 97 | ||
| 98 | + # If debuging is requested then print test suites | ||
| 99 | + if debug: | ||
| 100 | + print(suites) | ||
| 101 | + | ||
| 98 | # Set return code | 102 | # Set return code |
| 99 | if success: | 103 | if success: |
| 100 | rc = 0 | 104 | rc = 0 |