From 13978c15673a09714027b9c2ce770693dc50208b Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 18 Feb 2015 13:30:02 -0500 Subject: [PATCH] [dsf-gdb] tests: Check if a line tag is defined more than once As a safety net, fail if a line tag is defined more than once. Also, allow calling resolveLineTagLocations more than once for a single test. Change-Id: I0832d3d28c4d688c38fd33dfc668b0ec6b8c4ffa Signed-off-by: Simon Marchi --- .../cdt/tests/dsf/gdb/framework/BaseTestCase.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 56d8f27dace..d3826ad04b1 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 @@ -113,7 +113,7 @@ public class BaseTestCase { private static boolean fgStatusHandlersEnabled = true; - private static HashMap fTagLocations = new HashMap<>(); + private HashMap fTagLocations = new HashMap<>(); public GdbLaunch getGDBLaunch() { return fLaunch; } @@ -253,15 +253,19 @@ public class BaseTestCase { Set tagsToFind = new HashSet<>(Arrays.asList(tags)); String line; int lineNumber = 1; - - fTagLocations.clear(); + int numberFound = 0; line = reader.readLine(); while (line != null) { for (String tag : tagsToFind) { if (line.contains(tag)) { + if (fTagLocations.containsKey(tag)) { + throw new RuntimeException("Tag " + tag + + " was found twice in " + sourceName); + } + fTagLocations.put(tag, lineNumber); - tagsToFind.remove(tag); + numberFound++; break; } } @@ -271,7 +275,7 @@ public class BaseTestCase { } /* Make sure all tags have been found */ - if (tagsToFind.size() > 0) { + if (numberFound != tagsToFind.size()) { throw new RuntimeException( "Some tags were not found in " + sourceName); }