Add tests on "-language-version" usage from Ant, Maven, Gradle

This commit is contained in:
Alexander Udalov
2016-05-26 15:40:36 +03:00
parent bc5202a4d7
commit 2c516f18a0
12 changed files with 164 additions and 0 deletions
@@ -0,0 +1,17 @@
OUT:
Buildfile: [TestData]/build.xml
build:
[kotlinc] Compiling [[TestData]/main.kt] => [[Temp]/hello.jar]
[kotlinc] [TestData]/main.kt:3:17: error: this type is sealed, so it can be inherited by only its own nested classes or objects
[kotlinc] class Derived : Base()
[kotlinc] ^
ERR:
BUILD FAILED
[TestData]/build.xml:5: Compile failed; see the compiler error output for details.
Total time: [time]
Return code: 1
@@ -0,0 +1,9 @@
<project name="Ant Task Test" default="build">
<taskdef resource="org/jetbrains/kotlin/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
<target name="build">
<kotlinc src="${test.data}/main.kt" output="${temp}/hello.jar">
<compilerarg line="-language-version 1.0"/>
</kotlinc>
</target>
</project>
@@ -0,0 +1,3 @@
sealed class Base
class Derived : Base()
@@ -77,6 +77,12 @@ public class AntTaskTestGenerated extends AbstractAntTaskTest {
doTest(fileName);
}
@TestMetadata("languageVersion")
public void testLanguageVersion() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/integration/ant/jvm/languageVersion/");
doTest(fileName);
}
@TestMetadata("mainInFiles")
public void testMainInFiles() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/integration/ant/jvm/mainInFiles/");
@@ -207,6 +207,7 @@ open class KotlinCompile() : AbstractKotlinCompile<K2JVMCompilerArguments>() {
args.noCallAssertions = kotlinOptions.noCallAssertions
args.noParamAssertions = kotlinOptions.noParamAssertions
args.moduleName = kotlinOptions.moduleName ?: extraProperties.getOrNull<String>("defaultModuleName")
args.languageVersion = kotlinOptions.languageVersion
fun addFriendPathForTestTask(taskName: String) {
logger.kotlinDebug("try to determine the output directory of corresponding $taskName task")
@@ -92,6 +92,14 @@ class SimpleKotlinGradleIT : BaseGradleIT() {
}
}
@Test
fun testLanguageVersion() {
Project("languageVersion", "1.6").build("build") {
assertFailed()
assertContains("This type is sealed")
}
}
@Test
fun testGradleSubplugin() {
val project = Project("kotlinGradleSubplugin", "1.6")
@@ -0,0 +1,40 @@
buildscript {
repositories {
mavenCentral()
maven {
url 'file://' + pathToKotlinPlugin
}
}
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.1-SNAPSHOT'
}
}
apply plugin: "kotlin"
sourceSets {
main {
kotlin {
srcDir 'src'
}
}
}
repositories {
maven {
url 'file://' + pathToKotlinPlugin
}
mavenCentral()
}
dependencies {
compile 'org.jetbrains.kotlin:kotlin-stdlib:1.1-SNAPSHOT'
}
compileKotlin {
kotlinOptions.languageVersion = "1.0"
}
task wrapper(type: Wrapper) {
gradleVersion = "1.4"
}
@@ -0,0 +1,3 @@
sealed class Base
class Derived : Base()
@@ -0,0 +1 @@
invoker.buildResult = failure
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>test-languageVersion</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-runtime</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
</plugin>
</plugins>
</pluginManagement>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<args>
<arg>-language-version</arg>
<arg>1.0</arg>
</args>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,3 @@
sealed class Base
class Derived : Base()
@@ -0,0 +1,4 @@
source(new File(basedir, "../../../verify-common.bsh").getAbsolutePath());
assertBuildLogHasLine("[INFO] BUILD FAILURE");
assertBuildLogHasLineThatContains("This type is sealed");