From d60c49599578cf1c591d3dae71b580c761173161 Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Mon, 4 Feb 2013 20:02:00 +0400 Subject: [PATCH] Extracting test name from regex matcher. --- .../jet/test/generator/SimpleTestMethodModel.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/compiler/tests/org/jetbrains/jet/test/generator/SimpleTestMethodModel.java b/compiler/tests/org/jetbrains/jet/test/generator/SimpleTestMethodModel.java index e7be189bcee..694b756a33b 100644 --- a/compiler/tests/org/jetbrains/jet/test/generator/SimpleTestMethodModel.java +++ b/compiler/tests/org/jetbrains/jet/test/generator/SimpleTestMethodModel.java @@ -23,6 +23,7 @@ import org.jetbrains.jet.JetTestUtils; import org.jetbrains.jet.utils.Printer; import java.io.File; +import java.util.regex.Matcher; import java.util.regex.Pattern; public class SimpleTestMethodModel implements TestMethodModel { @@ -50,14 +51,19 @@ public class SimpleTestMethodModel implements TestMethodModel { @Override public String getName() { - String fileName = FileUtil.getNameWithoutExtension(file.getName()); + Matcher matcher = filenamePattern.matcher(file.getName()); + boolean found = matcher.find(); + assert found : file.getName() + " isn't matched by regex " + filenamePattern.pattern(); + assert matcher.groupCount() == 2 : filenamePattern.pattern(); + String extractedName = matcher.group(1); + String unescapedName; if (rootDir.equals(file.getParentFile())) { - unescapedName = fileName; + unescapedName = extractedName; } else { String relativePath = FileUtil.getRelativePath(rootDir, file.getParentFile()); - unescapedName = relativePath + "-" + StringUtil.capitalize(fileName); + unescapedName = relativePath + "-" + StringUtil.capitalize(extractedName); } return "test" + StringUtil.capitalize(TestGeneratorUtil.escapeForJavaIdentifier(unescapedName)); }