Skip to content

Commit

Permalink
Merge pull request #70 from koral--/upstream152
Browse files Browse the repository at this point in the history
Release 0.2.5
  • Loading branch information
koral-- authored Aug 18, 2020
2 parents 26ab9a6 + d032754 commit 8292e11
Show file tree
Hide file tree
Showing 18 changed files with 168 additions and 47 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.2.5 - 2020-08-19
- Merge upstream changes 16873cb7a67b2b21287ba65c0ac89c7266f2d659
- Add compatiblity witn Anroid Gradle Plugin 4 [#64](https://github.com/koral--/gradle-pitest-plugin/issue/64)
- Fix report directory parameter handling [#63](https://github.com/koral--/gradle-pitest-plugin/issue/63)

# 0.2.4 - 2020-05-27
- Fix Gradle 6.4 execution break while trying to change mainClass [#60](https://github.com/koral--/gradle-pitest-plugin/issue/60)

Expand Down
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,34 @@ which supports Android gradle projects.

```groovy
plugins {
id 'pl.droidsonroids.pitest' version '0.2.4'
id 'pl.droidsonroids.pitest' version '0.2.5'
}
```

```kotlin
plugins {
id("pl.droidsonroids.pitest") version "0.2.5"
}
```

## With Maven central repository
```groovy
```kotlin
buildscript {
repositories {
mavenCentral()
google()
// If you're using a version of Gradle lower than 4.1, you must instead use:
// maven {
// url 'https://maven.google.com'
// }
// An alternative URL is 'https://dl.google.com/dl/android/maven2/'
}
dependencies {
classpath 'pl.droidsonroids.gradle:gradle-pitest-plugin:0.2.4'
classpath "pl.droidsonroids.gradle:gradle-pitest-plugin:0.2.5"
}
}

apply plugin: 'com.android.application'
//or apply plugin: 'com.android.library'
//or apply plugin: 'com.android.test'
apply plugin: 'pl.droidsonroids.pitest'
plugins {
id("com.android.application")
//or id("com.android.library")
//or id("com.android.test")
id("pl.droidsonroids.pitest")
}
```

# Usage
Expand Down
6 changes: 1 addition & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ repositories {
}

sourceSets {
funcTest {
java.srcDir file('src/funcTest/java')
groovy.srcDir file('src/funcTest/groovy')
resources.srcDir file('src/funcTest/resources')
}
funcTest
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=0.2.4
VERSION=0.2.5
GROUP=pl.droidsonroids.gradle
POM_DESCRIPTION=Gradle plugin for PIT Mutation Testing in Android projects
POM_URL=https://github.com/koral--/gradle-pitest-plugin
Expand Down
2 changes: 0 additions & 2 deletions gradle/cdeliveryboy-release.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ cDeliveryBoy {
nexusStaging {
packageGroup = "info.solidsoft"
stagingProfileId = "34a3a5beeaa96"
numberOfRetries = 40
delayBetweenRetriesInMillis = 3000
}

scmVersion {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import org.gradle.internal.jvm.Jvm
@CompileDynamic
class PitestPluginPitVersionFunctionalSpec extends AbstractPitestFunctionalSpec {

private static final String PIT_1_3_VERSION = "1.3.1"
private static final String MINIMAL_JAVA9_COMPATIBLE_PIT_VERSION = "1.2.3" //https://github.com/hcoles/pitest/issues/380
private static final String MINIMAL_JAVA10_COMPATIBLE_PIT_VERSION = "1.4.0"
private static final String MINIMAL_SUPPORTED_PIT_VERSION = "1.4.0" //minimal PIT version that required Java 8 - May 2018
private static final String MINIMAL_JAVA11_COMPATIBLE_PIT_VERSION = "1.4.2" //in fact 1.4.1, but 1.4.2 is also Java 12 compatible
private static final String MINIMAL_JAVA13_COMPATIBLE_PIT_VERSION = "1.4.6" //not officially, but at least simple case works
private static final String MINIMAL_JAVA14_COMPATIBLE_PIT_VERSION = "1.4.11" //not officially, but with ASM 7.3.1
Expand Down Expand Up @@ -41,25 +39,22 @@ class PitestPluginPitVersionFunctionalSpec extends AbstractPitestFunctionalSpec
pitVersion << getPitVersionsCompatibleWithCurrentJavaVersion().unique() //be aware that unique() is available since Groovy 2.4.0
}

@SuppressWarnings("IfStatementCouldBeTernary")
private List<String> getPitVersionsCompatibleWithCurrentJavaVersion() {
return [getMinimalPitVersionCompatibleWithCurrentJavaVersion(), PitestPlugin.DEFAULT_PITEST_VERSION]
}

@SuppressWarnings("IfStatementCouldBeTernary")
private String getMinimalPitVersionCompatibleWithCurrentJavaVersion() {
if (isJava14Compatible()) {
return [PitestPlugin.DEFAULT_PITEST_VERSION, MINIMAL_JAVA14_COMPATIBLE_PIT_VERSION]
return [MINIMAL_JAVA14_COMPATIBLE_PIT_VERSION]
}
if (isJava13Compatible()) {
return [PitestPlugin.DEFAULT_PITEST_VERSION, MINIMAL_JAVA13_COMPATIBLE_PIT_VERSION]
return [MINIMAL_JAVA13_COMPATIBLE_PIT_VERSION]
}

if (Jvm.current().javaVersion.isJava11Compatible()) {
return [PitestPlugin.DEFAULT_PITEST_VERSION, MINIMAL_JAVA11_COMPATIBLE_PIT_VERSION]
}
if (Jvm.current().javaVersion.isJava10Compatible()) {
return [PitestPlugin.DEFAULT_PITEST_VERSION, MINIMAL_JAVA10_COMPATIBLE_PIT_VERSION]
}
if (Jvm.current().javaVersion.isJava9Compatible()) {
return [PitestPlugin.DEFAULT_PITEST_VERSION, MINIMAL_JAVA9_COMPATIBLE_PIT_VERSION, PIT_1_3_VERSION]
return [MINIMAL_JAVA11_COMPATIBLE_PIT_VERSION]
}
return [PitestPlugin.DEFAULT_PITEST_VERSION, "1.2.0", PIT_1_3_VERSION, "1.4.0"]
return [MINIMAL_SUPPORTED_PIT_VERSION]
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package pl.droidsonroids.gradle.pitest.functional

import groovy.transform.CompileDynamic
import nebula.test.functional.ExecutionResult

@CompileDynamic
class TestFixturesFunctionalSpec extends AbstractPitestFunctionalSpec {

void "should work with java-test-fixtures plugin"() {
given:
copyResources("testProjects/testFixtures", "")
when:
ExecutionResult result = runTasks('pitestRelease')
then:
!result.standardError.contains("Build failed with an exception")
!result.failure
result.wasExecuted('pitestRelease')
result.standardOutput.contains('Generated 1 mutations Killed 1 (100%)')
}

}
35 changes: 35 additions & 0 deletions src/funcTest/resources/testProjects/junit5spock2/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'info.solidsoft.pitest'

/*
//Local/current version of the plugin should be put on a classpath earlier to override that plugin version
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:X.Y.Z-SNAPSHOT'
}
}
*/

repositories {
mavenCentral()
}

group = "pitest.test"

dependencies {
testImplementation 'org.spockframework:spock-core:2.0-M3-groovy-2.5'
}

test {
useJUnitPlatform()
}

pitest {
// testPlugin = "junit5" //not needed - 'junit5PluginVersion' should implicitly set it
junit5PluginVersion = "0.12"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'simpleSpock2'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package pitest.test;

public class Library {
public boolean someLibraryMethod() {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package pitest.test;

import spock.lang.Specification;

class LibrarySpock2Spec extends Specification {

void "should generate some mutation coverage"() {
given:
Library classUnderTest = new Library();
expect:
classUnderTest.someLibraryMethod()
}
}
36 changes: 36 additions & 0 deletions src/funcTest/resources/testProjects/testFixtures/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apply plugin: 'com.android.library'
apply plugin: 'java-test-fixtures'
apply plugin: 'pl.droidsonroids.pitest'

buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
//Local/current version of the plugin should be put on a classpath earlier to override that plugin version
// classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.1.7-SNAPSHOT'
}
}

repositories {
mavenCentral()
}

group = "pitest.test"

dependencies {
testImplementation 'junit:junit:4.12'
}

android {
compileSdkVersion 30
defaultConfig {
minSdkVersion 24
targetSdkVersion 30
}
lintOptions {
//ignore missing lint database
abortOnError false
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'testFixtures'
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="pl.droidsonroids.pitest"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package pitest.test;

public class Library {
public boolean someLibraryMethod() {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package pitest.test;

import org.junit.Test;
import pitest.test.Library;

import static org.junit.Assert.*;

public class LibraryTest {
@Test public void testSomeLibraryMethod() {
Library classUnderTest = new Library();
assertTrue("someLibraryMethod should return 'true'", classUnderTest.someLibraryMethod());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ class PitestTask extends JavaExec {

@Override
void exec() {
//Workaround for compatibility with Gradle <4.0 due to setArgs(List) and setJvmArgs(List) added in Gradle 4.0
args = argumentsForPit()
jvmArgs = ((List<String>) getMainProcessJvmArgs().getOrNull() ?: getJvmArgs())
classpath = getLaunchClasspath()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package pl.droidsonroids.gradle.pitest

import groovy.transform.CompileDynamic
import spock.lang.Ignore
import spock.lang.Issue

@CompileDynamic
Expand Down Expand Up @@ -236,13 +235,4 @@ class PitestTaskConfigurationSpec extends BasicProjectBuilderSpec implements Wit
}*.absolutePath
}

@Ignore("TODO move to funcTest")
void "should consider testSourceSets in (additional) classpath"() {
given:
project.android.sourceSets.test.java.srcDir("intTest")
project.pitest.testSourceSets = [project.android.sourceSets.test]
expect:
task.taskArgumentMap()['classPath'].find(".*/intTest") != null
}
}

0 comments on commit 8292e11

Please sign in to comment.