Minor, move replaceHashWithStar to JetTestUtils

This commit is contained in:
Alexander Udalov
2015-02-04 15:37:03 +03:00
parent 37da154ea2
commit 45fec9257a
2 changed files with 14 additions and 15 deletions
@@ -237,6 +237,9 @@ public class JetTestUtils {
@SuppressWarnings("unchecked")
private static final Class<? extends TestCase>[] NO_INNER_CLASSES = ArrayUtil.EMPTY_CLASS_ARRAY;
// We suspect sequences of eight consecutive hexadecimal digits to be a package part hash code
private static final Pattern STRIP_PACKAGE_PART_HASH_PATTERN = Pattern.compile("\\$([0-9a-f]{8})");
private JetTestUtils() {
}
@@ -877,4 +880,13 @@ public class JetTestUtils {
public static File replaceExtension(@NotNull File file, @Nullable String newExtension) {
return new File(file.getParentFile(), FileUtil.getNameWithoutExtension(file) + (newExtension == null ? "" : "." + newExtension));
}
@NotNull
public static String replaceHashWithStar(@NotNull String string) {
Matcher matcher = STRIP_PACKAGE_PART_HASH_PATTERN.matcher(string);
if (matcher.find()) {
return matcher.replaceAll("\\$*");
}
return string;
}
}
@@ -20,6 +20,7 @@ import org.jetbrains.jps.builders.JpsBuildTestCase
import kotlin.properties.Delegates
import com.intellij.openapi.util.io.FileUtil
import java.io.File
import org.jetbrains.kotlin.test.JetTestUtils
import org.jetbrains.jps.builders.CompileScopeTestBuilder
import org.jetbrains.jps.builders.impl.logging.ProjectBuilderLoggerBase
import org.jetbrains.jps.builders.logging.BuildLoggingManager
@@ -34,7 +35,6 @@ import java.util.HashMap
import org.jetbrains.kotlin.utils.keysToMap
import org.jetbrains.jps.incremental.messages.BuildMessage
import kotlin.test.assertFalse
import java.util.regex.Pattern
import kotlin.test.assertEquals
import org.jetbrains.jps.model.JpsModuleRootModificationUtil
import com.intellij.openapi.util.io.FileUtilRt
@@ -347,20 +347,7 @@ public abstract class AbstractIncrementalJpsTest : JpsBuildTestCase() {
override fun isEnabled(): Boolean = true
override fun logLine(message: String?) {
fun String.replaceHashWithStar(): String {
val matcher = STRIP_PACKAGE_PART_HASH_PATTERN.matcher(this)
if (matcher.find()) {
return matcher.replaceAll("\\$*")
}
return this
}
logBuf.append(message!!.trimLeading(rootPath + "/").replaceHashWithStar()).append('\n')
}
class object {
// We suspect sequences of eight consecutive hexadecimal digits to be a package part hash code
val STRIP_PACKAGE_PART_HASH_PATTERN = Pattern.compile("\\$([0-9a-f]{8})")
logBuf.append(JetTestUtils.replaceHashWithStar(message!!.trimLeading(rootPath + "/"))).append('\n')
}
}