michael-o commented on a change in pull request #66: URL: https://github.com/apache/maven-integration-testing/pull/66#discussion_r439849717
########## File path: core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5669ReadPomsOnce.java ########## @@ -96,4 +97,58 @@ public void testit() } assertEquals( uniqueBuildingSources.size(), 167 /* is 168 minus superpom */ ); } + + public void testWithBuildConsumer() + throws Exception + { + // prepare JavaAgent + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5669-read-poms-once" ); + Verifier verifier = newVerifier( testDir.getAbsolutePath(), false ); + Map<String, String> filterProperties = + Collections.singletonMap( "${javaAgentJar}", + verifier.getArtifactPath( "mng-coreit", "javaagent", "1.0-SNAPSHOT", "jar" ) ); + verifier.filterFile( ".mvn/jvm.config", ".mvn/jvm.config", null, filterProperties ); + + verifier.setForkJvm( true ); // pick up agent + verifier.setMavenDebug( false ); + verifier.setAutoclean( false ); + verifier.addCliOption( "-q" ); + verifier.addCliOption( "-U" ); + verifier.addCliOption( "-Dmaven.experimental.buildconsumer=true" ); + verifier.executeGoals( Arrays.asList( "verify" ) ); + verifier.resetStreams(); + + List<String> logTxt = verifier.loadLines( "log.txt", "utf-8" ); + for ( String line : logTxt ) + { + if ( line.startsWith( "Picked up JAVA_TOOL_OPTIONS:" ) ) + { + logTxt.remove( line ); + break; + } + } + assertEquals( logTxt.toString(), 168 + 4 /* reactor poms are read twice: file + raw (=XMLFilters) */, logTxt.size() ); + + // analyze lines. It is a Hashmap, so we can't rely on the order + Set<String> uniqueBuildingSources = new HashSet<>( 168 ); + final String buildSourceKey = "org.apache.maven.model.building.source="; + final int keyLength = buildSourceKey.length(); + for( String line : logTxt ) + { + int start = line.indexOf( buildSourceKey ); + if ( start < 0 ) + { + continue; + } + + int end = line.indexOf(", ", start); + if ( end < 0) Review comment: Whitespace missing ########## File path: core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5669ReadPomsOnce.java ########## @@ -96,4 +97,58 @@ public void testit() } assertEquals( uniqueBuildingSources.size(), 167 /* is 168 minus superpom */ ); } + + public void testWithBuildConsumer() + throws Exception + { + // prepare JavaAgent + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5669-read-poms-once" ); + Verifier verifier = newVerifier( testDir.getAbsolutePath(), false ); + Map<String, String> filterProperties = + Collections.singletonMap( "${javaAgentJar}", + verifier.getArtifactPath( "mng-coreit", "javaagent", "1.0-SNAPSHOT", "jar" ) ); + verifier.filterFile( ".mvn/jvm.config", ".mvn/jvm.config", null, filterProperties ); + + verifier.setForkJvm( true ); // pick up agent + verifier.setMavenDebug( false ); + verifier.setAutoclean( false ); + verifier.addCliOption( "-q" ); + verifier.addCliOption( "-U" ); + verifier.addCliOption( "-Dmaven.experimental.buildconsumer=true" ); + verifier.executeGoals( Arrays.asList( "verify" ) ); + verifier.resetStreams(); + + List<String> logTxt = verifier.loadLines( "log.txt", "utf-8" ); + for ( String line : logTxt ) + { + if ( line.startsWith( "Picked up JAVA_TOOL_OPTIONS:" ) ) + { + logTxt.remove( line ); + break; + } + } + assertEquals( logTxt.toString(), 168 + 4 /* reactor poms are read twice: file + raw (=XMLFilters) */, logTxt.size() ); + + // analyze lines. It is a Hashmap, so we can't rely on the order + Set<String> uniqueBuildingSources = new HashSet<>( 168 ); + final String buildSourceKey = "org.apache.maven.model.building.source="; + final int keyLength = buildSourceKey.length(); + for( String line : logTxt ) + { + int start = line.indexOf( buildSourceKey ); + if ( start < 0 ) + { + continue; + } + + int end = line.indexOf(", ", start); Review comment: Whitespace missing ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org