Lines 1-7
Link Here
|
1 |
/* |
1 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 |
* |
3 |
* |
4 |
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. |
4 |
* Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved. |
5 |
* |
5 |
* |
6 |
* The contents of this file are subject to the terms of either the GNU |
6 |
* The contents of this file are subject to the terms of either the GNU |
7 |
* General Public License Version 2 only ("GPL") or the Common |
7 |
* General Public License Version 2 only ("GPL") or the Common |
Lines 75-82
Link Here
|
75 |
import static java.util.Calendar.MILLISECOND; |
75 |
import static java.util.Calendar.MILLISECOND; |
76 |
import static java.util.logging.Level.FINER; |
76 |
import static java.util.logging.Level.FINER; |
77 |
import static java.util.logging.Level.FINEST; |
77 |
import static java.util.logging.Level.FINEST; |
|
|
78 |
import static org.netbeans.modules.junit.output.RegexpUtils.ADD_ERROR_PREFIX; |
79 |
import static org.netbeans.modules.junit.output.RegexpUtils.ADD_FAILURE_PREFIX; |
78 |
import static org.netbeans.modules.junit.output.RegexpUtils.END_OF_TEST_PREFIX; |
80 |
import static org.netbeans.modules.junit.output.RegexpUtils.END_OF_TEST_PREFIX; |
79 |
import static org.netbeans.modules.junit.output.RegexpUtils.NESTED_EXCEPTION_PREFIX; |
|
|
80 |
import static org.netbeans.modules.junit.output.RegexpUtils.OUTPUT_DELIMITER_PREFIX; |
81 |
import static org.netbeans.modules.junit.output.RegexpUtils.OUTPUT_DELIMITER_PREFIX; |
81 |
import static org.netbeans.modules.junit.output.RegexpUtils.START_OF_TEST_PREFIX; |
82 |
import static org.netbeans.modules.junit.output.RegexpUtils.START_OF_TEST_PREFIX; |
82 |
import static org.netbeans.modules.junit.output.RegexpUtils.TESTCASE_PREFIX; |
83 |
import static org.netbeans.modules.junit.output.RegexpUtils.TESTCASE_PREFIX; |
Lines 107-112
Link Here
|
107 |
private static final String XML_FORMATTER_CLASS_NAME |
108 |
private static final String XML_FORMATTER_CLASS_NAME |
108 |
= "org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter";//NOI18N |
109 |
= "org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter";//NOI18N |
109 |
|
110 |
|
|
|
111 |
/** |
112 |
* Does Ant provide detailed information about the currently running test |
113 |
* and its output? |
114 |
*/ |
115 |
private boolean testListenerInfoAvailable = false; |
110 |
/** |
116 |
/** |
111 |
* number of tests to be executed in the current test suite |
117 |
* number of tests to be executed in the current test suite |
112 |
* |
118 |
* |
Lines 172-179
Link Here
|
172 |
/** */ |
178 |
/** */ |
173 |
private RegexpUtils regexp = RegexpUtils.getInstance(); |
179 |
private RegexpUtils regexp = RegexpUtils.getInstance(); |
174 |
|
180 |
|
175 |
/** */ |
181 |
///** */ |
176 |
private Report topReport; |
182 |
//private Report topReport; |
177 |
/** */ |
183 |
/** */ |
178 |
private Report report; |
184 |
private Report report; |
179 |
/** */ |
185 |
/** */ |
Lines 236-241
Link Here
|
236 |
progressLogger.finest("VERBOSE: " + msg); //NOI18N |
242 |
progressLogger.finest("VERBOSE: " + msg); //NOI18N |
237 |
} |
243 |
} |
238 |
if (msg.startsWith(TEST_LISTENER_PREFIX)) { |
244 |
if (msg.startsWith(TEST_LISTENER_PREFIX)) { |
|
|
245 |
if (report == null) { |
246 |
return; |
247 |
} |
248 |
testListenerInfoAvailable = true; |
239 |
String testListenerMsg = msg.substring(TEST_LISTENER_PREFIX.length()); |
249 |
String testListenerMsg = msg.substring(TEST_LISTENER_PREFIX.length()); |
240 |
if (testListenerMsg.startsWith(TESTS_COUNT_PREFIX)) { |
250 |
if (testListenerMsg.startsWith(TESTS_COUNT_PREFIX)) { |
241 |
String countStr = testListenerMsg.substring(TESTS_COUNT_PREFIX.length()); |
251 |
String countStr = testListenerMsg.substring(TESTS_COUNT_PREFIX.length()); |
Lines 252-278
Link Here
|
252 |
} |
262 |
} |
253 |
return; |
263 |
return; |
254 |
} |
264 |
} |
255 |
if (testListenerMsg.startsWith(START_OF_TEST_PREFIX)) { |
265 |
|
|
|
266 |
int leftBracketIndex = testListenerMsg.indexOf('('); |
267 |
if (leftBracketIndex == -1) { |
268 |
return; |
269 |
} |
270 |
|
271 |
final String shortMsg = testListenerMsg.substring(0, leftBracketIndex); |
272 |
if (shortMsg.equals(START_OF_TEST_PREFIX)) { |
273 |
boolean testStarted = false; |
256 |
String restOfMsg = testListenerMsg.substring(START_OF_TEST_PREFIX.length()); |
274 |
String restOfMsg = testListenerMsg.substring(START_OF_TEST_PREFIX.length()); |
257 |
if ((restOfMsg.length() == 0) |
275 |
if (restOfMsg.length() == 0) { |
258 |
|| !Character.isLetterOrDigit(restOfMsg.charAt(0))) { |
276 |
testStarted = true; |
|
|
277 |
} else { |
278 |
char firstChar = restOfMsg.charAt(0); |
279 |
char lastChar = restOfMsg.charAt(restOfMsg.length() - 1); |
280 |
if ((firstChar == '(') && (lastChar == ')')) { |
281 |
testcase = new Report.Testcase(); |
282 |
testcase.name = restOfMsg.substring(1, restOfMsg.length() - 1); |
283 |
testcase.timeMillis = Report.Testcase.NOT_FINISHED_YET; |
284 |
testStarted = true; |
285 |
} else if (!Character.isLetterOrDigit(firstChar)) { |
286 |
testStarted = true; |
287 |
} |
288 |
} |
289 |
if (testStarted) { |
259 |
progressLogger.finest("test started"); //NOI18N |
290 |
progressLogger.finest("test started"); //NOI18N |
260 |
} |
291 |
} |
261 |
return; |
292 |
return; |
262 |
} |
293 |
} |
263 |
if (testListenerMsg.startsWith(END_OF_TEST_PREFIX)) { |
294 |
if (shortMsg.equals(END_OF_TEST_PREFIX)) { |
|
|
295 |
boolean testFinished = false; |
264 |
String restOfMsg = testListenerMsg.substring(END_OF_TEST_PREFIX.length()); |
296 |
String restOfMsg = testListenerMsg.substring(END_OF_TEST_PREFIX.length()); |
265 |
if ((restOfMsg.length() == 0) |
297 |
if (restOfMsg.length() == 0) { |
266 |
|| !Character.isLetterOrDigit(restOfMsg.charAt(0))) { |
298 |
testFinished = true; |
267 |
progressLogger.finest("test finished"); //NOI18N |
299 |
} else { |
|
|
300 |
char firstChar = restOfMsg.charAt(0); |
301 |
char lastChar = restOfMsg.charAt(restOfMsg.length() - 1); |
302 |
if ((firstChar == '(') && (lastChar == ')')) { |
303 |
String name = restOfMsg.substring(1, restOfMsg.length() - 1); |
304 |
if (name.equals(testcase.name)) { |
305 |
testFinished = true; |
306 |
} |
307 |
} else if (!Character.isLetterOrDigit(firstChar)) { |
308 |
testFinished = true; |
309 |
} |
310 |
} |
311 |
if (testFinished) { |
312 |
if (testcase != null) { |
313 |
testcase.timeMillis = Report.Testcase.TIME_UNKNOWN; |
314 |
report.reportTest(testcase); |
315 |
testcase = null; |
316 |
} |
268 |
executedOneSuiteTests++; |
317 |
executedOneSuiteTests++; |
269 |
if (expectedOneSuiteTests < executedOneSuiteTests) { |
318 |
if (expectedOneSuiteTests < executedOneSuiteTests) { |
270 |
expectedOneSuiteTests = executedOneSuiteTests; |
319 |
expectedOneSuiteTests = executedOneSuiteTests; |
271 |
} |
320 |
} |
|
|
321 |
progressLogger.finest("test finished"); //NOI18N |
272 |
updateProgress(); |
322 |
updateProgress(); |
273 |
} |
323 |
} |
274 |
return; |
324 |
return; |
275 |
} |
325 |
} |
|
|
326 |
if (shortMsg.equals(ADD_FAILURE_PREFIX) |
327 |
|| shortMsg.equals(ADD_ERROR_PREFIX)) { |
328 |
if (testcase == null) { |
329 |
return; |
330 |
} |
331 |
int lastCharIndex = testListenerMsg.length() - 1; |
332 |
if (testListenerMsg.charAt(lastCharIndex) != ')') { |
333 |
return; |
334 |
} |
335 |
String insideBrackets = testListenerMsg.substring( |
336 |
shortMsg.length() + 1, |
337 |
lastCharIndex); |
338 |
int commaIndex = insideBrackets.indexOf(','); |
339 |
String testName = (commaIndex == -1) |
340 |
? insideBrackets |
341 |
: insideBrackets.substring(0, commaIndex); |
342 |
if (!testName.equals(testcase.className)) { |
343 |
return; |
344 |
} |
345 |
testcase.trouble = new Report.Trouble(shortMsg.equals(ADD_ERROR_PREFIX)); |
346 |
if (commaIndex != -1) { |
347 |
int errMsgStart; |
348 |
if (Character.isSpaceChar(insideBrackets.charAt(commaIndex + 1))) { |
349 |
errMsgStart = commaIndex + 2; |
350 |
} else { |
351 |
errMsgStart = commaIndex + 1; |
352 |
} |
353 |
testcase.trouble.message = insideBrackets.substring(errMsgStart); |
354 |
} |
355 |
} |
356 |
return; |
276 |
} |
357 |
} |
277 |
|
358 |
|
278 |
/* Look for classpaths: */ |
359 |
/* Look for classpaths: */ |
Lines 312-317
Link Here
|
312 |
progressLogger.finest("NORMAL: " + msg); //NOI18N |
393 |
progressLogger.finest("NORMAL: " + msg); //NOI18N |
313 |
} |
394 |
} |
314 |
|
395 |
|
|
|
396 |
if (testListenerInfoAvailable |
397 |
&& (report != null) && !report.isSuiteFinished() |
398 |
&& (testcase != null)) { |
399 |
displayOutput(msg, event.getLogLevel() == AntEvent.LOG_WARN); |
400 |
return; |
401 |
} |
402 |
|
315 |
//<editor-fold defaultstate="collapsed" desc="if (waitingForIssueStatus) ..."> |
403 |
//<editor-fold defaultstate="collapsed" desc="if (waitingForIssueStatus) ..."> |
316 |
if (waitingForIssueStatus) { |
404 |
if (waitingForIssueStatus) { |
317 |
assert testcase != null; |
405 |
assert testcase != null; |
Lines 433-438
Link Here
|
433 |
if (matcher.matches()) { |
521 |
if (matcher.matches()) { |
434 |
assert report != null; |
522 |
assert report != null; |
435 |
|
523 |
|
|
|
524 |
report.markSuiteFinished(); |
436 |
try { |
525 |
try { |
437 |
report.totalTests = Integer.parseInt(matcher.group(1)); |
526 |
report.totalTests = Integer.parseInt(matcher.group(1)); |
438 |
report.failures = Integer.parseInt(matcher.group(2)); |
527 |
report.failures = Integer.parseInt(matcher.group(2)); |
Lines 457-463
Link Here
|
457 |
} |
546 |
} |
458 |
//</editor-fold> |
547 |
//</editor-fold> |
459 |
//<editor-fold defaultstate="collapsed" desc="output"> |
548 |
//<editor-fold defaultstate="collapsed" desc="output"> |
460 |
else { |
549 |
else if (!testListenerInfoAvailable) { |
461 |
displayOutput(msg, |
550 |
displayOutput(msg, |
462 |
event.getLogLevel() == AntEvent.LOG_WARN); |
551 |
event.getLogLevel() == AntEvent.LOG_WARN); |
463 |
} |
552 |
} |
Lines 736-753
Link Here
|
736 |
// |
825 |
// |
737 |
isDeterminateProgress = willBeDeterminateProgress; |
826 |
isDeterminateProgress = willBeDeterminateProgress; |
738 |
|
827 |
|
739 |
Manager.getInstance().testStarted(session, |
828 |
manager.testStarted(session, sessionType); |
740 |
sessionType); |
|
|
741 |
} |
829 |
} |
742 |
|
830 |
|
743 |
/** |
831 |
/** |
744 |
*/ |
832 |
*/ |
745 |
void testTaskFinished() { |
833 |
void testTaskFinished() { |
746 |
if (waitingForIssueStatus) { |
|
|
747 |
assert testcase != null; |
748 |
|
749 |
report.reportTest(testcase); |
750 |
} |
751 |
closePreviousReport(); |
834 |
closePreviousReport(); |
752 |
|
835 |
|
753 |
progressLogger.finer("ACTUAL # OF SUITES: " + executedSuitesCount); |
836 |
progressLogger.finer("ACTUAL # OF SUITES: " + executedSuitesCount); |
Lines 869-876
Link Here
|
869 |
void buildFinished(final AntEvent event) { |
952 |
void buildFinished(final AntEvent event) { |
870 |
try { |
953 |
try { |
871 |
buildFinished(event.getException()); |
954 |
buildFinished(event.getException()); |
872 |
Manager.getInstance().sessionFinished(session, |
955 |
|
873 |
sessionType); |
956 |
if (report != null) { |
|
|
957 |
closePreviousReport(true); //true ... interrupted |
958 |
} |
959 |
|
960 |
manager.sessionFinished(session, sessionType); |
874 |
} finally { |
961 |
} finally { |
875 |
progressHandle.finish(); |
962 |
progressHandle.finish(); |
876 |
} |
963 |
} |
Lines 898-918
Link Here
|
898 |
progressHandle.progress(stepMessage); |
985 |
progressHandle.progress(stepMessage); |
899 |
} |
986 |
} |
900 |
|
987 |
|
901 |
Manager.getInstance().displaySuiteRunning(session, |
988 |
manager.displaySuiteRunning(session, sessionType, suiteName); |
902 |
sessionType, |
|
|
903 |
suiteName); |
904 |
return report; |
989 |
return report; |
905 |
} |
990 |
} |
906 |
|
991 |
|
907 |
/** |
992 |
/** |
908 |
*/ |
993 |
*/ |
909 |
private void suiteFinished(final Report report) { |
994 |
private void suiteFinished(final Report report, boolean interrupted) { |
910 |
if (progressLogger.isLoggable(FINER)) { |
995 |
if (progressLogger.isLoggable(FINER)) { |
911 |
progressLogger.finer("actual # of tests in a suite: " + executedOneSuiteTests); |
996 |
progressLogger.finer("actual # of tests in a suite: " + executedOneSuiteTests); |
912 |
} |
997 |
} |
913 |
executedSuitesCount++; |
998 |
executedSuitesCount++; |
914 |
|
999 |
|
915 |
Manager.getInstance().displayReport(session, sessionType, report); |
1000 |
manager.displayReport(session, sessionType, report); |
916 |
} |
1001 |
} |
917 |
|
1002 |
|
918 |
private void buildFinished(final Throwable exception) { |
1003 |
private void buildFinished(final Throwable exception) { |
Lines 951-957
Link Here
|
951 |
/** |
1036 |
/** |
952 |
*/ |
1037 |
*/ |
953 |
private void displayOutput(final String text, final boolean error) { |
1038 |
private void displayOutput(final String text, final boolean error) { |
954 |
Manager.getInstance().displayOutput(session, sessionType, text, error); |
1039 |
manager.displayOutput(session, sessionType, text, error); |
955 |
} |
1040 |
} |
956 |
|
1041 |
|
957 |
//-------------------------------------------------------- |
1042 |
//-------------------------------------------------------- |
Lines 959-973
Link Here
|
959 |
/** |
1044 |
/** |
960 |
*/ |
1045 |
*/ |
961 |
private boolean tryParsePlainHeader(String testcaseHeader) { |
1046 |
private boolean tryParsePlainHeader(String testcaseHeader) { |
|
|
1047 |
assert report != null; |
962 |
final Matcher matcher = regexp.getTestcaseHeaderPlainPattern() |
1048 |
final Matcher matcher = regexp.getTestcaseHeaderPlainPattern() |
963 |
.matcher(testcaseHeader); |
1049 |
.matcher(testcaseHeader); |
964 |
if (matcher.matches()) { |
1050 |
if (matcher.matches()) { |
965 |
String methodName = matcher.group(1); |
1051 |
String methodName = matcher.group(1); |
966 |
int timeMillis = regexp.parseTimeMillisNoNFE(matcher.group(2)); |
1052 |
int timeMillis = regexp.parseTimeMillisNoNFE(matcher.group(2)); |
967 |
|
1053 |
|
968 |
testcase = new Report.Testcase(); |
1054 |
testcase = report.findTest(methodName, true); |
969 |
testcase.className = null; |
1055 |
testcase.className = null; |
970 |
testcase.name = methodName; |
|
|
971 |
testcase.timeMillis = timeMillis; |
1056 |
testcase.timeMillis = timeMillis; |
972 |
|
1057 |
|
973 |
trouble = null; |
1058 |
trouble = null; |
Lines 982-987
Link Here
|
982 |
/** |
1067 |
/** |
983 |
*/ |
1068 |
*/ |
984 |
private boolean tryParseBriefHeader(String testcaseHeader) { |
1069 |
private boolean tryParseBriefHeader(String testcaseHeader) { |
|
|
1070 |
assert report != null; |
985 |
final Matcher matcher = regexp.getTestcaseHeaderBriefPattern() |
1071 |
final Matcher matcher = regexp.getTestcaseHeaderBriefPattern() |
986 |
.matcher(testcaseHeader); |
1072 |
.matcher(testcaseHeader); |
987 |
if (matcher.matches()) { |
1073 |
if (matcher.matches()) { |
Lines 989-997
Link Here
|
989 |
String clsName = matcher.group(2); |
1075 |
String clsName = matcher.group(2); |
990 |
boolean error = (matcher.group(3) == null); |
1076 |
boolean error = (matcher.group(3) == null); |
991 |
|
1077 |
|
992 |
testcase = new Report.Testcase(); |
1078 |
testcase = report.findTest(methodName, true); |
993 |
testcase.className = clsName; |
1079 |
testcase.className = clsName; |
994 |
testcase.name = methodName; |
|
|
995 |
testcase.timeMillis = -1; |
1080 |
testcase.timeMillis = -1; |
996 |
|
1081 |
|
997 |
trouble = (testcase.trouble = new Report.Trouble(error)); |
1082 |
trouble = (testcase.trouble = new Report.Trouble(error)); |
Lines 1002-1010
Link Here
|
1002 |
} |
1087 |
} |
1003 |
} |
1088 |
} |
1004 |
|
1089 |
|
1005 |
/** |
|
|
1006 |
*/ |
1007 |
private void closePreviousReport() { |
1090 |
private void closePreviousReport() { |
|
|
1091 |
closePreviousReport(false); |
1092 |
} |
1093 |
|
1094 |
private void closePreviousReport(boolean interrupted) { |
1008 |
if (xmlOutputBuffer != null) { |
1095 |
if (xmlOutputBuffer != null) { |
1009 |
try { |
1096 |
try { |
1010 |
String xmlOutput = xmlOutputBuffer.toString(); |
1097 |
String xmlOutput = xmlOutputBuffer.toString(); |
Lines 1019-1029
Link Here
|
1019 |
assert false; //should not happen (StringReader) |
1106 |
assert false; //should not happen (StringReader) |
1020 |
} |
1107 |
} |
1021 |
} else if ((report != null) && (report.resultsDir != null)) { |
1108 |
} else if ((report != null) && (report.resultsDir != null)) { |
|
|
1109 |
|
1110 |
if (waitingForIssueStatus) { |
1111 |
assert testcase != null; |
1112 |
report.reportTest(testcase); |
1113 |
} |
1114 |
|
1022 |
/* |
1115 |
/* |
1023 |
* We have parsed the output but it seems that we also have |
1116 |
* We have parsed the output but it seems that we also have |
1024 |
* an XML report file available - let's use it: |
1117 |
* an XML report file available - let's use it: |
1025 |
*/ |
1118 |
*/ |
1026 |
|
|
|
1027 |
File reportFile = new File( |
1119 |
File reportFile = new File( |
1028 |
report.resultsDir, |
1120 |
report.resultsDir, |
1029 |
"TEST-" + report.suiteClassName + ".xml");//NOI18N |
1121 |
"TEST-" + report.suiteClassName + ".xml");//NOI18N |
Lines 1060-1066
Link Here
|
1060 |
} |
1152 |
} |
1061 |
} |
1153 |
} |
1062 |
if (report != null) { |
1154 |
if (report != null) { |
1063 |
suiteFinished(report); |
1155 |
suiteFinished(report, interrupted); |
1064 |
} |
1156 |
} |
1065 |
|
1157 |
|
1066 |
xmlOutputBuffer = null; |
1158 |
xmlOutputBuffer = null; |