From 955afec34302016386657ce49dbb288824931a69 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sun, 4 Dec 2016 12:05:28 +0000 Subject: [PATCH] Fixup for "[dsf-gdb] debug tests: Use line tags where possible" Unfortunately previous commit was submitted too early. There were two problems that this commit corrects: 1) clear line tags before each test run - side effect of Bug 508642 When a test marked with Intermittent fails, the next retry is executed with the same class instance. Therefore, the new try starts with a non-empty fTagLocations. The test trips on the check that there are no duplicate tags. 2) Fix failing testStopAtMainWithReverse A blank line got inserted into the test case, that interfered with the test logic. Change-Id: If4c28557eac7ee740b4e3a5eac5dd2726c39a35d Also-by: Jonah Graham Signed-off-by: Simon Marchi --- .../src/LaunchConfigurationAndRestartTestApp.cc | 5 ++--- .../cdt/tests/dsf/gdb/framework/BaseTestCase.java | 14 ++++++++++++++ .../tests/LaunchConfigurationAndRestartTest.java | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/LaunchConfigurationAndRestartTestApp.cc b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/LaunchConfigurationAndRestartTestApp.cc index b17f082beb8..8fa1492e62e 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/LaunchConfigurationAndRestartTestApp.cc +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/LaunchConfigurationAndRestartTestApp.cc @@ -25,9 +25,8 @@ int envTest() { int main (int argc, char *argv[]) { envTest(); // FIRST_LINE_IN_MAIN - reverseTest(); - stopAtOther(); - + reverseTest(); // tests assume that every line between first and last + stopAtOther(); // is steppable, so no blank lines allowed. return 36; // LAST_LINE_IN_MAIN // Return special value to allow // testing exit code feature diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java index 3c2c87c2d9d..241ef73a6d2 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java @@ -337,6 +337,20 @@ public class BaseTestCase { setGdbVersion(); } + /** + * Clear our knowledge of line tags. Must be called before + * resolveLineTagLocations in {@link Intermittent} tests. + *

+ * This is a workaround for Bug 508642. This may not seem necessary, since + * the fTagLocations field is not static and a new instance of the test + * class is created for each test. However, when a test marked as + * {@link Intermittent} fails, the class instance is re-used, so the content + * of the failed try leaks in the new try. + */ + public void clearLineTags() { + fTagLocations.clear(); + } + /** * Given a set of tags (strings) to find in sourceFile, populate the * fTagLocations map with the line numbers where they are found. diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java index ee6eb778c22..fb2ae6348db 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java @@ -104,6 +104,7 @@ public class LaunchConfigurationAndRestartTest extends BaseParametrizedTestCase // parameters. The individual tests will be responsible for starting the launch. // Looks up line tags in source file(s). + clearLineTags(); resolveLineTagLocations(SOURCE_NAME, LINE_TAGS); FIRST_LINE_IN_MAIN = getLineForTag("FIRST_LINE_IN_MAIN");