mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
one test rewritten in Kotlin
This commit is contained in:
Generated
+11
@@ -0,0 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="KotlinJavaRuntime">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/build/kotlinc/lib/kotlin-runtime.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/build/kotlinc/lib/kotlin-runtime-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@@ -0,0 +1 @@
|
||||
/kotlinc/
|
||||
@@ -12,6 +12,9 @@
|
||||
<fileset dir="${project.home}/build/lib/jps">
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="${project.home}/build/kotlinc/jps" erroronmissingdir="false">
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="${idea.lib}">
|
||||
<include name="jdom.jar"/>
|
||||
<include name="log4j.jar"/>
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
<orderEntry type="module" module-name="jps-model-impl" />
|
||||
<orderEntry type="library" scope="TEST" name="Groovy" level="project" />
|
||||
<orderEntry type="module" module-name="jps-serialization-tests" scope="TEST" />
|
||||
<orderEntry type="library" scope="TEST" name="KotlinJavaRuntime" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ public class ProjectPaths {
|
||||
private ProjectPaths() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Collection<File> getCompilationClasspathFiles(ModuleChunk chunk,
|
||||
boolean includeTests,
|
||||
final boolean excludeMainModuleOutput,
|
||||
@@ -49,14 +50,17 @@ public class ProjectPaths {
|
||||
return getClasspathFiles(chunk, JpsJavaClasspathKind.compile(includeTests), excludeMainModuleOutput, ClasspathPart.WHOLE, exportedOnly);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Collection<File> getPlatformCompilationClasspath(ModuleChunk chunk, boolean excludeMainModuleOutput) {
|
||||
return getClasspathFiles(chunk, JpsJavaClasspathKind.compile(chunk.containsTests()), excludeMainModuleOutput, ClasspathPart.BEFORE_JDK, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Collection<File> getCompilationClasspath(ModuleChunk chunk, boolean excludeMainModuleOutput) {
|
||||
return getClasspathFiles(chunk, JpsJavaClasspathKind.compile(chunk.containsTests()), excludeMainModuleOutput, ClasspathPart.AFTER_JDK, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Collection<File> getClasspathFiles(ModuleChunk chunk,
|
||||
JpsJavaClasspathKind kind,
|
||||
final boolean excludeMainModuleOutput,
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.jps.builders
|
||||
|
||||
import com.intellij.openapi.application.ex.PathManagerEx
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.jps.ModuleChunk
|
||||
import org.jetbrains.jps.ProjectPaths
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType
|
||||
import org.jetbrains.jps.incremental.ModuleBuildTarget
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ModuleClasspathTest extends JpsBuildTestCase {
|
||||
@Override
|
||||
protected void setUp() {
|
||||
super.setUp()
|
||||
addJdk("1.6", "/jdk.jar")
|
||||
addJdk("1.5", "/jdk15.jar")
|
||||
loadProject("moduleClasspath/moduleClasspath.ipr")
|
||||
}
|
||||
|
||||
private String getProjectPath() {
|
||||
return FileUtil.toSystemIndependentName(getTestDataRootPath()) + "/moduleClasspath/moduleClasspath.ipr"
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataRootPath() {
|
||||
char s = '/'
|
||||
return FileUtil.toCanonicalPath(PathManagerEx.findFileUnderCommunityHome("jps/jps-builders/testData/output").absolutePath, s)
|
||||
}
|
||||
|
||||
public void testSimpleClasspath() {
|
||||
assertClasspath('util', false, ["util/lib/exported.jar", "/jdk15.jar"])
|
||||
}
|
||||
|
||||
public void testScopes() {
|
||||
assertClasspath("test-util", false,
|
||||
["/jdk.jar", "test-util/lib/provided.jar"])
|
||||
assertClasspath("test-util", true,
|
||||
["/jdk.jar", "test-util/lib/provided.jar", "test-util/lib/test.jar", "out/production/test-util"])
|
||||
}
|
||||
|
||||
public void testDepModules() {
|
||||
assertClasspath("main", false,
|
||||
["util/lib/exported.jar", "out/production/util", "/jdk.jar", "main/lib/service.jar"])
|
||||
assertClasspath("main", true,
|
||||
["out/production/main", "util/lib/exported.jar", "out/test/util", "out/production/util", "/jdk.jar",
|
||||
"out/test/test-util", "out/production/test-util", "main/lib/service.jar"])
|
||||
}
|
||||
|
||||
public void testCompilationClasspath() {
|
||||
ModuleChunk chunk = createChunk('main')
|
||||
assertClasspath(["util/lib/exported.jar", "out/production/util", "/jdk.jar"],
|
||||
getPathsList(ProjectPaths.getPlatformCompilationClasspath(chunk, true)))
|
||||
assertClasspath(["main/lib/service.jar"],
|
||||
getPathsList(ProjectPaths.getCompilationClasspath(chunk, true)))
|
||||
}
|
||||
|
||||
private def assertClasspath(String moduleName, boolean includeTests, List<String> expected) {
|
||||
ModuleChunk chunk = createChunk(moduleName)
|
||||
final List<String> classpath = getPathsList(new ProjectPaths().getCompilationClasspathFiles(chunk, includeTests, true, true))
|
||||
assertClasspath(expected, toSystemIndependentPaths(classpath))
|
||||
}
|
||||
|
||||
private ModuleChunk createChunk(String moduleName) {
|
||||
def module = myProject.modules.find {it.name == moduleName}
|
||||
return new ModuleChunk([new ModuleBuildTarget(module, JavaModuleBuildTargetType.PRODUCTION)] as Set)
|
||||
}
|
||||
|
||||
private def assertClasspath(List<String> expected, List<String> classpath) {
|
||||
String basePath = FileUtil.toSystemIndependentName(new File(getProjectPath()).parentFile.absolutePath) + "/"
|
||||
List<String> actual = toSystemIndependentPaths(classpath).collect { String path ->
|
||||
path.startsWith(basePath) ? path.substring(basePath.length()) : path
|
||||
}
|
||||
assertEquals(expected.join("\n"), actual.join("\n"))
|
||||
}
|
||||
|
||||
private static List<String> toSystemIndependentPaths(List<String> classpath) {
|
||||
final List<String> result = new ArrayList<String>()
|
||||
for (String path: classpath) {
|
||||
result.add(FileUtil.toSystemIndependentName(path));
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
public static List<String> getPathsList(Collection<File> files) {
|
||||
final List<String> result = new ArrayList<String>();
|
||||
for (File file : files) {
|
||||
result.add(getCanonicalPath(file));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private static String getCanonicalPath(File file) {
|
||||
final String path = file.getPath();
|
||||
return path.contains(".")? FileUtil.toCanonicalPath(path) : FileUtil.toSystemIndependentName(path);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.jps.builders
|
||||
|
||||
import com.intellij.openapi.application.ex.PathManagerEx
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.util.io.FileUtil.*
|
||||
import org.jetbrains.jps.ModuleChunk
|
||||
import org.jetbrains.jps.ProjectPaths
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType
|
||||
import org.jetbrains.jps.incremental.ModuleBuildTarget
|
||||
import java.io.File
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import org.junit.Assert
|
||||
import java.util.Collections
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ModuleClasspathTest(): JpsBuildTestCase() {
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
addJdk("1.6", "/jdk.jar")
|
||||
addJdk("1.5", "/jdk15.jar")
|
||||
loadProject("moduleClasspath/moduleClasspath.ipr")
|
||||
}
|
||||
|
||||
private fun getProjectPath(): String {
|
||||
return FileUtil.toSystemIndependentName(getTestDataRootPath()) + "/moduleClasspath/moduleClasspath.ipr"
|
||||
}
|
||||
|
||||
override fun getTestDataRootPath(): String {
|
||||
return FileUtil.toCanonicalPath(PathManagerEx.findFileUnderCommunityHome("jps/jps-builders/testData/output")!!.getAbsolutePath(), '/')!!
|
||||
}
|
||||
|
||||
public fun testSimpleClasspath() {
|
||||
assertClasspath("util", false, listOf("util/lib/exported.jar", "/jdk15.jar"))
|
||||
}
|
||||
|
||||
public fun testScopes() {
|
||||
assertClasspath("test-util", false, listOf("/jdk.jar", "test-util/lib/provided.jar"))
|
||||
assertClasspath("test-util", true, listOf("/jdk.jar", "test-util/lib/provided.jar", "test-util/lib/test.jar", "out/production/test-util"))
|
||||
}
|
||||
|
||||
public fun testDepModules() {
|
||||
assertClasspath("main", false, listOf("util/lib/exported.jar", "out/production/util", "/jdk.jar", "main/lib/service.jar"))
|
||||
assertClasspath("main", true, listOf("out/production/main", "util/lib/exported.jar", "out/test/util", "out/production/util", "/jdk.jar", "out/test/test-util", "out/production/test-util", "main/lib/service.jar"))
|
||||
}
|
||||
|
||||
public fun testCompilationClasspath() {
|
||||
val chunk = createChunk("main")
|
||||
assertClasspath(listOf("util/lib/exported.jar", "out/production/util", "/jdk.jar"), getPathsList(ProjectPaths.getPlatformCompilationClasspath(chunk, true)))
|
||||
assertClasspath(listOf("main/lib/service.jar"), getPathsList(ProjectPaths.getCompilationClasspath(chunk, true)))
|
||||
}
|
||||
|
||||
private fun assertClasspath(moduleName: String, includeTests: Boolean, expected: List<String>) {
|
||||
val classpath = getPathsList(ProjectPaths.getCompilationClasspathFiles(createChunk(moduleName), includeTests, true, true))
|
||||
assertClasspath(expected, toSystemIndependentPaths(classpath))
|
||||
}
|
||||
|
||||
private fun createChunk(moduleName: String): ModuleChunk {
|
||||
val module = myProject!!.getModules().firstOrNull { it.getName() == moduleName }
|
||||
return ModuleChunk(setOf(ModuleBuildTarget(module!!, JavaModuleBuildTargetType.PRODUCTION)))
|
||||
}
|
||||
|
||||
private fun assertClasspath(expected: List<String>, classpath: List<String>) {
|
||||
val basePath = FileUtil.toSystemIndependentName(File(getProjectPath()).getParentFile()!!.getAbsolutePath()) + "/"
|
||||
val actual = toSystemIndependentPaths(classpath).map { StringUtil.trimStart(it, basePath) }
|
||||
Assert.assertEquals(expected.makeString("\n"), actual.makeString("\n"))
|
||||
}
|
||||
|
||||
private fun toSystemIndependentPaths(classpath: List<String>): List<String> {
|
||||
return classpath.map(FileUtil::toSystemIndependentName)
|
||||
}
|
||||
|
||||
public fun getPathsList(files: Collection<File>): List<String> {
|
||||
return files.map(::getCanonicalPath)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCanonicalPath(file: File): String {
|
||||
val path = file.getPath()
|
||||
return if (path.contains(".")) FileUtil.toCanonicalPath(path)!! else FileUtil.toSystemIndependentName(path)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user