Bug #1746

XML test report not written in case of exception

Added by Knödlseder Jürgen almost 8 years ago. Updated almost 8 years ago.

Status:ClosedStart date:03/16/2016
Priority:HighDue date:
Assigned To:Knödlseder Jürgen% Done:


Target version:1.1.0


If an exception occurs in a unit test, the test report is not written and the following in displayed on the screen:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/gamma/lib/python2.6/site-packages/cscripts/__init__.py", line 83, in test
  File "/usr/local/gamma/lib/python2.6/site-packages/cscripts/tests/test_python_cscripts.py", line 99, in test
  File "/usr/local/gamma/lib/python2.6/site-packages/gammalib/test.py", line 262, in save
    return _test.GTestSuites_save(self, *args)
RuntimeError: *** ERROR in GXmlAttribute::value(std::string): Invalid XML attribute value: *** ERROR in GPythonTestSuite::test: <type 'exceptions.RuntimeError'>
*** ERROR in GCaldb::path(std::string&, std::string&): Directory "caldb/data/cta" not found. Requested mission "CTA" not found in calibration database.

It looks as if the XML attribute has an invalid value.


No recurrence.


#1 Updated by Knödlseder Jürgen almost 8 years ago

It looks like the problem is related to the code in GXmlAttribute::value(std::string value) that attempts adding hyphens around the XML code. This code is probably obsolete since the GXmlAttribute::write(GUrl& url) method writes the value using the gammalib::str2xml(value) function that converts all hyphens into special characters:

    // Get value without quotation marks
    std::string value = m_value.substr(1, m_value.length()-2);

    // Convert value to XML format
    value = "\""+gammalib::str2xml(value)+"\"";

    // Write attribute into URL
    url.printf(" %s=%s", m_name.c_str(), value.c_str());

Probably the best thing would be to store the value without hyphens. GXmlAttribute::value(std::string value) should eventually strips leading and trailing hyphens before storing the value.

#2 Updated by Knödlseder Jürgen almost 8 years ago

  • Assigned To set to Knödlseder Jürgen
  • Priority changed from Normal to High
  • Target version set to 1.1.0

#3 Updated by Knödlseder Jürgen almost 8 years ago

  • Status changed from New to Closed

I changed the logic in the GXmlAttribute class so that the hyphens are no longer stored but stripped upon construction, and put back when the write() method is called. The value() methods get and set the attribute without any hyphens.

This logic, which needed a few minor further code adjustments, now leads to a proper recording of unit test exceptions in the XML report.

Changed merged into devel.

Also available in: Atom PDF