This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git
commit 27cd238399e7e1d4e89e9a894a9cabe111158ff8 Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Wed Nov 4 20:12:03 2026 +0000 Fix two vacuous IT verify scripts and merge three IT pairs MINVOKER-289 asserted a File object, which is always truthy, instead of its existence. not-clone-not-plugin checked target/it/clone-clean, but a plugin-style default clone would go to target/its, so it passed either way. Fixes #799 --- src/it/MINVOKER-289/verify.groovy | 2 +- src/it/fail-ignore-with-verify/pom.xml | 67 ---------------------- .../fail-ignore-with-verify/src/it/project/pom.xml | 32 ----------- src/it/fail-ignore/pom.xml | 15 ++++- src/it/not-clone-not-plugin/verify.groovy | 17 ++---- src/it/rerun-build-invoker-test-in-config/pom.xml | 63 -------------------- .../src/it/project/pom.xml | 33 ----------- .../src/it/project/postbuild.groovy | 26 --------- .../verify.groovy | 29 ---------- src/it/rerun-build-invoker-test/invoker.properties | 8 ++- src/it/rerun-build-invoker-test/pom.xml | 8 ++- src/it/rerun-build-invoker-test/verify.groovy | 25 +++++--- src/it/script-streamLogs-false/verify.groovy | 49 ---------------- src/it/script-streamLogs-true/pom.xml | 67 ---------------------- .../src/it/beanshell/pom.xml | 32 ----------- .../src/it/beanshell/setup.bsh | 29 ---------- .../script-streamLogs-true/src/it/groovy/pom.xml | 32 ----------- .../src/it/groovy/setup.groovy | 30 ---------- src/it/script-streamLogs-true/verify.groovy | 49 ---------------- .../invoker.properties | 7 ++- .../pom.xml | 6 +- .../src/it/beanshell/pom.xml | 0 .../src/it/beanshell/setup.bsh | 0 .../src/it/groovy/pom.xml | 0 .../src/it/groovy/setup.groovy | 0 src/it/script-streamLogs/verify.groovy | 67 ++++++++++++++++++++++ 26 files changed, 125 insertions(+), 568 deletions(-) diff --git a/src/it/MINVOKER-289/verify.groovy b/src/it/MINVOKER-289/verify.groovy index 6184c1a..1b2e85d 100644 --- a/src/it/MINVOKER-289/verify.groovy +++ b/src/it/MINVOKER-289/verify.groovy @@ -20,7 +20,7 @@ import java.util.stream.Collectors * under the License. */ -assert new File( basedir, 'target/it/project/touch.txt' ) +assert new File( basedir, 'target/it/project/touch.txt' ).exists() File buildLog = new File( basedir, 'build.log' ) diff --git a/src/it/fail-ignore-with-verify/pom.xml b/src/it/fail-ignore-with-verify/pom.xml deleted file mode 100644 index 8092137..0000000 --- a/src/it/fail-ignore-with-verify/pom.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you 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. ---> - -<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/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <groupId>org.apache.maven.plugins.invoker</groupId> - <artifactId>fail-ignore</artifactId> - <version>1.0-SNAPSHOT</version> - <packaging>pom</packaging> - - <description>Test to check that a failure in the forked Maven builds is ignored.</description> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-invoker-plugin</artifactId> - <version>@project.version@</version> - <configuration> - <debug>true</debug> - <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo> - <pomIncludes> - <pomInclude>*/pom.xml</pomInclude> - </pomIncludes> - <goals> - <goal>invalid-phase-to-fail-build</goal> - </goals> - <ignoreFailures>true</ignoreFailures> - </configuration> - <executions> - <execution> - <id>integration-test</id> - <phase>initialize</phase> - <goals> - <goal>integration-test</goal> - <goal>verify</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - -</project> diff --git a/src/it/fail-ignore-with-verify/src/it/project/pom.xml b/src/it/fail-ignore-with-verify/src/it/project/pom.xml deleted file mode 100644 index b80df76..0000000 --- a/src/it/fail-ignore-with-verify/src/it/project/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you 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. ---> - -<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/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>test</groupId> - <artifactId>fail-ignore</artifactId> - <version>0.1-SNAPSHOT</version> - <packaging>jar</packaging> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> -</project> diff --git a/src/it/fail-ignore/pom.xml b/src/it/fail-ignore/pom.xml index d8aa363..c1cea18 100644 --- a/src/it/fail-ignore/pom.xml +++ b/src/it/fail-ignore/pom.xml @@ -27,7 +27,10 @@ under the License. <version>1.0-SNAPSHOT</version> <packaging>pom</packaging> - <description>Test to check that a failure in the forked Maven builds is ignored.</description> + <description> + Test to check that a failure in the forked Maven builds is ignored by the run goal as well as by + the integration-test and verify goals. + </description> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> @@ -52,12 +55,20 @@ under the License. </configuration> <executions> <execution> - <id>integration-test</id> + <id>run</id> <phase>initialize</phase> <goals> <goal>run</goal> </goals> </execution> + <execution> + <id>integration-test-and-verify</id> + <phase>initialize</phase> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> </executions> </plugin> </plugins> diff --git a/src/it/not-clone-not-plugin/verify.groovy b/src/it/not-clone-not-plugin/verify.groovy index b219ae5..8876bf8 100644 --- a/src/it/not-clone-not-plugin/verify.groovy +++ b/src/it/not-clone-not-plugin/verify.groovy @@ -17,15 +17,10 @@ * under the License. */ -import java.io.*; +// the project is not a maven-plugin, so cloning is off: no clone directory, neither the one the +// plugin would use by default for plugin projects nor the one other ITs configure +assert !new File( basedir, "target/its" ).exists() +assert !new File( basedir, "target/it" ).exists() -try -{ - File itRoot = new File( basedir, "target/it/clone-clean" ); - return !itRoot.exists(); -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} +// and the nested project was built in place +assert new File( basedir, "src/it/clone-clean/build.log" ).isFile() diff --git a/src/it/rerun-build-invoker-test-in-config/pom.xml b/src/it/rerun-build-invoker-test-in-config/pom.xml deleted file mode 100644 index 542f07c..0000000 --- a/src/it/rerun-build-invoker-test-in-config/pom.xml +++ /dev/null @@ -1,63 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you 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. ---> - -<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/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <groupId>org.apache.maven.plugins.invoker</groupId> - <artifactId>rerun-build-invoker-test-in-config</artifactId> - <version>1.0-SNAPSHOT</version> - <packaging>pom</packaging> - - <description>Test to check that failed jobs are rerun when invokerTest is used in plugin configuration</description> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-invoker-plugin</artifactId> - <version>@project.version@</version> - <configuration> - <rerunFailingTestsCount>1</rerunFailingTestsCount> - <invokerTest>project</invokerTest> - <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo> - <goals> - <goal>validate</goal> - </goals> - </configuration> - <executions> - <execution> - <id>integration-test</id> - <phase>initialize</phase> - <goals> - <goal>run</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - -</project> diff --git a/src/it/rerun-build-invoker-test-in-config/src/it/project/pom.xml b/src/it/rerun-build-invoker-test-in-config/src/it/project/pom.xml deleted file mode 100644 index a787ea9..0000000 --- a/src/it/rerun-build-invoker-test-in-config/src/it/project/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you 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. ---> - -<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/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>test</groupId> - <artifactId>rerun-build</artifactId> - <version>0.1-SNAPSHOT</version> - <packaging>pom</packaging> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> - -</project> diff --git a/src/it/rerun-build-invoker-test-in-config/src/it/project/postbuild.groovy b/src/it/rerun-build-invoker-test-in-config/src/it/project/postbuild.groovy deleted file mode 100644 index 82978ca..0000000 --- a/src/it/rerun-build-invoker-test-in-config/src/it/project/postbuild.groovy +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -def touchFile = new File(basedir, 'touch.txt') -if (!touchFile.exists()) { - touchFile.text = 'touch' - return false -} - -true diff --git a/src/it/rerun-build-invoker-test-in-config/verify.groovy b/src/it/rerun-build-invoker-test-in-config/verify.groovy deleted file mode 100644 index d5f1799..0000000 --- a/src/it/rerun-build-invoker-test-in-config/verify.groovy +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -def buildLog = new File(basedir, 'build.log').text - -assert !buildLog.contains('Rerunning of failed jobs is disabled') - -// selecting a project in the plugin configuration doesn't disable rerunning -assert buildLog.count('FAILED') == 1 -assert buildLog.count('SUCCESS (') == 1 -assert buildLog.contains('Rerunning 1 failed job') - -assert new File(basedir, 'target/it/project/build.log.1').exists() diff --git a/src/it/rerun-build-invoker-test/invoker.properties b/src/it/rerun-build-invoker-test/invoker.properties index 54a3782..3076223 100644 --- a/src/it/rerun-build-invoker-test/invoker.properties +++ b/src/it/rerun-build-invoker-test/invoker.properties @@ -15,5 +15,9 @@ # specific language governing permissions and limitations # under the License. -invoker.goals = initialize -Dinvoker.test=project -invoker.buildResult = failure +# 1: the project is selected with the invoker.test user property, a failed job is not rerun +invoker.goals.1 = initialize -Dinvoker.test=project -Dit.dir=it-user-property +invoker.buildResult.1 = failure +# 2: the same project is selected in the plugin configuration only, a failed job is rerun +invoker.goals.2 = initialize -Dit.dir=it-config +invoker.buildResult.2 = success diff --git a/src/it/rerun-build-invoker-test/pom.xml b/src/it/rerun-build-invoker-test/pom.xml index ebc2140..2c3a587 100644 --- a/src/it/rerun-build-invoker-test/pom.xml +++ b/src/it/rerun-build-invoker-test/pom.xml @@ -27,7 +27,10 @@ under the License. <version>1.0-SNAPSHOT</version> <packaging>pom</packaging> - <description>Test to check that failed jobs are not rerun when invoker.test is used</description> + <description> + Test to check that failed jobs are not rerun when invoker.test is used, but are rerun when invokerTest is + only set in the plugin configuration. + </description> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> @@ -41,7 +44,8 @@ under the License. <version>@project.version@</version> <configuration> <rerunFailingTestsCount>1</rerunFailingTestsCount> - <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo> + <invokerTest>project</invokerTest> + <cloneProjectsTo>${project.build.directory}/${it.dir}</cloneProjectsTo> <goals> <goal>validate</goal> </goals> diff --git a/src/it/rerun-build-invoker-test/verify.groovy b/src/it/rerun-build-invoker-test/verify.groovy index 4360b0d..20aa187 100644 --- a/src/it/rerun-build-invoker-test/verify.groovy +++ b/src/it/rerun-build-invoker-test/verify.groovy @@ -17,13 +17,24 @@ * under the License. */ +// both invocations of this IT write to build.log, the second one starts with the header of this project def buildLog = new File(basedir, 'build.log').text +String header = '[INFO] Building rerun-build-invoker-test 1.0-SNAPSHOT' +int second = buildLog.indexOf(header, buildLog.indexOf(header) + 1) +assert second > 0 : 'build.log has only one invocation' -assert buildLog.contains('Rerunning of failed jobs is disabled when the invoker.test user property is used') +// invoker.test given as user property: the selected project was executed only once - no rerun +def userPropertyLog = buildLog.substring(0, second) +assert userPropertyLog.contains('Rerunning of failed jobs is disabled when the invoker.test user property is used') +assert userPropertyLog.count('FAILED') == 1 +assert !userPropertyLog.contains('SUCCESS ') +assert !userPropertyLog.contains('Rerunning 1 failed job') +assert !new File(basedir, 'target/it-user-property/project/build.log.1').exists() -// the selected project was executed only once - no rerun -assert buildLog.count('FAILED') == 1 -assert !buildLog.contains('SUCCESS ') -assert !buildLog.contains('Rerunning 1 failed job') - -assert !new File(basedir, 'target/it/project/build.log.1').exists() +// invokerTest only in the plugin configuration: selecting a project doesn't disable rerunning +def configLog = buildLog.substring(second) +assert !configLog.contains('Rerunning of failed jobs is disabled') +assert configLog.count('FAILED') == 1 +assert configLog.count('SUCCESS (') == 1 +assert configLog.contains('Rerunning 1 failed job') +assert new File(basedir, 'target/it-config/project/build.log.1').exists() diff --git a/src/it/script-streamLogs-false/verify.groovy b/src/it/script-streamLogs-false/verify.groovy deleted file mode 100644 index 7bd3293..0000000 --- a/src/it/script-streamLogs-false/verify.groovy +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -def FS = File.separator - -// make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else, -// so check if touch.txt exist - -assert new File(basedir, 'target/its/beanshell/touch.txt').exists() -assert new File(basedir, 'target/its/groovy/touch.txt').exists() - -// logs -def buildLog = new File(basedir, 'build.log').text -def beanshellLog = new File(basedir, 'target/its/beanshell/build.log').text -def groovyLog = new File(basedir, 'target/its/groovy/build.log').text - -// beanshell failed and no log message -assert !buildLog.contains('[INFO] Output form beanshell script') -assert buildLog.contains('[INFO] org.apache.maven.shared.scriptinterpreter.ScriptEvaluationException: java.lang.OutOfMemoryError: Requested array size exceeds VM limit') -assert buildLog.contains('[INFO] beanshell' + FS + 'pom.xml ................................ FAILED') - -assert beanshellLog.contains('Output form beanshell script') -assert beanshellLog.contains('java.lang.OutOfMemoryError: Requested array size exceeds VM limit') - -// groovy failed and no log message -assert !buildLog.contains('[INFO] Output from groovy script') -assert buildLog.contains('Assertion failed:') -assert buildLog.contains('assert pom.contains("<modelVersion>9.9.9</modelVersion>")') -assert buildLog.contains('[INFO] groovy' + FS + 'pom.xml ................................... FAILED') - -assert groovyLog.contains('Output from groovy script') -assert groovyLog.contains('Assertion failed:') -assert groovyLog.contains('assert pom.contains("<modelVersion>9.9.9</modelVersion>")') diff --git a/src/it/script-streamLogs-true/pom.xml b/src/it/script-streamLogs-true/pom.xml deleted file mode 100644 index 52fd744..0000000 --- a/src/it/script-streamLogs-true/pom.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you 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. ---> - -<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/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <groupId>org.apache.maven.plugins.invoker</groupId> - <artifactId>script-streamLogs-true</artifactId> - <version>1.0-SNAPSHOT</version> - <packaging>pom</packaging> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-invoker-plugin</artifactId> - <version>@project.version@</version> - <configuration> - <writeJunitReport>true</writeJunitReport> - <cloneProjectsTo>${project.build.directory}/its</cloneProjectsTo> - <pomIncludes> - <pomInclude>*/pom.xml</pomInclude> - </pomIncludes> - <preBuildHookScript>setup</preBuildHookScript> - <goals> - <goal>validate</goal> - </goals> - <ignoreFailures>true</ignoreFailures> - <streamLogs>true</streamLogs> - <streamLogsOnFailures>false</streamLogsOnFailures> - </configuration> - <executions> - <execution> - <id>integration-test</id> - <phase>initialize</phase> - <goals> - <goal>run</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - -</project> diff --git a/src/it/script-streamLogs-true/src/it/beanshell/pom.xml b/src/it/script-streamLogs-true/src/it/beanshell/pom.xml deleted file mode 100644 index f8a5c6a..0000000 --- a/src/it/script-streamLogs-true/src/it/beanshell/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you 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. ---> - -<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/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>test</groupId> - <artifactId>beanshell</artifactId> - <version>0.1-SNAPSHOT</version> - <packaging>pom</packaging> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> -</project> diff --git a/src/it/script-streamLogs-true/src/it/beanshell/setup.bsh b/src/it/script-streamLogs-true/src/it/beanshell/setup.bsh deleted file mode 100644 index 5f0bc34..0000000 --- a/src/it/script-streamLogs-true/src/it/beanshell/setup.bsh +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -import java.io.*; - -// marker for parent build that this sub build was indeed run -File touchFile = new File( basedir, "touch.txt" ); -touchFile.createNewFile(); - -System.out.println("Output form beanshell script"); - -// BeanShell does not allow us to simply throw an error, so will we try to trigger an OutOfMemoryError... -long[] arr = new long[ Integer.MAX_VALUE ]; diff --git a/src/it/script-streamLogs-true/src/it/groovy/pom.xml b/src/it/script-streamLogs-true/src/it/groovy/pom.xml deleted file mode 100644 index b1ba49e..0000000 --- a/src/it/script-streamLogs-true/src/it/groovy/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you 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. ---> - -<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/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>test</groupId> - <artifactId>groovy</artifactId> - <version>0.1-SNAPSHOT</version> - <packaging>pom</packaging> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> -</project> diff --git a/src/it/script-streamLogs-true/src/it/groovy/setup.groovy b/src/it/script-streamLogs-true/src/it/groovy/setup.groovy deleted file mode 100644 index fc18103..0000000 --- a/src/it/script-streamLogs-true/src/it/groovy/setup.groovy +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -import java.io.*; - -// marker for parent build that this sub build was indeed run -File touchFile = new File( basedir, "touch.txt" ) -touchFile.createNewFile() - -println("Output from groovy script") - -def pom = new File( basedir, "pom.xml" ).text -assert pom.contains("<modelVersion>9.9.9</modelVersion>") - diff --git a/src/it/script-streamLogs-true/verify.groovy b/src/it/script-streamLogs-true/verify.groovy deleted file mode 100644 index c56f20d..0000000 --- a/src/it/script-streamLogs-true/verify.groovy +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -def FS = File.separator - -// make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else, -// so check if touch.txt exist - -assert new File(basedir, 'target/its/beanshell/touch.txt').exists() -assert new File(basedir, 'target/its/groovy/touch.txt').exists() - -// logs -def buildLog = new File(basedir, 'build.log').text -def beanshellLog = new File(basedir, 'target/its/beanshell/build.log').text -def groovyLog = new File(basedir, 'target/its/groovy/build.log').text - -// beanshell failed and log message -assert buildLog.contains('[INFO] Output form beanshell script') -assert buildLog.contains('java.lang.OutOfMemoryError: Requested array size exceeds VM limit') -assert buildLog.contains('[INFO] beanshell' + FS + 'pom.xml ................................ FAILED') - -assert beanshellLog.contains('Output form beanshell script') -assert beanshellLog.contains('java.lang.OutOfMemoryError: Requested array size exceeds VM limit') - -// groovy failed and log message -assert buildLog.contains('[INFO] Output from groovy script') -assert buildLog.contains('Assertion failed:') -assert buildLog.contains('assert pom.contains("<modelVersion>9.9.9</modelVersion>")') -assert buildLog.contains('[INFO] groovy' + FS + 'pom.xml ................................... FAILED') - -assert groovyLog.contains('Output from groovy script') -assert groovyLog.contains('Assertion failed:') -assert groovyLog.contains('assert pom.contains("<modelVersion>9.9.9</modelVersion>")') diff --git a/src/it/rerun-build-invoker-test/invoker.properties b/src/it/script-streamLogs/invoker.properties similarity index 69% copy from src/it/rerun-build-invoker-test/invoker.properties copy to src/it/script-streamLogs/invoker.properties index 54a3782..7616a41 100644 --- a/src/it/rerun-build-invoker-test/invoker.properties +++ b/src/it/script-streamLogs/invoker.properties @@ -15,5 +15,8 @@ # specific language governing permissions and limitations # under the License. -invoker.goals = initialize -Dinvoker.test=project -invoker.buildResult = failure + +# 1: streamLogs=false, the output of the failed scripts is only written to the build logs of the projects +invoker.goals.1 = initialize -Dstream.logs=false -Dit.dir=its-stream-false +# 2: streamLogs=true, the output of the scripts is also streamed to the build log of this IT +invoker.goals.2 = initialize -Dstream.logs=true -Dit.dir=its-stream-true diff --git a/src/it/script-streamLogs-false/pom.xml b/src/it/script-streamLogs/pom.xml similarity index 92% rename from src/it/script-streamLogs-false/pom.xml rename to src/it/script-streamLogs/pom.xml index 268e3eb..0af3b47 100644 --- a/src/it/script-streamLogs-false/pom.xml +++ b/src/it/script-streamLogs/pom.xml @@ -23,7 +23,7 @@ under the License. <modelVersion>4.0.0</modelVersion> <groupId>org.apache.maven.plugins.invoker</groupId> - <artifactId>script-streamLogs-false</artifactId> + <artifactId>script-streamLogs</artifactId> <version>1.0-SNAPSHOT</version> <packaging>pom</packaging> @@ -39,7 +39,7 @@ under the License. <version>@project.version@</version> <configuration> <writeJunitReport>true</writeJunitReport> - <cloneProjectsTo>${project.build.directory}/its</cloneProjectsTo> + <cloneProjectsTo>${project.build.directory}/${it.dir}</cloneProjectsTo> <pomIncludes> <pomInclude>*/pom.xml</pomInclude> </pomIncludes> @@ -48,7 +48,7 @@ under the License. <goal>validate</goal> </goals> <ignoreFailures>true</ignoreFailures> - <streamLogs>false</streamLogs> + <streamLogs>${stream.logs}</streamLogs> <streamLogsOnFailures>false</streamLogsOnFailures> </configuration> <executions> diff --git a/src/it/script-streamLogs-false/src/it/beanshell/pom.xml b/src/it/script-streamLogs/src/it/beanshell/pom.xml similarity index 100% rename from src/it/script-streamLogs-false/src/it/beanshell/pom.xml rename to src/it/script-streamLogs/src/it/beanshell/pom.xml diff --git a/src/it/script-streamLogs-false/src/it/beanshell/setup.bsh b/src/it/script-streamLogs/src/it/beanshell/setup.bsh similarity index 100% rename from src/it/script-streamLogs-false/src/it/beanshell/setup.bsh rename to src/it/script-streamLogs/src/it/beanshell/setup.bsh diff --git a/src/it/script-streamLogs-false/src/it/groovy/pom.xml b/src/it/script-streamLogs/src/it/groovy/pom.xml similarity index 100% rename from src/it/script-streamLogs-false/src/it/groovy/pom.xml rename to src/it/script-streamLogs/src/it/groovy/pom.xml diff --git a/src/it/script-streamLogs-false/src/it/groovy/setup.groovy b/src/it/script-streamLogs/src/it/groovy/setup.groovy similarity index 100% rename from src/it/script-streamLogs-false/src/it/groovy/setup.groovy rename to src/it/script-streamLogs/src/it/groovy/setup.groovy diff --git a/src/it/script-streamLogs/verify.groovy b/src/it/script-streamLogs/verify.groovy new file mode 100644 index 0000000..39e88a0 --- /dev/null +++ b/src/it/script-streamLogs/verify.groovy @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +def FS = File.separator + +// both invocations of this IT write to build.log, the second one starts with the header of this project: +// the first has streamLogs=false, the second streamLogs=true +def buildLog = new File(basedir, 'build.log').text +String header = '[INFO] Building script-streamLogs 1.0-SNAPSHOT' +int second = buildLog.indexOf(header, buildLog.indexOf(header) + 1) +assert second > 0 : 'build.log has only one invocation' + +// the build logs of the projects are in the clone directory of the respective invocation +for ( String itDir : [ 'its-stream-false', 'its-stream-true' ] ) { + // make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else, + // so check if touch.txt exist + assert new File(basedir, "target/${itDir}/beanshell/touch.txt").exists() + assert new File(basedir, "target/${itDir}/groovy/touch.txt").exists() + + def beanshellLog = new File(basedir, "target/${itDir}/beanshell/build.log").text + assert beanshellLog.contains('Output form beanshell script') + assert beanshellLog.contains('java.lang.OutOfMemoryError: Requested array size exceeds VM limit') + def groovyLog = new File(basedir, "target/${itDir}/groovy/build.log").text + assert groovyLog.contains('Output from groovy script') + assert groovyLog.contains('Assertion failed:') + assert groovyLog.contains('assert pom.contains("<modelVersion>9.9.9</modelVersion>")') +} + +// streamLogs=false: failed scripts show no output in the build log +def notStreamed = buildLog.substring(0, second) +// beanshell failed and no log message +assert !notStreamed.contains('[INFO] Output form beanshell script') +assert notStreamed.contains('[INFO] org.apache.maven.shared.scriptinterpreter.ScriptEvaluationException: java.lang.OutOfMemoryError: Requested array size exceeds VM limit') +assert notStreamed.contains('[INFO] beanshell' + FS + 'pom.xml ................................ FAILED') +// groovy failed and no log message +assert !notStreamed.contains('[INFO] Output from groovy script') +assert notStreamed.contains('Assertion failed:') +assert notStreamed.contains('assert pom.contains("<modelVersion>9.9.9</modelVersion>")') +assert notStreamed.contains('[INFO] groovy' + FS + 'pom.xml ................................... FAILED') + +// streamLogs=true: the output of the failed scripts is in the build log +def streamed = buildLog.substring(second) +// beanshell failed and log message +assert streamed.contains('[INFO] Output form beanshell script') +assert streamed.contains('java.lang.OutOfMemoryError: Requested array size exceeds VM limit') +assert streamed.contains('[INFO] beanshell' + FS + 'pom.xml ................................ FAILED') +// groovy failed and log message +assert streamed.contains('[INFO] Output from groovy script') +assert streamed.contains('Assertion failed:') +assert streamed.contains('assert pom.contains("<modelVersion>9.9.9</modelVersion>")') +assert streamed.contains('[INFO] groovy' + FS + 'pom.xml ................................... FAILED')
