-
Notifications
You must be signed in to change notification settings - Fork 70
[MNG-4660] Add integration test to show that --resume-from works #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
6d84c65
[MNG-4660] Add integration test to show that --resume-from works
mthmulders 3487410
[MNG-4660] Change order of modules in POM
mthmulders 2f7a4b7
[MNG-4660] Introduce a compile-time dependency from module B to A
mthmulders fab1d19
[MNG-4660] Rename test method so it's more descriptive
mthmulders dfe3c4b
[MNG-4660] No longer necessary to first install the whole project loc…
mthmulders a192984
[MNG-4660] Only run test for Maven 3.7.0-SNAPSHOT and up
mthmulders 60e6f00
[MNG-4660] Remove TODO
mthmulders 2f8a107
[MNG-4660] Formatting
mthmulders 0cd4d82
[MNG-4660] Corrected the Maven version to be 3.7.0 instead of -SNAPSHOT.
MartinKanters 78dc772
[MNG-4660] Reverted the change in the other integration test
MartinKanters 0ddc365
[MNG-4660] Putting our integration test on top of the list, to order …
MartinKanters b6dfce3
[MNG-4660] Run test twice, once with packaged and once without packag…
mthmulders 726117c
[MNG-4660] Test case for checking whether a packaged artifact is up t…
mthmulders 0c08966
[MNG-4660] Remove System.err.println invocations
mthmulders 405b475
[MNG-4660] Rename method so it better describes the test
mthmulders daac687
[MNG-4660] Revert unrelated change
mthmulders 44bb379
[MNG-4660] Removed the dependency on the compiler plugin
MartinKanters 4d928bb
[MNG-4660] Changed junit dependencies to version 4.12, which is the s…
MartinKanters 5a15824
Add assertions to analyze failing Linux+JDK8
rfscholte 7d07a92
[MNG-4660] Add dependency on full Hamcrest package
mthmulders 6555381
[MNG-4660] Additional assertions on files being present
mthmulders 38d5503
[MNG-4660] Base assertions and detailed failure message on the same info
mthmulders 65ffad5
[MNG-4660] Add small delay between two Verifier invocations.
mthmulders a6c54d5
[MNG-4660] Share a bit more context why we're doing the ugly Thread.s…
mthmulders File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4660OutdatedPackagedArtifact.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| package org.apache.maven.it; | ||
|
|
||
| /* | ||
| * 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 org.apache.maven.it.util.ResourceExtractor; | ||
| import org.apache.maven.shared.utils.io.FileUtils; | ||
|
|
||
| import java.io.File; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.nio.file.Paths; | ||
|
|
||
| import static org.junit.Assert.assertThat; | ||
| import static org.hamcrest.Matchers.greaterThan; | ||
|
|
||
| /** | ||
| * This is a test case for a new check introduced with <a href="https://issues.apache.org/jira/browse/MNG-4660">MNG-4660</a>. | ||
| * That check verifies if a packaged artifact within the Reactor is up-to-date with the outputDirectory of the same project. | ||
| * | ||
| * @author Maarten Mulders | ||
| * @author Martin Kanters | ||
| */ | ||
| public class MavenITmng4660OutdatedPackagedArtifact extends AbstractMavenIntegrationTestCase { | ||
| public MavenITmng4660OutdatedPackagedArtifact() | ||
| { | ||
| super( "[3.7.0,)" ); | ||
| } | ||
|
|
||
| /** | ||
| * Test that Maven logs a warning when a packaged artifact is found that is older than the outputDirectory of the | ||
| * same artifact. | ||
| */ | ||
| public void testShouldWarnWhenPackagedArtifactIsOutdated() throws Exception | ||
| { | ||
| final File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4660-outdated-packaged-artifact" ); | ||
|
|
||
| // 1. Package the whole project | ||
| final Verifier verifier1 = newVerifier( testDir.getAbsolutePath() ); | ||
| verifier1.deleteDirectory( "target" ); | ||
| verifier1.deleteArtifacts( "org.apache.maven.its.mng4660" ); | ||
|
|
||
| verifier1.executeGoal( "package" ); | ||
|
|
||
| Path module1Jar = testDir.toPath().resolve( "module-a/target/module-a-1.0.jar" ).toAbsolutePath(); | ||
| verifier1.verifyErrorFreeLog(); | ||
| verifier1.assertFilePresent( module1Jar.toString() ); | ||
| verifier1.resetStreams(); | ||
|
|
||
| if ( System.getProperty( "java.version", "" ).startsWith( "1." ) ) | ||
| { | ||
| // Simulating the delay between two invocations. It also makes sure we're not hit by tests that run so fast, | ||
| // that the difference in file modification time (see below) is too small to observe. Java 8 on Linux and | ||
| // macOS returns that value with "just" second precision, which is not detailed enough. | ||
| Thread.sleep( 1_000 ); | ||
| } | ||
|
|
||
| // 2. Create a properties file with some content and compile only that module (module A). | ||
| final Verifier verifier2 = newVerifier( testDir.getAbsolutePath() ); | ||
| final Path resourcesDirectory = Files.createDirectories( Paths.get( testDir.toString(), "module-a", "src", "main", "resources" ) ); | ||
| final Path fileToWrite = resourcesDirectory.resolve( "example.properties" ); | ||
| FileUtils.fileWrite( fileToWrite.toString(), "x=42" ); | ||
|
|
||
| verifier2.setAutoclean( false ); | ||
| verifier2.addCliOption( "--projects" ); | ||
| verifier2.addCliOption( ":module-a" ); | ||
| verifier2.executeGoal( "compile" ); | ||
|
|
||
| Path module1PropertiesFile = testDir.toPath().resolve( "module-a/target/classes/example.properties" ) | ||
| .toAbsolutePath(); | ||
|
|
||
| verifier2.assertFilePresent( module1PropertiesFile.toString() ); | ||
| assertThat( Files.getLastModifiedTime( module1PropertiesFile ), | ||
| greaterThan ( Files.getLastModifiedTime( module1Jar ) ) ); | ||
|
|
||
| Path module1Class = testDir.toPath().resolve( "module-a/target/classes/org/apache/maven/it/Example.class" ) | ||
| .toAbsolutePath(); | ||
| verifier2.verifyErrorFreeLog(); | ||
| verifier2.assertFilePresent( module1Class.toString() ); | ||
| verifier2.resetStreams(); | ||
|
|
||
| // 3. Resume project build from module B, that depends on module A we just touched. Its packaged artifact | ||
| // is no longer in sync with its compiled artifacts. | ||
| final Verifier verifier3 = newVerifier( testDir.getAbsolutePath() ); | ||
| verifier3.setAutoclean( false ); | ||
| verifier3.addCliOption( "--resume-from" ); | ||
| verifier3.addCliOption( ":module-b" ); | ||
| verifier3.executeGoal( "compile" ); | ||
|
|
||
| verifier3.verifyErrorFreeLog(); | ||
| try | ||
| { | ||
| verifier3.verifyTextInLog( "Packaged artifact is not up-to-date" ); | ||
| } | ||
| catch ( VerificationException e ) | ||
| { | ||
| String message = e.getMessage() + System.lineSeparator(); | ||
| message += " " + module1Jar.getFileName() + " -> " + Files.getLastModifiedTime( module1Jar ) | ||
| + System.lineSeparator(); | ||
| message += " " + module1PropertiesFile.getFileName() + " -> " + Files.getLastModifiedTime( module1PropertiesFile ) | ||
| + System.lineSeparator(); | ||
| throw new VerificationException( message, e.getCause() ); | ||
| } | ||
| verifier3.resetStreams(); | ||
| } | ||
| } |
112 changes: 112 additions & 0 deletions
112
core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4660ResumeFromTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| package org.apache.maven.it; | ||
|
|
||
| /* | ||
| * 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 org.apache.maven.it.util.ResourceExtractor; | ||
|
|
||
| import java.io.File; | ||
|
|
||
| /** | ||
| * This is a test case for <a href="https://issues.apache.org/jira/browse/MNG-4660">MNG-4660</a>. | ||
| * | ||
| * @author Maarten Mulders | ||
| * @author Martin Kanters | ||
| */ | ||
| public class MavenITmng4660ResumeFromTest extends AbstractMavenIntegrationTestCase { | ||
| public MavenITmng4660ResumeFromTest() | ||
| { | ||
| super( "[3.7.0,)" ); | ||
| } | ||
|
|
||
| /** | ||
| * Test that the --resume-from flag resolves dependencies inside the same Maven project | ||
| * without having them installed first. | ||
| * This test case uses the target/classes folder of module-a, for the situation where | ||
| * module-a has not been packaged. | ||
| */ | ||
| public void testShouldResolveOutputDirectoryFromEarlierBuild() throws Exception | ||
| { | ||
| final File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4660-resume-from" ); | ||
|
|
||
| final Verifier verifier1 = newVerifier( testDir.getAbsolutePath() ); | ||
| verifier1.deleteDirectory( "target" ); | ||
| verifier1.deleteArtifacts( "org.apache.maven.its.mng4660" ); | ||
|
|
||
| try | ||
| { | ||
| verifier1.executeGoal( "test" ); // The test goal will not create a packaged artifact | ||
| fail( "Expected this invocation to fail" ); // See TestCase.java | ||
| } | ||
| catch ( final VerificationException ve ) | ||
| { | ||
| verifier1.verifyTextInLog( "Deliberately fail test case" ); | ||
| } | ||
| finally | ||
| { | ||
| verifier1.resetStreams(); | ||
| } | ||
|
|
||
| final Verifier verifier2 = newVerifier( testDir.getAbsolutePath() ); | ||
| verifier2.setAutoclean( false ); | ||
| verifier2.addCliOption( "--resume-from" ); | ||
| verifier2.addCliOption( ":module-b" ); | ||
| verifier2.executeGoal( "compile" ); // to prevent the unit test from failing (again) | ||
|
|
||
| verifier2.verifyErrorFreeLog(); | ||
| verifier2.resetStreams(); | ||
| } | ||
|
|
||
| /** | ||
| * Test that the --resume-from flag resolves dependencies inside the same Maven project | ||
| * without having them installed first. | ||
| * This test case uses the packaged artifact of module-a. | ||
| */ | ||
| public void testShouldResolvePackagedArtifactFromEarlierBuild() throws Exception | ||
| { | ||
| final File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4660-resume-from" ); | ||
|
|
||
| final Verifier verifier1 = newVerifier( testDir.getAbsolutePath() ); | ||
| verifier1.deleteDirectory( "target" ); | ||
| verifier1.deleteArtifacts( "org.apache.maven.its.mng4660" ); | ||
|
|
||
| try | ||
| { | ||
| verifier1.executeGoal( "verify" ); // The verify goal will create a packaged artifact | ||
| fail( "Expected this invocation to fail" ); // See TestCase.java | ||
| } | ||
| catch ( final VerificationException ve ) | ||
| { | ||
| verifier1.verifyTextInLog( "Deliberately fail test case" ); | ||
| } | ||
| finally | ||
| { | ||
| verifier1.resetStreams(); | ||
| } | ||
|
|
||
| final Verifier verifier2 = newVerifier( testDir.getAbsolutePath() ); | ||
| verifier2.setAutoclean( false ); | ||
| verifier2.addCliOption( "--resume-from" ); | ||
| verifier2.addCliOption( ":module-b" ); | ||
| verifier2.executeGoal( "compile" ); // to prevent the unit test from failing (again) | ||
|
|
||
| verifier2.verifyErrorFreeLog(); | ||
| verifier2.resetStreams(); | ||
| } | ||
| } | ||
36 changes: 36 additions & 0 deletions
36
core-it-suite/src/test/resources/mng-4660-outdated-packaged-artifact/module-a/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| <?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> | ||
|
|
||
| <artifactId>module-a</artifactId> | ||
|
|
||
| <parent> | ||
| <groupId>org.apache.maven.its.mng4660</groupId> | ||
| <artifactId>parent</artifactId> | ||
| <version>1.0</version> | ||
| </parent> | ||
|
|
||
| </project> |
24 changes: 24 additions & 0 deletions
24
...g-4660-outdated-packaged-artifact/module-a/src/main/java/org/apache/maven/it/Example.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package org.apache.maven.it; | ||
|
|
||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| public class Example | ||
| { | ||
| } |
44 changes: 44 additions & 0 deletions
44
core-it-suite/src/test/resources/mng-4660-outdated-packaged-artifact/module-b/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| <?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> | ||
|
|
||
| <artifactId>module-b</artifactId> | ||
|
|
||
| <parent> | ||
| <groupId>org.apache.maven.its.mng4660</groupId> | ||
| <artifactId>parent</artifactId> | ||
| <version>1.0</version> | ||
| </parent> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.apache.maven.its.mng4660</groupId> | ||
| <artifactId>module-a</artifactId> | ||
| <version>1.0</version> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| </project> |
28 changes: 28 additions & 0 deletions
28
...outdated-packaged-artifact/module-b/src/main/java/org/apache/maven/it/AnotherExample.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package org.apache.maven.it; | ||
|
|
||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| public class AnotherExample | ||
| { | ||
| public AnotherExample() | ||
| { | ||
| new Example(); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.