Maven: Introduce test for plugin output
Use mvn integration-test to run tests
This commit is contained in:
@@ -45,6 +45,12 @@
|
|||||||
<artifactId>kotlin-jdk-annotations</artifactId>
|
<artifactId>kotlin-jdk-annotations</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.codehaus.groovy</groupId>
|
||||||
|
<artifactId>groovy-all</artifactId>
|
||||||
|
<version>2.4.4</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -80,6 +86,29 @@
|
|||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-invoker-plugin</artifactId>
|
||||||
|
<version>2.0.0</version>
|
||||||
|
<configuration>
|
||||||
|
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
|
||||||
|
<settingsFile>src/it/settings.xml</settingsFile>
|
||||||
|
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
|
||||||
|
<postBuildHookScript>verify</postBuildHookScript> <!-- no extension required -->
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>integration-test</id>
|
||||||
|
<goals>
|
||||||
|
<goal>install</goal>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
|
||||||
|
<configuration>
|
||||||
|
<postBuildHookScript>verify</postBuildHookScript>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<settings>
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>it-repo</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>true</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>local.central</id>
|
||||||
|
<url>@localRepositoryUrl@</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>local.central</id>
|
||||||
|
<url>@localRepositoryUrl@</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
</settings>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
[INFO] Kotlin Compiler version @snapshot@
|
||||||
|
[INFO] Compiling Kotlin sources from [/src/main/kotlin]
|
||||||
|
[INFO] Classes directory is /target/classes
|
||||||
|
[INFO] Classpath: /target/classes
|
||||||
|
[INFO] Classes directory is /target/classes
|
||||||
|
[INFO] Using kotlin annotations from /local-repo/org/jetbrains/kotlin/kotlin-jdk-annotations/0.1-SNAPSHOT/kotlin-jdk-annotations-0.1-SNAPSHOT.jar
|
||||||
|
[INFO] PERF: INIT: Compiler initialized in LLL ms
|
||||||
|
[INFO] PERF: ANALYZE: 1 files (2 lines) in LLL ms
|
||||||
|
[INFO] PERF: GENERATE: 1 files (2 lines) in LLL ms
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||||
|
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>test-group</groupId>
|
||||||
|
<name>test-project</name>
|
||||||
|
<artifactId>test-project</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.12</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||||
|
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<version>0.1-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fun main(vararg args: String) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
|
class State {
|
||||||
|
def currentPlugin = ""
|
||||||
|
def lines = []
|
||||||
|
}
|
||||||
|
|
||||||
|
def removePaths(String path, File basedir) {
|
||||||
|
while (basedir.parentFile != null) {
|
||||||
|
path = path.replace(basedir.absolutePath, "").replace(basedir.path, "")
|
||||||
|
basedir = basedir.parentFile
|
||||||
|
}
|
||||||
|
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
|
||||||
|
def pattern = Pattern.compile(/\[INFO\] --- ([^:]+):.*:\S+ \([^)]+\) @ test-project ---/)
|
||||||
|
State state = new File(basedir, "build.log").readLines().inject(new State()) { acc, line ->
|
||||||
|
def m = pattern.matcher(line)
|
||||||
|
if (m.find()) {
|
||||||
|
acc.currentPlugin = m.group(1)
|
||||||
|
} else if (line.startsWith("[INFO] Downloaded:") || line.startsWith("[INFO] Downloading:")) {
|
||||||
|
// ignore line
|
||||||
|
} else if (acc.currentPlugin == "kotlin-maven-plugin") {
|
||||||
|
def filtered = removePaths(line, basedir).replace("\\", "/").replaceAll(/[0-9]+\s*ms/, "LLL ms").trim().replaceAll(/^\[[A-Z]+\]$/, "")
|
||||||
|
if (filtered != "") {
|
||||||
|
acc.lines << filtered
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
acc
|
||||||
|
}
|
||||||
|
|
||||||
|
def expectedLog = new File(basedir, "expected.log").readLines().join("\n").trim()
|
||||||
|
def actualLog = state.lines.join("\n").trim()
|
||||||
|
|
||||||
|
if (expectedLog != actualLog) {
|
||||||
|
println "Expected and actual log differs!"
|
||||||
|
println ""
|
||||||
|
|
||||||
|
println "Actual log:"
|
||||||
|
println actualLog
|
||||||
|
println ""
|
||||||
|
println "Expected log (from ${new File(basedir, "expected.log").absolutePath}):"
|
||||||
|
println expectedLog
|
||||||
|
println ""
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
println "Log comparison succeeded"
|
||||||
|
}
|
||||||
|
|
||||||
|
def classes = new File(basedir, "target/classes").listFiles()?.toList() ?: []
|
||||||
|
if (classes.isEmpty()) {
|
||||||
|
println "No classes were produced"
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
-26
@@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2013 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.kotlin.maven;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class MojoTest {
|
|
||||||
@Test
|
|
||||||
public void dummy() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user