1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 459197 - C++ Unit Testing does not work with QT5

- remove "-flush" from 
  QtTestsRunnerProvider.getAdditionalLaunchParameters which does
  not work on Qt5
- add support in QtXmlLogHandler to support QtBuild and Duration
  nodes (for Duration node store the duration time in the model)
- fix typo in QtTestsRunnerMessages.properties file

Change-Id: I3ae8a8cba6870857f2a779e317465573387c0dee
This commit is contained in:
Jeff Johnston 2017-05-05 20:00:42 -04:00 committed by Doug Schaefer
parent 9280202a2a
commit ec4e410c8b
3 changed files with 19 additions and 2 deletions

View file

@ -18,6 +18,6 @@ QtXmlLogHandler_metrics_unit_events=events
QtXmlLogHandler_metrics_unit_instructions=instr.
QtXmlLogHandler_metrics_unit_msec=msec
QtXmlLogHandler_metrics_unit_ticks=ticks
QtXmlLogHandler_unknown_benchmarck_metric=Benchmarck metric value "{0}" is not supported\!
QtXmlLogHandler_unknown_benchmarck_metric=Benchmark metric value "{0}" is not supported\!
QtXmlLogHandler_unknown_message_level=String "{0}" cannot be converted to a message level\!
QtXmlLogHandler_wrong_tag_name=Invalid XML format: Element "{0}" is not accepted\!

View file

@ -68,7 +68,6 @@ public class QtTestsRunnerProvider implements ITestsRunnerProvider {
public String[] getAdditionalLaunchParameters(String[][] testPaths) throws TestingException {
final String[] qtParameters = {
"-xml", //$NON-NLS-1$
"-flush", //$NON-NLS-1$
};
String[] result = qtParameters;

View file

@ -45,9 +45,11 @@ public class QtXmlLogHandler extends DefaultHandler {
private static final String XML_NODE_DESCRIPTION = "Description"; //$NON-NLS-1$
private static final String XML_NODE_ENVIRONMENT = "Environment"; //$NON-NLS-1$
private static final String XML_NODE_QTVERSION = "QtVersion"; //$NON-NLS-1$
private static final String XML_NODE_QTBUILD = "QtBuild"; //$NON-NLS-1$
private static final String XML_NODE_QTESTVERSION = "QTestVersion"; //$NON-NLS-1$
private static final String XML_NODE_BENCHMARK = "BenchmarkResult"; //$NON-NLS-1$
private static final String XML_NODE_DATATAG = "DataTag"; //$NON-NLS-1$
private static final String XML_NODE_DURATION = "Duration"; //$NON-NLS-1$
// Qt Test XML case statuses representation
private static final String XML_VALUE_INCIDENT_PASS = "pass"; //$NON-NLS-1$
@ -69,6 +71,7 @@ public class QtXmlLogHandler extends DefaultHandler {
// Qt Test XML log attributes
private static final String XML_ATTR_TEST_CASE_NAME = "name"; //$NON-NLS-1$
private static final String XML_ATTR_TEST_FUNCTION_NAME = "name"; //$NON-NLS-1$
private static final String XML_ATTR_MSECS = "msecs"; //$NON-NLS-1$
private static final String XML_ATTR_TYPE = "type"; //$NON-NLS-1$
private static final String XML_ATTR_FILE = "file"; //$NON-NLS-1$
private static final String XML_ATTR_LINE = "line"; //$NON-NLS-1$
@ -149,6 +152,9 @@ public class QtXmlLogHandler extends DefaultHandler {
/** Stores the message level for currently parsed test message. */
private ITestMessage.Level messageLevel;
/** Stores the duration in msecs for currently parsed test function. */
private int duration;
/** Stores the status for currently parsed test case. */
private ITestItem.Status testCaseStatus;
@ -265,6 +271,7 @@ public class QtXmlLogHandler extends DefaultHandler {
lastDataTag = ""; //$NON-NLS-1$
testCaseAdded = false;
testCaseStatus = ITestItem.Status.Passed;
duration = 0;
} else if (qName == XML_NODE_MESSAGE) {
String messageLevelStr = attrs.getValue(XML_ATTR_TYPE);
@ -283,6 +290,7 @@ public class QtXmlLogHandler extends DefaultHandler {
messageLevel = getMessageLevel(STRING_INCIDENT_TO_MESSAGE_LEVEL, strType);
messageText = null;
setCurrentTestCaseStatus(STRING_TO_TEST_STATUS.get(strType));
duration = 0;
} else if (qName == XML_NODE_BENCHMARK) {
lastDataTag = attrs.getValue(XML_ATTR_DATA_TAG);
@ -296,12 +304,17 @@ public class QtXmlLogHandler extends DefaultHandler {
)
);
} else if (qName == XML_NODE_DURATION) {
float msecs = Float.parseFloat(attrs.getValue(XML_ATTR_MSECS));
duration = Math.round(msecs);
} else if (qName == XML_NODE_DATATAG) {
lastDataTag = ""; //$NON-NLS-1$
} else if (qName == XML_NODE_DESCRIPTION
|| qName == XML_NODE_ENVIRONMENT
|| qName == XML_NODE_QTVERSION
|| qName == XML_NODE_QTBUILD
|| qName == XML_NODE_QTESTVERSION) {
/* just skip, do nothing */
@ -319,6 +332,9 @@ public class QtXmlLogHandler extends DefaultHandler {
} else if (qName == XML_NODE_TEST_FUNCTION) {
createTestCaseIfNecessary();
exitTestCaseIfNecessary();
if (duration != 0) {
modelUpdater.setTestingTime(duration);
}
} else if (qName == XML_NODE_DATATAG) {
lastDataTag = elementData;
@ -337,6 +353,8 @@ public class QtXmlLogHandler extends DefaultHandler {
} else if (qName == XML_NODE_ENVIRONMENT
|| qName == XML_NODE_QTVERSION
|| qName == XML_NODE_QTESTVERSION
|| qName == XML_NODE_QTBUILD
|| qName == XML_NODE_DURATION
|| qName == XML_NODE_BENCHMARK) {
/* just skip, do nothing */