From b83af889fb09eebe07e203772bc78854a2e3a5c5 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Wed, 4 Jan 2012 11:17:04 -0800 Subject: [PATCH] Fixed breakage of lrparser and xlc tests. --- .../cdt/core/testplugin/util/TestSourceReader.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java index e4bffbbbc57..2869a337ba4 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java @@ -70,7 +70,19 @@ public class TestSourceReader { */ public static StringBuilder[] getContentsForTest(Bundle bundle, String srcRoot, Class clazz, final String testName, int sections) throws IOException { + // Walk up the class inheritance chain until we find the test method. + try { + while (clazz.getMethod(testName).getDeclaringClass() != clazz) { + clazz = clazz.getSuperclass(); + } + } catch (SecurityException e) { + Assert.fail(e.getMessage()); + } catch (NoSuchMethodException e) { + Assert.fail(e.getMessage()); + } + while (true) { + // Find and open the .java file for the class clazz. String fqn = clazz.getName().replace('.', '/'); fqn = fqn.indexOf("$") == -1 ? fqn : fqn.substring(0, fqn.indexOf("$")); String classFile = fqn + ".java"; @@ -94,6 +106,7 @@ public class TestSourceReader { BufferedReader br = new BufferedReader(new InputStreamReader(in)); try { + // Read the java file collecting comments until we encounter the test method. List contents = new ArrayList(); StringBuilder content = new StringBuilder(); for (String line = br.readLine(); line != null; line = br.readLine()) {