Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonah Graham2018-11-20 16:20:42 +0000
committerJonah Graham2018-11-22 21:47:02 +0000
commit170e654b4796bad1453ae85a427b97317d67a69a (patch)
tree6ca9b8a8fedd5fd25f97eb79c408312e256ff981 /testsrunner/org.eclipse.cdt.testsrunner.gtest
parent35996a5c5ca5c254959ba48241eaada6dbf8628d (diff)
downloadorg.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.tar.gz
org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.tar.xz
org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.zip
Bug 540373: Cleanup: Format & Remove trailing whitespace
This was done by selecting all projects in Eclipse then Source -> Clean Up... -> choosing: - Format source code - Remove trailing white spaces on all lines and completing the wizard Change-Id: I63685372c6bcc67719bcf145123bcb72e5b00394
Diffstat (limited to 'testsrunner/org.eclipse.cdt.testsrunner.gtest')
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.gtest/src/org/eclipse/cdt/testsrunner/internal/gtest/GoogleTestsRunnerPlugin.java10
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.gtest/src/org/eclipse/cdt/testsrunner/internal/gtest/GoogleTestsRunnerProvider.java28
-rw-r--r--testsrunner/org.eclipse.cdt.testsrunner.gtest/src/org/eclipse/cdt/testsrunner/internal/gtest/OutputHandler.java318
3 files changed, 161 insertions, 195 deletions
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.gtest/src/org/eclipse/cdt/testsrunner/internal/gtest/GoogleTestsRunnerPlugin.java b/testsrunner/org.eclipse.cdt.testsrunner.gtest/src/org/eclipse/cdt/testsrunner/internal/gtest/GoogleTestsRunnerPlugin.java
index 129606d1a9b..ce386206c1e 100644
--- a/testsrunner/org.eclipse.cdt.testsrunner.gtest/src/org/eclipse/cdt/testsrunner/internal/gtest/GoogleTestsRunnerPlugin.java
+++ b/testsrunner/org.eclipse.cdt.testsrunner.gtest/src/org/eclipse/cdt/testsrunner/internal/gtest/GoogleTestsRunnerPlugin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Anton Gorenkov
+ * Copyright (c) 2011, 2012 Anton Gorenkov
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -17,7 +17,6 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
-
/**
* The activator class controls the plug-in life cycle
*/
@@ -29,7 +28,6 @@ public class GoogleTestsRunnerPlugin extends Plugin {
/** Plug-in instance. */
private static GoogleTestsRunnerPlugin plugin;
-
public GoogleTestsRunnerPlugin() {
super();
plugin = this;
@@ -37,7 +35,7 @@ public class GoogleTestsRunnerPlugin extends Plugin {
/**
* Returns the Boost Tests Runner provider plug-in instance.
- *
+ *
* @return the plug-in instance
*/
public static GoogleTestsRunnerPlugin getDefault() {
@@ -51,7 +49,7 @@ public class GoogleTestsRunnerPlugin extends Plugin {
/**
* Logs the specified status with this plug-in's log.
- *
+ *
* @param status status to log
*/
public static void log(IStatus status) {
@@ -60,7 +58,7 @@ public class GoogleTestsRunnerPlugin extends Plugin {
/**
* Logs an internal error with the specified throwable
- *
+ *
* @param e the exception to be logged
*/
public static void log(Throwable e) {
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.gtest/src/org/eclipse/cdt/testsrunner/internal/gtest/GoogleTestsRunnerProvider.java b/testsrunner/org.eclipse.cdt.testsrunner.gtest/src/org/eclipse/cdt/testsrunner/internal/gtest/GoogleTestsRunnerProvider.java
index 6b7af420414..9933322411c 100644
--- a/testsrunner/org.eclipse.cdt.testsrunner.gtest/src/org/eclipse/cdt/testsrunner/internal/gtest/GoogleTestsRunnerProvider.java
+++ b/testsrunner/org.eclipse.cdt.testsrunner.gtest/src/org/eclipse/cdt/testsrunner/internal/gtest/GoogleTestsRunnerProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Anton Gorenkov
+ * Copyright (c) 2011, 2012 Anton Gorenkov
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -21,26 +21,23 @@ import org.eclipse.cdt.testsrunner.launcher.ITestsRunnerProvider;
import org.eclipse.cdt.testsrunner.model.ITestModelUpdater;
import org.eclipse.cdt.testsrunner.model.TestingException;
-
/**
* The Tests Runner provider plug-in to run tests with Google Testing framework.
- *
+ *
* Parses the text test module to output and provides the data for the Tests
* Runner Plug-In.
*/
public class GoogleTestsRunnerProvider implements ITestsRunnerProvider {
-
+
private static final String TEST_PATHS_DELIMITED = ":"; //$NON-NLS-1$
private static final String TEST_PATH_PARTS_DELIMITED = "."; //$NON-NLS-1$
- private static final String ALL_TESTS= ".*"; //$NON-NLS-1$
+ private static final String ALL_TESTS = ".*"; //$NON-NLS-1$
-
@Override
public String[] getAdditionalLaunchParameters(String[][] testPaths) {
- final String[] gtestParameters = {
- "--gtest_repeat=1", //$NON-NLS-1$
- "--gtest_print_time=1", //$NON-NLS-1$
- "--gtest_color=no", //$NON-NLS-1$
+ final String[] gtestParameters = { "--gtest_repeat=1", //$NON-NLS-1$
+ "--gtest_print_time=1", //$NON-NLS-1$
+ "--gtest_color=no", //$NON-NLS-1$
};
String[] result = gtestParameters;
@@ -74,10 +71,10 @@ public class GoogleTestsRunnerProvider implements ITestsRunnerProvider {
}
return result;
}
-
+
/**
* Construct the error message from prefix and detailed description.
- *
+ *
* @param prefix prefix
* @param description detailed description
* @return the full message
@@ -85,15 +82,16 @@ public class GoogleTestsRunnerProvider implements ITestsRunnerProvider {
private String getErrorText(String prefix, String description) {
return MessageFormat.format(GoogleTestsRunnerMessages.GoogleTestsRunner_error_format, prefix, description);
}
-
+
@Override
public void run(ITestModelUpdater modelUpdater, InputStream inputStream) throws TestingException {
-
+
try {
OutputHandler ouputHandler = new OutputHandler(modelUpdater);
ouputHandler.run(inputStream);
} catch (IOException e) {
- throw new TestingException(getErrorText(GoogleTestsRunnerMessages.GoogleTestsRunner_io_error_prefix, e.getLocalizedMessage()));
+ throw new TestingException(
+ getErrorText(GoogleTestsRunnerMessages.GoogleTestsRunner_io_error_prefix, e.getLocalizedMessage()));
}
}
diff --git a/testsrunner/org.eclipse.cdt.testsrunner.gtest/src/org/eclipse/cdt/testsrunner/internal/gtest/OutputHandler.java b/testsrunner/org.eclipse.cdt.testsrunner.gtest/src/org/eclipse/cdt/testsrunner/internal/gtest/OutputHandler.java
index 992f4434169..e1b690fb40b 100644
--- a/testsrunner/org.eclipse.cdt.testsrunner.gtest/src/org/eclipse/cdt/testsrunner/internal/gtest/OutputHandler.java
+++ b/testsrunner/org.eclipse.cdt.testsrunner.gtest/src/org/eclipse/cdt/testsrunner/internal/gtest/OutputHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Anton Gorenkov
+ * Copyright (c) 2011, 2012 Anton Gorenkov
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -29,7 +29,6 @@ import org.eclipse.cdt.testsrunner.model.ITestMessage;
import org.eclipse.cdt.testsrunner.model.TestingException;
import org.xml.sax.SAXException;
-
/**
* <p>
* Parses the output of Google Testing Framework and notifies the Tests Runner
@@ -49,34 +48,34 @@ import org.xml.sax.SAXException;
* </p>
*/
public class OutputHandler {
-
+
/**
* Base class for the FSM internal state.
*/
class State {
-
+
/** Stores the regular expression by which the state should be entered. */
private Pattern enterPattern;
-
+
/** The regular expression matcher. */
private Matcher matcher;
-
+
/** Groups count in a regular expression. */
private int groupCount;
-
+
/**
* The constructor.
- *
+ *
* @param enterRegex the regular expression by which the state should be
* entered
*/
State(String enterRegex) {
this(enterRegex, -1);
}
-
+
/**
* The constructor.
- *
+ *
* @param enterRegex the regular expression by which the state should be
* entered
* @param groupCount groups count in a regular expression. It is used
@@ -86,11 +85,11 @@ public class OutputHandler {
enterPattern = Pattern.compile(enterRegex);
this.groupCount = groupCount;
}
-
+
/**
* Checks whether the specified string matches the enter pattern
* (regular expression). If it is so the state should be entered.
- *
+ *
* @param line input line (token)
* @return true if matches and false otherwise
* @throws TestingException if groups count does not match the defined
@@ -100,12 +99,8 @@ public class OutputHandler {
matcher = enterPattern.matcher(line);
boolean groupsCountOk = groupCount == -1 || matcher.groupCount() == groupCount;
if (!groupsCountOk) {
- generateInternalError(
- MessageFormat.format(
- GoogleTestsRunnerMessages.OutputHandler_wrong_groups_count,
- enterPattern.pattern(), matcher.groupCount(), groupCount
- )
- );
+ generateInternalError(MessageFormat.format(GoogleTestsRunnerMessages.OutputHandler_wrong_groups_count,
+ enterPattern.pattern(), matcher.groupCount(), groupCount));
}
boolean matches = matcher.matches();
if (!matches || !groupsCountOk) {
@@ -114,37 +109,39 @@ public class OutputHandler {
}
return matches;
}
-
+
/**
* Returns the matched group value by index.
- *
+ *
* @param groupNumber group index
* @return group value
*/
protected String group(int groupNumber) {
return matcher.group(groupNumber);
}
-
+
/**
* Action that triggers on state enter.
- *
+ *
* @param previousState previous state
* @throws TestingException if testing error is detected
*/
- public void onEnter(State previousState) throws TestingException {}
+ public void onEnter(State previousState) throws TestingException {
+ }
/**
* Action that triggers on state exit.
- *
+ *
* @param previousState next state
* @throws TestingException if testing error is detected
*/
- public void onExit(State nextState) {}
-
+ public void onExit(State nextState) {
+ }
+
/**
* Common routine that constructs full test suite name by name and type
* parameter.
- *
+ *
* @param name test suite name
* @param typeParameter type parameter
* @return full test suite name
@@ -153,16 +150,15 @@ public class OutputHandler {
return (typeParameter != null) ? MessageFormat.format("{0}({1})", name, typeParameter.trim()) : name; //$NON-NLS-1$
}
}
-
-
+
/**
* The state is activated when a new test suite is started.
*/
class TestSuiteStart extends State {
-
+
/** Stores the matched type parameter. */
private String typeParameter;
-
+
TestSuiteStart(String enterRegex, int groupCount) {
super(enterRegex, groupCount);
}
@@ -176,23 +172,22 @@ public class OutputHandler {
typeParameter = group(3);
modelUpdater.enterTestSuite(getTestSuiteName(group(1), typeParameter));
}
-
+
/**
* Provides access to the matched type parameter.
- *
+ *
* @return type parameter value
*/
public String getTypeParameter() {
return typeParameter;
}
}
-
-
+
/**
* The state is activated when a new test case is started.
*/
class TestCaseStart extends State {
-
+
TestCaseStart(String enterRegex, int groupCount) {
super(enterRegex, groupCount);
}
@@ -200,7 +195,7 @@ public class OutputHandler {
/**
* Extract current test case and test suite names and notify Tests
* Runner Core about test case start.
- *
+ *
* @throws TestingException if extracted test suite name does not match
* last entered test suite name.
*/
@@ -210,36 +205,31 @@ public class OutputHandler {
String lastTestSuiteName = modelUpdater.currentTestSuite().getName();
String currTestSuiteName = getTestSuiteName(group(1), stateTestSuiteStart.getTypeParameter());
if (!lastTestSuiteName.equals(currTestSuiteName)) {
- generateInternalError(
- MessageFormat.format(
- GoogleTestsRunnerMessages.OutputHandler_wrong_suite_name,
- testCaseName, currTestSuiteName, lastTestSuiteName
- )
- );
+ generateInternalError(MessageFormat.format(GoogleTestsRunnerMessages.OutputHandler_wrong_suite_name,
+ testCaseName, currTestSuiteName, lastTestSuiteName));
}
modelUpdater.enterTestCase(testCaseName);
}
}
-
/**
* The state is activated when an error message's location is started.
*/
class ErrorMessageLocation extends State {
-
+
/** Stores the message location file name. */
private String messageFileName;
/** Stores the message location line number. */
private int messageLineNumber;
-
+
/** Stores the first part of the message. */
private String messagePart;
-
+
ErrorMessageLocation(String enterRegex, int groupCount) {
super(enterRegex, groupCount);
}
-
+
/**
* Extract the data for the message location (file name, line number).
* The data may be provided in a common style ("/path/file:line" with
@@ -247,7 +237,7 @@ public class OutputHandler {
* ("/path/file(line):" with the message text continuing on the same
* line). It is also possible not to specify line number at all
* ("/path/file:").
- *
+ *
* @throws TestingException if location format cannot be recognized.
*/
@Override
@@ -283,36 +273,35 @@ public class OutputHandler {
// NOTE: For Visual Studio style there is also first part of the message at this line
messagePart = group(8);
}
-
+
/**
* Provides access to the message location file name.
- *
+ *
* @return file name
*/
public String getMessageFileName() {
return messageFileName;
}
-
+
/**
* Provides access to the message location line number.
- *
+ *
* @return line number
*/
public int getMessageLineNumber() {
return messageLineNumber;
}
-
+
/**
* Provides access to the first part of the message.
- *
+ *
* @return message part
*/
public String getMessagePart() {
return messagePart;
}
}
-
-
+
/**
* The state is activated when an error message text is started or continued.
*/
@@ -352,23 +341,19 @@ public class OutputHandler {
@Override
public void onExit(State nextState) {
if (this != nextState) {
- modelUpdater.addTestMessage(
- stateErrorMessageLocation.getMessageFileName(),
- stateErrorMessageLocation.getMessageLineNumber(),
- ITestMessage.Level.Error,
- messagePart.toString()
- );
+ modelUpdater.addTestMessage(stateErrorMessageLocation.getMessageFileName(),
+ stateErrorMessageLocation.getMessageLineNumber(), ITestMessage.Level.Error,
+ messagePart.toString());
messagePart.setLength(0);
}
}
}
-
/**
* The state is activated when a test trace is started or continued.
*/
class TestTrace extends ErrorMessageLocation {
-
+
TestTrace(String enterRegex, int groupCount) {
super(enterRegex, groupCount);
}
@@ -380,15 +365,10 @@ public class OutputHandler {
@Override
public void onEnter(State previousState) throws TestingException {
super.onEnter(previousState);
- modelUpdater.addTestMessage(
- getMessageFileName(),
- getMessageLineNumber(),
- ITestMessage.Level.Info,
- getMessagePart()
- );
+ modelUpdater.addTestMessage(getMessageFileName(), getMessageLineNumber(), ITestMessage.Level.Info,
+ getMessagePart());
}
}
-
/**
* The state is activated when a test case is finished.
@@ -398,11 +378,11 @@ public class OutputHandler {
TestCaseEnd(String enterRegex, int groupCount) {
super(enterRegex, groupCount);
}
-
+
/**
* Sets the test case execution time, status and notify Tests Runner
* Core about test case end.
- *
+ *
* @throws TestingException if current test suite or case name does not
* match last entered test suite or case name or if test status is not
* known.
@@ -410,25 +390,18 @@ public class OutputHandler {
@Override
public void onEnter(State previousState) throws TestingException {
String lastTestSuiteName = modelUpdater.currentTestSuite().getName();
- String explicitTypeParameter = group(5);
- String typeParameter = explicitTypeParameter != null ? explicitTypeParameter : stateTestSuiteStart.getTypeParameter();
+ String explicitTypeParameter = group(5);
+ String typeParameter = explicitTypeParameter != null ? explicitTypeParameter
+ : stateTestSuiteStart.getTypeParameter();
String currTestSuiteName = getTestSuiteName(group(2), typeParameter);
if (!lastTestSuiteName.equals(currTestSuiteName)) {
- generateInternalError(
- MessageFormat.format(
- GoogleTestsRunnerMessages.OutputHandler_wrong_suite_name,
- group(2), currTestSuiteName, lastTestSuiteName
- )
- );
+ generateInternalError(MessageFormat.format(GoogleTestsRunnerMessages.OutputHandler_wrong_suite_name,
+ group(2), currTestSuiteName, lastTestSuiteName));
}
String lastTestCaseName = modelUpdater.currentTestCase().getName();
if (!lastTestCaseName.equals(group(3))) {
- generateInternalError(
- MessageFormat.format(
- GoogleTestsRunnerMessages.OutputHandler_unexpected_case_end,
- group(3), lastTestCaseName
- )
- );
+ generateInternalError(MessageFormat.format(GoogleTestsRunnerMessages.OutputHandler_unexpected_case_end,
+ group(3), lastTestCaseName));
}
String testStatusStr = group(1);
ITestItem.Status testStatus = ITestItem.Status.Skipped;
@@ -437,24 +410,20 @@ public class OutputHandler {
} else if (testStatusStr.equals(testStatusFailed)) {
testStatus = ITestItem.Status.Failed;
} else {
- generateInternalError(MessageFormat.format(GoogleTestsRunnerMessages.OutputHandler_unknown_test_status, testStatusStr));
+ generateInternalError(MessageFormat.format(GoogleTestsRunnerMessages.OutputHandler_unknown_test_status,
+ testStatusStr));
}
String getParamValue = group(7);
if (getParamValue != null) {
- modelUpdater.addTestMessage(
- DEFAULT_LOCATION_FILE,
- DEFAULT_LOCATION_LINE,
- ITestMessage.Level.Info,
- MessageFormat.format(GoogleTestsRunnerMessages.OutputHandler_getparam_message, getParamValue)
- );
-
+ modelUpdater.addTestMessage(DEFAULT_LOCATION_FILE, DEFAULT_LOCATION_LINE, ITestMessage.Level.Info,
+ MessageFormat.format(GoogleTestsRunnerMessages.OutputHandler_getparam_message, getParamValue));
+
}
modelUpdater.setTestingTime(Integer.parseInt(group(8)));
modelUpdater.setTestStatus(testStatus);
modelUpdater.exitTestCase();
}
}
-
/**
* The state is activated when a test suite is finished.
@@ -464,10 +433,10 @@ public class OutputHandler {
TestSuiteEnd(String enterRegex, int groupCount) {
super(enterRegex, groupCount);
}
-
+
/**
* Notify Tests Runner Core about test suite end.
- *
+ *
* @throws TestingException if current test suite name does not match
* last entered test suite name.
*/
@@ -476,28 +445,23 @@ public class OutputHandler {
String lastTestSuiteName = modelUpdater.currentTestSuite().getName();
String currTestSuiteName = getTestSuiteName(group(1), stateTestSuiteStart.getTypeParameter());
if (!lastTestSuiteName.equals(currTestSuiteName)) {
- generateInternalError(
- MessageFormat.format(
- GoogleTestsRunnerMessages.OutputHandler_unexpected_suite_end,
- currTestSuiteName, lastTestSuiteName
- )
- );
+ generateInternalError(MessageFormat.format(GoogleTestsRunnerMessages.OutputHandler_unexpected_suite_end,
+ currTestSuiteName, lastTestSuiteName));
}
modelUpdater.exitTestSuite();
}
}
-
-
- /** The default file name for test message location. */
+
+ /** The default file name for test message location. */
private static final String DEFAULT_LOCATION_FILE = null;
/** The default line number for test message location. */
private static final int DEFAULT_LOCATION_LINE = 1;
-
+
// Common regular expression parts
static private String regexTestSuiteName = "([^, ]+)"; //$NON-NLS-1$
static private String regexParameterInstantiation = "(\\s*,\\s+where\\s+TypeParam\\s*=(.+))?"; //$NON-NLS-1$
- static private String regexTestName = regexTestSuiteName+"\\.([^,]+)"; //$NON-NLS-1$
+ static private String regexTestName = regexTestSuiteName + "\\.([^,]+)"; //$NON-NLS-1$
static private String regexTestCount = "\\d+\\s+tests?"; //$NON-NLS-1$
static private String regexTestTime = "(\\d+)\\s+ms"; //$NON-NLS-1$
/* Matches location in the following formats:
@@ -511,64 +475,69 @@ public class OutputHandler {
* 4 - line number (common style) *
* 5 - line number (Visual Studio style) *
* 6 - file name (if no line number specified) *
- * Using:
+ * Using:
* - group 2 with 4 or 5 (if line number was specified)
* - group 6 (if filename only was specified)
*/
static private String regexLocation = "((.*)(:(\\d+)|\\((\\d+)\\))|(.*[^):])):"; //$NON-NLS-1$
- // Test statuses representation
+ // Test statuses representation
static private String testStatusOk = "OK"; //$NON-NLS-1$
static private String testStatusFailed = "FAILED"; //$NON-NLS-1$
-
// All available states in FSM
private State stateInitial = new State(""); //$NON-NLS-1$
private State stateInitialized = new State(".*Global test environment set-up.*"); //$NON-NLS-1$
- private TestSuiteStart stateTestSuiteStart = new TestSuiteStart("\\[-*\\]\\s+"+regexTestCount+"\\s+from\\s+"+regexTestSuiteName+regexParameterInstantiation, 3); //$NON-NLS-1$ //$NON-NLS-2$
- private State stateTestCaseStart = new TestCaseStart("\\[\\s*RUN\\s*\\]\\s+"+regexTestName, 2); //$NON-NLS-1$
- private ErrorMessageLocation stateErrorMessageLocation = new ErrorMessageLocation(regexLocation+"\\s+(Failure|error: (.*))", 8); //$NON-NLS-1$
+ private TestSuiteStart stateTestSuiteStart = new TestSuiteStart(
+ "\\[-*\\]\\s+" + regexTestCount + "\\s+from\\s+" + regexTestSuiteName + regexParameterInstantiation, 3); //$NON-NLS-1$ //$NON-NLS-2$
+ private State stateTestCaseStart = new TestCaseStart("\\[\\s*RUN\\s*\\]\\s+" + regexTestName, 2); //$NON-NLS-1$
+ private ErrorMessageLocation stateErrorMessageLocation = new ErrorMessageLocation(
+ regexLocation + "\\s+(Failure|error: (.*))", 8); //$NON-NLS-1$
private State stateErrorMessage = new ErrorMessage("(.*)", 1); //$NON-NLS-1$
private State stateTestTraceStart = new State(".*Google Test trace.*"); //$NON-NLS-1$
// NOTE: Use 8 groups instead of 7 cause we need to be consistent with ErrorMessageLocation (as we subclass it)
- private State stateTestTrace = new TestTrace(regexLocation+"\\s+((.*))", 8); //$NON-NLS-1$
- private State stateTestCaseEnd = new TestCaseEnd("\\[\\s*("+testStatusOk+"|"+testStatusFailed+")\\s*\\]\\s+"+regexTestName+regexParameterInstantiation+"(\\s*,\\s+where\\s+GetParam\\s*\\(\\s*\\)\\s*=\\s*(.+))?\\s+\\("+regexTestTime+"\\)", 8); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- private State stateTestSuiteEnd = new TestSuiteEnd("\\[-*\\]\\s+"+regexTestCount+"\\s+from\\s+"+regexTestSuiteName+"\\s+\\("+regexTestTime+"\\s+total\\)", 2); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private State stateTestTrace = new TestTrace(regexLocation + "\\s+((.*))", 8); //$NON-NLS-1$
+ private State stateTestCaseEnd = new TestCaseEnd("\\[\\s*(" + testStatusOk + "|" + testStatusFailed + ")\\s*\\]\\s+" //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ + regexTestName + regexParameterInstantiation
+ + "(\\s*,\\s+where\\s+GetParam\\s*\\(\\s*\\)\\s*=\\s*(.+))?\\s+\\(" + regexTestTime + "\\)", 8); //$NON-NLS-1$ //$NON-NLS-2$
+ private State stateTestSuiteEnd = new TestSuiteEnd("\\[-*\\]\\s+" + regexTestCount + "\\s+from\\s+" //$NON-NLS-1$//$NON-NLS-2$
+ + regexTestSuiteName + "\\s+\\(" + regexTestTime + "\\s+total\\)", 2); //$NON-NLS-1$ //$NON-NLS-2$
private State stateFinal = new State(".*Global test environment tear-down.*"); //$NON-NLS-1$
// NOTE: This state is a special workaround for empty test modules (they haven't got global test environment set-up/tear-down). They should be always passed.
private State stateEmptyTestModuleFinal = new State(".*\\[\\s*PASSED\\s*\\]\\s+0\\s+tests.*"); //$NON-NLS-1$
-
+
// Transitions table
- private Map<State, State[] > transitions = new HashMap<State, State[]>();
+ private Map<State, State[]> transitions = new HashMap<State, State[]>();
{
// NOTE: Next states order is important!
- transitions.put( from(stateInitial), to(stateInitialized, stateEmptyTestModuleFinal) );
- transitions.put( from(stateInitialized), to(stateTestSuiteStart) );
- transitions.put( from(stateTestSuiteStart), to(stateTestCaseStart) );
- transitions.put( from(stateTestCaseStart), to(stateTestCaseEnd, stateErrorMessageLocation) );
- transitions.put( from(stateErrorMessageLocation), to(stateTestTraceStart, stateTestCaseEnd, stateErrorMessageLocation, stateErrorMessage) );
- transitions.put( from(stateErrorMessage), to(stateTestTraceStart, stateTestCaseEnd, stateErrorMessageLocation, stateErrorMessage) );
- transitions.put( from(stateTestTraceStart), to(stateTestTrace) );
- transitions.put( from(stateTestTrace), to(stateTestCaseEnd, stateErrorMessageLocation, stateTestTrace) );
- transitions.put( from(stateTestCaseEnd), to(stateTestCaseStart, stateTestSuiteEnd) );
- transitions.put( from(stateTestSuiteEnd), to(stateTestSuiteStart, stateFinal) );
+ transitions.put(from(stateInitial), to(stateInitialized, stateEmptyTestModuleFinal));
+ transitions.put(from(stateInitialized), to(stateTestSuiteStart));
+ transitions.put(from(stateTestSuiteStart), to(stateTestCaseStart));
+ transitions.put(from(stateTestCaseStart), to(stateTestCaseEnd, stateErrorMessageLocation));
+ transitions.put(from(stateErrorMessageLocation),
+ to(stateTestTraceStart, stateTestCaseEnd, stateErrorMessageLocation, stateErrorMessage));
+ transitions.put(from(stateErrorMessage),
+ to(stateTestTraceStart, stateTestCaseEnd, stateErrorMessageLocation, stateErrorMessage));
+ transitions.put(from(stateTestTraceStart), to(stateTestTrace));
+ transitions.put(from(stateTestTrace), to(stateTestCaseEnd, stateErrorMessageLocation, stateTestTrace));
+ transitions.put(from(stateTestCaseEnd), to(stateTestCaseStart, stateTestSuiteEnd));
+ transitions.put(from(stateTestSuiteEnd), to(stateTestSuiteStart, stateFinal));
}
/** Current FSM state. */
private State currentState;
-
+
/** The interface to notify the Tests Runner Core */
private ITestModelUpdater modelUpdater;
-
OutputHandler(ITestModelUpdater modelUpdater) {
this.modelUpdater = modelUpdater;
}
-
+
/**
* Runs the parsing process. Initializes the FSM, selects new states with
* transitions table and checks whether the parsing completes successfully.
- *
+ *
* @param inputStream gtest test module output stream
* @throws IOException if stream reading error happens
* @throws TestingException if testing error happens
@@ -577,72 +546,73 @@ public class OutputHandler {
// Initialize input stream reader
InputStreamReader streamReader = new InputStreamReader(inputStream);
BufferedReader reader = new BufferedReader(streamReader);
- String line;
- boolean finalizedProperly = false;
+ String line;
+ boolean finalizedProperly = false;
- // Initialize internal state
+ // Initialize internal state
currentState = stateInitial;
- while ( ( line = reader.readLine() ) != null ) {
- // Search for the next possible state
- State[] possibleNextStates = transitions.get(currentState);
- if (possibleNextStates == null) {
- // Final state, stop running
- finalizedProperly = true;
- break;
- }
- for (State nextState : possibleNextStates) {
- if (nextState.match(line)) {
- // Next state found - send notifications to the states
- currentState.onExit(nextState);
- State previousState = currentState;
- currentState = nextState;
- nextState.onEnter(previousState);
- break;
- }
- }
- // NOTE: We cannot be sure that we cover all the output of gtest with our regular expressions
- // (e.g. some framework notes or warnings may be uncovered etc.), so we just skip unmatched
- // lines without an error
- }
- // Check whether the last line leads to the final state
- if (transitions.get(currentState) == null) {
- finalizedProperly = true;
- }
- if (!finalizedProperly) {
- generateInternalError(GoogleTestsRunnerMessages.OutputHandler_unexpected_output);
- }
+ while ((line = reader.readLine()) != null) {
+ // Search for the next possible state
+ State[] possibleNextStates = transitions.get(currentState);
+ if (possibleNextStates == null) {
+ // Final state, stop running
+ finalizedProperly = true;
+ break;
+ }
+ for (State nextState : possibleNextStates) {
+ if (nextState.match(line)) {
+ // Next state found - send notifications to the states
+ currentState.onExit(nextState);
+ State previousState = currentState;
+ currentState = nextState;
+ nextState.onEnter(previousState);
+ break;
+ }
+ }
+ // NOTE: We cannot be sure that we cover all the output of gtest with our regular expressions
+ // (e.g. some framework notes or warnings may be uncovered etc.), so we just skip unmatched
+ // lines without an error
+ }
+ // Check whether the last line leads to the final state
+ if (transitions.get(currentState) == null) {
+ finalizedProperly = true;
+ }
+ if (!finalizedProperly) {
+ generateInternalError(GoogleTestsRunnerMessages.OutputHandler_unexpected_output);
+ }
}
-
+
/**
* Throws the testing exception with unknown internal error prefix and the specified description.
- *
+ *
* @param additionalInfo additional description of what happens
* @throws SAXException the exception that will be thrown
*/
private void generateInternalError(String additionalInfo) throws TestingException {
- TestingException e = new TestingException(GoogleTestsRunnerMessages.OutputHandler_unknown_error_prefix+additionalInfo);
+ TestingException e = new TestingException(
+ GoogleTestsRunnerMessages.OutputHandler_unknown_error_prefix + additionalInfo);
GoogleTestsRunnerPlugin.log(e);
throw e;
}
/**
* Helper functions to make code more readable.
- *
+ *
* @param fromState state to return
* @return passed state
*/
private State from(State fromState) {
return fromState;
}
-
+
/**
* Helper functions to make code more readable.
- *
+ *
* @param toStates states array to return
* @return passed states array
*/
private State[] to(State... toStates) {
return toStates;
}
-
+
}

Back to the top