Commit 443151637732c0810bf18263057e5ffe9877df56

Authored by Jürgen Knödlseder
1 parent 6cefe7c5

Test all ctools for help text

The outcome of the unit tests depends on the presence of the CTOOLS environment variable. If the CTOOLS environment variable is not present the unit test should fail, otherwise it sould succeed.
dev/testreport.py
... ... @@ -66,7 +66,7 @@ def report_one_failure(name, xml):
66 66 type = xml.attribute('type')
67 67  
68 68 # Print failure information
69   - print(' Failure in %s:\n "%s" (%s)' % (name, message, type))
  69 + print(' Failure in "%s":\n "%s" (%s)' % (name, message, type))
70 70  
71 71 # Return
72 72 return
... ...
src/support/ctool.cpp
... ... @@ -1777,8 +1777,8 @@ std::string ctool::warn_xml_suffix(const GFilename& filename) const
1777 1777 *
1778 1778 * $CTOOLS//share/help/
1779 1779 *
1780   - * of the ctools installation and the help file has the name "<name>.txt",
1781   - * where <name> stands for the name of the ctool.
  1780 + * of the ctools installation and the help file has the name "name().txt",
  1781 + * where name() stands for the name of the ctool.
1782 1782 ***************************************************************************/
1783 1783 void ctool::provide_help(void) const
1784 1784 {
... ...
test/test_ctbin.py
... ... @@ -104,9 +104,16 @@ class Test(test):
104 104 # Setup ctbin --help option
105 105 cmd = ctbin+' --help'
106 106  
107   - # Check if execution was successful
108   - self.test_assert(self._execute(cmd) == 0,
109   - 'Check successful execution from command line with --help option')
  107 + # Check if execution was successful in case that the CTOOLS
  108 + # environment variable was set or failed otherwise
  109 + if 'CTOOLS' in os.environ:
  110 + rc = 0
  111 + what = 'success'
  112 + else:
  113 + rc = 1
  114 + what = 'failure'
  115 + self.test_value(self._execute(cmd), rc,
  116 + 'Check execution %s from command line with --help option' % what)
110 117  
111 118 # Return
112 119 return
... ...
test/test_ctbkgcube.py
... ... @@ -104,6 +104,20 @@ class Test(test):
104 104 self.test_assert(self._execute(cmd) != 0,
105 105 'Check invalid input file when executed from command line')
106 106  
  107 + # Setup ctbkgcube --help option
  108 + cmd = ctbkgcube+' --help'
  109 +
  110 + # Check if execution was successful in case that the CTOOLS
  111 + # environment variable was set or failed otherwise
  112 + if 'CTOOLS' in os.environ:
  113 + rc = 0
  114 + what = 'success'
  115 + else:
  116 + rc = 1
  117 + what = 'failure'
  118 + self.test_value(self._execute(cmd), rc,
  119 + 'Check execution %s from command line with --help option' % what)
  120 +
107 121 # Return
108 122 return
109 123  
... ...
test/test_ctbutterfly.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import os
21 22 import gammalib
22 23 import ctools
23 24 from testing import test
... ... @@ -95,6 +96,20 @@ class Test(test):
95 96 self.test_assert(self._execute(cmd) != 0,
96 97 'Check invalid input file when executed from command line')
97 98  
  99 + # Setup ctbutterfly --help option
  100 + cmd = ctbutterfly+' --help'
  101 +
  102 + # Check if execution was successful in case that the CTOOLS
  103 + # environment variable was set or failed otherwise
  104 + if 'CTOOLS' in os.environ:
  105 + rc = 0
  106 + what = 'success'
  107 + else:
  108 + rc = 1
  109 + what = 'failure'
  110 + self.test_value(self._execute(cmd), rc,
  111 + 'Check execution %s from command line with --help option' % what)
  112 +
98 113 # Return
99 114 return
100 115  
... ...
test/test_ctcubemask.py
... ... @@ -99,6 +99,20 @@ class Test(test):
99 99 self.test_assert(self._execute(cmd) != 0,
100 100 'Check invalid input file when executed from command line')
101 101  
  102 + # Setup ctcubemask --help option
  103 + cmd = ctcubemask+' --help'
  104 +
  105 + # Check if execution was successful in case that the CTOOLS
  106 + # environment variable was set or failed otherwise
  107 + if 'CTOOLS' in os.environ:
  108 + rc = 0
  109 + what = 'success'
  110 + else:
  111 + rc = 1
  112 + what = 'failure'
  113 + self.test_value(self._execute(cmd), rc,
  114 + 'Check execution %s from command line with --help option' % what)
  115 +
102 116 # Return
103 117 return
104 118  
... ...
test/test_ctedispcube.py
... ... @@ -102,6 +102,20 @@ class Test(test):
102 102 self.test_assert(self._execute(cmd) != 0,
103 103 'Check invalid input file when executed from command line')
104 104  
  105 + # Setup ctedispcube --help option
  106 + cmd = ctedispcube+' --help'
  107 +
  108 + # Check if execution was successful in case that the CTOOLS
  109 + # environment variable was set or failed otherwise
  110 + if 'CTOOLS' in os.environ:
  111 + rc = 0
  112 + what = 'success'
  113 + else:
  114 + rc = 1
  115 + what = 'failure'
  116 + self.test_value(self._execute(cmd), rc,
  117 + 'Check execution %s from command line with --help option' % what)
  118 +
105 119 # Return
106 120 return
107 121  
... ...
test/test_cterror.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import os
21 22 import gammalib
22 23 import ctools
23 24 from testing import test
... ... @@ -93,6 +94,20 @@ class Test(test):
93 94 self.test_assert(self._execute(cmd) != 0,
94 95 'Check invalid input file when executed from command line')
95 96  
  97 + # Setup cterror --help option
  98 + cmd = cterror+' --help'
  99 +
  100 + # Check if execution was successful in case that the CTOOLS
  101 + # environment variable was set or failed otherwise
  102 + if 'CTOOLS' in os.environ:
  103 + rc = 0
  104 + what = 'success'
  105 + else:
  106 + rc = 1
  107 + what = 'failure'
  108 + self.test_value(self._execute(cmd), rc,
  109 + 'Check execution %s from command line with --help option' % what)
  110 +
96 111 # Return
97 112 return
98 113  
... ...
test/test_ctexpcube.py
... ... @@ -100,6 +100,20 @@ class Test(test):
100 100 self.test_assert(self._execute(cmd) != 0,
101 101 'Check invalid input file when executed from command line')
102 102  
  103 + # Setup ctexpcube --help option
  104 + cmd = ctexpcube+' --help'
  105 +
  106 + # Check if execution was successful in case that the CTOOLS
  107 + # environment variable was set or failed otherwise
  108 + if 'CTOOLS' in os.environ:
  109 + rc = 0
  110 + what = 'success'
  111 + else:
  112 + rc = 1
  113 + what = 'failure'
  114 + self.test_value(self._execute(cmd), rc,
  115 + 'Check execution %s from command line with --help option' % what)
  116 +
103 117 # Return
104 118 return
105 119  
... ...
test/test_ctlike.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import os
21 22 import gammalib
22 23 import ctools
23 24 from testing import test
... ... @@ -93,6 +94,20 @@ class Test(test):
93 94 self.test_assert(self._execute(cmd) != 0,
94 95 'Check invalid input file when executed from command line')
95 96  
  97 + # Setup ctlike --help option
  98 + cmd = ctlike+' --help'
  99 +
  100 + # Check if execution was successful in case that the CTOOLS
  101 + # environment variable was set or failed otherwise
  102 + if 'CTOOLS' in os.environ:
  103 + rc = 0
  104 + what = 'success'
  105 + else:
  106 + rc = 1
  107 + what = 'failure'
  108 + self.test_value(self._execute(cmd), rc,
  109 + 'Check execution %s from command line with --help option' % what)
  110 +
96 111 # Return
97 112 return
98 113  
... ...
test/test_ctmapcube.py
... ... @@ -100,6 +100,20 @@ class Test(test):
100 100 self.test_assert(self._execute(cmd) != 0,
101 101 'Check invalid input file when executed from command line')
102 102  
  103 + # Setup ctmapcube --help option
  104 + cmd = ctmapcube+' --help'
  105 +
  106 + # Check if execution was successful in case that the CTOOLS
  107 + # environment variable was set or failed otherwise
  108 + if 'CTOOLS' in os.environ:
  109 + rc = 0
  110 + what = 'success'
  111 + else:
  112 + rc = 1
  113 + what = 'failure'
  114 + self.test_value(self._execute(cmd), rc,
  115 + 'Check execution %s from command line with --help option' % what)
  116 +
103 117 # Return
104 118 return
105 119  
... ...
test/test_ctmodel.py
... ... @@ -104,6 +104,20 @@ class Test(test):
104 104 self.test_assert(self._execute(cmd) != 0,
105 105 'Check invalid input file when executed from command line')
106 106  
  107 + # Setup ctmodel --help option
  108 + cmd = ctmodel+' --help'
  109 +
  110 + # Check if execution was successful in case that the CTOOLS
  111 + # environment variable was set or failed otherwise
  112 + if 'CTOOLS' in os.environ:
  113 + rc = 0
  114 + what = 'success'
  115 + else:
  116 + rc = 1
  117 + what = 'failure'
  118 + self.test_value(self._execute(cmd), rc,
  119 + 'Check execution %s from command line with --help option' % what)
  120 +
107 121 # Return
108 122 return
109 123  
... ...
test/test_ctobssim.py
... ... @@ -102,6 +102,20 @@ class Test(test):
102 102 self.test_assert(self._execute(cmd) != 0,
103 103 'Check invalid input file when executed from command line')
104 104  
  105 + # Setup ctobssim --help option
  106 + cmd = ctobssim+' --help'
  107 +
  108 + # Check if execution was successful in case that the CTOOLS
  109 + # environment variable was set or failed otherwise
  110 + if 'CTOOLS' in os.environ:
  111 + rc = 0
  112 + what = 'success'
  113 + else:
  114 + rc = 1
  115 + what = 'failure'
  116 + self.test_value(self._execute(cmd), rc,
  117 + 'Check execution %s from command line with --help option' % what)
  118 +
105 119 # Return
106 120 return
107 121  
... ...
test/test_ctpsfcube.py
... ... @@ -102,6 +102,20 @@ class Test(test):
102 102 self.test_assert(self._execute(cmd) != 0,
103 103 'Check invalid input file when executed from command line')
104 104  
  105 + # Setup ctpsfcube --help option
  106 + cmd = ctpsfcube+' --help'
  107 +
  108 + # Check if execution was successful in case that the CTOOLS
  109 + # environment variable was set or failed otherwise
  110 + if 'CTOOLS' in os.environ:
  111 + rc = 0
  112 + what = 'success'
  113 + else:
  114 + rc = 1
  115 + what = 'failure'
  116 + self.test_value(self._execute(cmd), rc,
  117 + 'Check execution %s from command line with --help option' % what)
  118 +
105 119 # Return
106 120 return
107 121  
... ...
test/test_ctselect.py
... ... @@ -99,6 +99,20 @@ class Test(test):
99 99 self.test_assert(self._execute(cmd) != 0,
100 100 'Check invalid input file when executed from command line')
101 101  
  102 + # Setup ctselect --help option
  103 + cmd = ctselect+' --help'
  104 +
  105 + # Check if execution was successful in case that the CTOOLS
  106 + # environment variable was set or failed otherwise
  107 + if 'CTOOLS' in os.environ:
  108 + rc = 0
  109 + what = 'success'
  110 + else:
  111 + rc = 1
  112 + what = 'failure'
  113 + self.test_value(self._execute(cmd), rc,
  114 + 'Check execution %s from command line with --help option' % what)
  115 +
102 116 # Return
103 117 return
104 118  
... ...
test/test_ctskymap.py
... ... @@ -96,6 +96,20 @@ class Test(test):
96 96 self.test_assert(self._execute(cmd) != 0,
97 97 'Check invalid input file when executed from command line')
98 98  
  99 + # Setup ctskymap --help option
  100 + cmd = ctskymap+' --help'
  101 +
  102 + # Check if execution was successful in case that the CTOOLS
  103 + # environment variable was set or failed otherwise
  104 + if 'CTOOLS' in os.environ:
  105 + rc = 0
  106 + what = 'success'
  107 + else:
  108 + rc = 1
  109 + what = 'failure'
  110 + self.test_value(self._execute(cmd), rc,
  111 + 'Check execution %s from command line with --help option' % what)
  112 +
99 113 # Return
100 114 return
101 115  
... ...
test/test_cttsmap.py
... ... @@ -98,6 +98,20 @@ class Test(test):
98 98 self.test_assert(self._execute(cmd) != 0,
99 99 'Check invalid input file when executed from command line')
100 100  
  101 + # Setup cttsmap --help option
  102 + cmd = cttsmap+' --help'
  103 +
  104 + # Check if execution was successful in case that the CTOOLS
  105 + # environment variable was set or failed otherwise
  106 + if 'CTOOLS' in os.environ:
  107 + rc = 0
  108 + what = 'success'
  109 + else:
  110 + rc = 1
  111 + what = 'failure'
  112 + self.test_value(self._execute(cmd), rc,
  113 + 'Check execution %s from command line with --help option' % what)
  114 +
101 115 # Return
102 116 return
103 117  
... ...
test/test_ctulimit.py
... ... @@ -18,6 +18,7 @@
18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19 #
20 20 # ==========================================================================
  21 +import os
21 22 import gammalib
22 23 import ctools
23 24 from testing import test
... ... @@ -91,6 +92,20 @@ class Test(test):
91 92 self.test_assert(self._execute(cmd) != 0,
92 93 'Check invalid input file when executed from command line')
93 94  
  95 + # Setup ctulimit --help option
  96 + cmd = ctulimit+' --help'
  97 +
  98 + # Check if execution was successful in case that the CTOOLS
  99 + # environment variable was set or failed otherwise
  100 + if 'CTOOLS' in os.environ:
  101 + rc = 0
  102 + what = 'success'
  103 + else:
  104 + rc = 1
  105 + what = 'failure'
  106 + self.test_value(self._execute(cmd), rc,
  107 + 'Check execution %s from command line with --help option' % what)
  108 +
94 109 # Return
95 110 return
96 111  
... ...