Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
| 20 | // Following Gradle best practices to keep build logic organized |
| 21 | |
| 22 | // Bundle the test classes in a JAR for other Ant based builds |
| 23 | task testJar(type: Jar, group: 'Build') { |
| 24 | description = 'Assembles a jar archive containing the test classes.' |
| 25 | project.test.dependsOn it |
| 26 | |
| 27 | classifier 'test' |
| 28 | from sourceSets.test.output |
| 29 | } |
| 30 | |
| 31 | // ---------------------------------------------------------------------------- |
| 32 | // Unit test tasks and configurations |
| 33 | |
| 34 | // Help the up to date algorithm to make these tests done |
| 35 | ext.markTaskDone = { task -> |
| 36 | def buildFile = file("$buildDir/${task.name}.flag") |
| 37 | task.inputs.files task.classpath |
| 38 | task.outputs.file buildFile |
| 39 | task.doLast { |
| 40 | buildFile.text = 'Passed!' |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | task deprecatedEqualityTest(type: JavaExec, group: 'Verification') { |
| 45 | description = 'Run the non-JUnit test suite ' |
| 46 | classpath = sourceSets.test.runtimeClasspath |
| 47 | main 'org.apache.thrift.test.EqualityTest' |
| 48 | markTaskDone(it) |
| 49 | } |
| 50 | |
| 51 | task deprecatedJavaBeansTest(type: JavaExec, group: 'Verification') { |
| 52 | description = 'Run the non-JUnit test suite ' |
| 53 | classpath = sourceSets.test.runtimeClasspath |
| 54 | main 'org.apache.thrift.test.JavaBeansTest' |
| 55 | markTaskDone(it) |
| 56 | } |
| 57 | |
| 58 | // Main Unit Test task configuration |
| 59 | test { |
| 60 | description="Run the full test suite" |
| 61 | dependsOn deprecatedEqualityTest, deprecatedJavaBeansTest |
| 62 | |
| 63 | // Allow repeating tests even after successful execution |
| 64 | if (project.hasProperty('rerunTests')) { |
| 65 | outputs.upToDateWhen { false } |
| 66 | } |
| 67 | |
| 68 | include '**/Test*.class' |
| 69 | exclude '**/Test*\$*.class' |
| 70 | |
Jiayu Liu | 0c9c9df | 2022-05-06 03:30:52 +0800 | [diff] [blame] | 71 | // https://junit.org/junit5/docs/current/user-guide/#running-tests-build-gradle |
| 72 | useJUnitPlatform() { |
| 73 | // https://junit.org/junit5/docs/current/user-guide/#writing-tests-parallel-execution |
| 74 | systemProperty("junit.jupiter.execution.parallel.enabled", "true") |
| 75 | systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent") |
| 76 | systemProperty("junit.jupiter.execution.parallel.mode.classes.default", "concurrent") |
| 77 | } |
| 78 | |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 79 | maxHeapSize = '512m' |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 80 | |
| 81 | systemProperties = [ |
| 82 | 'build.test': "${compileTestJava.destinationDir}", |
| 83 | 'test.port': "${testPort}", |
Jiayu Liu | eac5103 | 2022-03-11 04:55:13 +0100 | [diff] [blame] | 84 | 'javax.net.ssl.trustStore': "${projectDir}/src/crossTest/resources/.truststore", |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 85 | 'javax.net.ssl.trustStorePassword': 'thrift', |
Jiayu Liu | eac5103 | 2022-03-11 04:55:13 +0100 | [diff] [blame] | 86 | 'javax.net.ssl.keyStore': "${projectDir}/src/crossTest/resources/.keystore", |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 87 | 'javax.net.ssl.keyStorePassword': 'thrift' |
| 88 | ] |
| 89 | } |