From c29fb00f8ff6dfc9c187ad8b727c112720b0daaa Mon Sep 17 00:00:00 2001 From: Josh Friend Date: Mon, 8 Jan 2024 16:29:20 -0500 Subject: [PATCH 1/2] Run help on root project to speed up project probe Signed-off-by: Josh Friend --- ...DefaultGradleBuildConfigurationReader.java | 2 +- .../AbstractProfilerIntegrationTest.groovy | 6 ++--- .../profiler/BenchmarkIntegrationTest.groovy | 6 ++--- .../profiler/ProfilerIntegrationTest.groovy | 26 +++++++++---------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/gradle/profiler/gradle/DefaultGradleBuildConfigurationReader.java b/src/main/java/org/gradle/profiler/gradle/DefaultGradleBuildConfigurationReader.java index 501e3f93..863f305a 100644 --- a/src/main/java/org/gradle/profiler/gradle/DefaultGradleBuildConfigurationReader.java +++ b/src/main/java/org/gradle/profiler/gradle/DefaultGradleBuildConfigurationReader.java @@ -126,7 +126,7 @@ private GradleBuildConfiguration probe(GradleConnector connector) { GradleBuildConfiguration version; try (ProjectConnection connection = connector.forProjectDirectory(projectDir).connect()) { BuildEnvironment buildEnvironment = connection.getModel(BuildEnvironment.class); - new ToolingApiGradleClient(connection).runTasks(ImmutableList.of("help"), ImmutableList.of("-I", initScript.getAbsolutePath()), ImmutableList.of()); + new ToolingApiGradleClient(connection).runTasks(ImmutableList.of(":help"), ImmutableList.of("-I", initScript.getAbsolutePath()), ImmutableList.of()); BuildDetails buildDetails = readBuildDetails(); JavaEnvironment javaEnvironment = buildEnvironment.getJava(); List allJvmArgs = new ArrayList<>(javaEnvironment.getJvmArguments()); diff --git a/src/test/groovy/org/gradle/profiler/AbstractProfilerIntegrationTest.groovy b/src/test/groovy/org/gradle/profiler/AbstractProfilerIntegrationTest.groovy index 93d9b4d2..c0a74e17 100644 --- a/src/test/groovy/org/gradle/profiler/AbstractProfilerIntegrationTest.groovy +++ b/src/test/groovy/org/gradle/profiler/AbstractProfilerIntegrationTest.groovy @@ -258,7 +258,7 @@ genrule( assert find("").size() == 17 assert find("").size() == 1 + assert find("").size() == 1 assert find("").size() == 16 assert containsOne("") } @@ -274,7 +274,7 @@ genrule( assert find("").size() == 12 assert find("").size() == 1 + assert find("").size() == 1 assert find("").size() == 11 assert find("").size() == 12 } @@ -290,7 +290,7 @@ genrule( assert find("").size() == 12 assert find("").size() == 1 + assert find("").size() == 1 assert find("").size() == 11 assert find("").size() == 12 } diff --git a/src/test/groovy/org/gradle/profiler/BenchmarkIntegrationTest.groovy b/src/test/groovy/org/gradle/profiler/BenchmarkIntegrationTest.groovy index 0b74b807..6b707a9f 100644 --- a/src/test/groovy/org/gradle/profiler/BenchmarkIntegrationTest.groovy +++ b/src/test/groovy/org/gradle/profiler/BenchmarkIntegrationTest.groovy @@ -20,7 +20,7 @@ class BenchmarkIntegrationTest extends AbstractProfilerIntegrationTest { // Probe version, 6 warm up, 10 builds logFile.find("").size() == 10 logFile.find("").size() == 17 - logFile.find("").size() == 2 + logFile.find("").size() == 2 logFile.find("").size() == 9 + 16 def lines = resultFile.lines @@ -54,7 +54,7 @@ class BenchmarkIntegrationTest extends AbstractProfilerIntegrationTest { // Probe version, 6 warm up, 10 builds logFile.find("").size() == 5 logFile.find("").size() == 17 - logFile.find("").size() == 2 + logFile.find("").size() == 2 logFile.find("").size() == 4 + 16 def lines = resultFile.lines @@ -91,7 +91,7 @@ class BenchmarkIntegrationTest extends AbstractProfilerIntegrationTest { // Probe version, 6 warm up, 10 builds logFile.find("").size() == 2 logFile.find("").size() == 17 - logFile.find("").size() == 2 + logFile.find("").size() == 2 logFile.find("").size() == 1 + 16 def lines = resultFile.lines diff --git a/src/test/groovy/org/gradle/profiler/ProfilerIntegrationTest.groovy b/src/test/groovy/org/gradle/profiler/ProfilerIntegrationTest.groovy index b3306e88..b3bb11ae 100644 --- a/src/test/groovy/org/gradle/profiler/ProfilerIntegrationTest.groovy +++ b/src/test/groovy/org/gradle/profiler/ProfilerIntegrationTest.groovy @@ -396,7 +396,7 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { } help { versions = "$minimalSupportedGradleVersion" - tasks = [help] + tasks = [":help"] daemon = none } """ @@ -418,7 +418,7 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { logFile.find("").size() == 2 + 11 + logFile.find("").size() == 2 + 11 logFile.find("").size() == 16 * 2 logFile.containsOne("* Running scenario assemble using Gradle $latestSupportedGradleVersion (scenario 1/3)") @@ -461,7 +461,7 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { // Probe version, 6 warm up, 10 builds logFile.find("").size() == 17 logFile.find("").size() == 1 + logFile.find("").size() == 1 logFile.find("").size() == 16 logFile.containsOne("* Running scenario xyz using Gradle $minimalSupportedGradleVersion (scenario 1/1)") @@ -482,7 +482,7 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { tasks = assemble } help { - tasks = help + tasks = ":help" } """ @@ -498,7 +498,7 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { then: logFile.find("").size() == 7 - logFile.find("").size() == 4 + logFile.find("").size() == 4 logFile.find("").size() == 3 logFile.containsOne("* Running scenario assemble using Gradle $minimalSupportedGradleVersion (scenario 1/2)") @@ -516,7 +516,7 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { tasks = assemble } help { - tasks = help + tasks = ":help" } """ @@ -533,7 +533,7 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { then: logFile.find("").size() == 7 logFile.find("").size() == 7 - logFile.find("").size() == 8 + logFile.find("").size() == 8 logFile.find("").size() == 6 logFile.containsOne("* Running scenario assemble using Gradle $minimalSupportedGradleVersion (scenario 1/4)") @@ -564,7 +564,7 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { tasks = assemble } help = \${defaults} { - tasks = help + tasks = ":help" } """ @@ -582,7 +582,7 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { logFile.find("").size() == 7 logFile.find("").size() == 7 logFile.find("").size() == 6 - logFile.find("").size() == 8 + logFile.find("").size() == 8 logFile.containsOne("* Running scenario assemble using Gradle $minimalSupportedGradleVersion (scenario 1/4)") logFile.containsOne("* Running scenario assemble using Gradle $latestSupportedGradleVersion (scenario 2/4)") @@ -600,7 +600,7 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { help { versions = "$minimalSupportedGradleVersion" cleanup-tasks = clean - tasks = help + tasks = ":help" } """ @@ -618,13 +618,13 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { then: // Probe version, 6 warm up, 10 builds logFile.find("").size() == 33 - logFile.find("").size() == 17 + logFile.find("").size() == 17 def lines = resultFile.lines lines.size() == totalLinesForExecutions(16) lines.get(0) == "scenario,help" lines.get(1) == "version,Gradle ${minimalSupportedGradleVersion}" - lines.get(2) == "tasks,help" + lines.get(2) == "tasks,:help" lines.get(3) == "value,total execution time" lines.get(4).matches("warm-up build #1,$SAMPLE") lines.get(9).matches("warm-up build #6,$SAMPLE") @@ -693,7 +693,7 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { logFile.find("").size() == 2 logFile.find("").size() == 6 - logFile.find("").size() == 2 + logFile.find("").size() == 2 logFile.find("").size() == 4 logFile.find("").size() == 2 From 27af2ace7523f8b39cd9c15ca716d7d73d050188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?An=C5=BEe=20Sodja?= Date: Wed, 10 Jan 2024 09:40:43 +0100 Subject: [PATCH 2/2] Adjust ProfilerIntegrationTest and fix some tests --- .../profiler/ProfilerIntegrationTest.groovy | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/test/groovy/org/gradle/profiler/ProfilerIntegrationTest.groovy b/src/test/groovy/org/gradle/profiler/ProfilerIntegrationTest.groovy index b3bb11ae..fc9bc9ae 100644 --- a/src/test/groovy/org/gradle/profiler/ProfilerIntegrationTest.groovy +++ b/src/test/groovy/org/gradle/profiler/ProfilerIntegrationTest.groovy @@ -396,7 +396,7 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { } help { versions = "$minimalSupportedGradleVersion" - tasks = [":help"] + tasks = ["help"] daemon = none } """ @@ -416,9 +416,10 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { // Probe version, 2 scenarios have 6 warm up, 10 builds, 1 scenario has 1 warm up, 10 builds logFile.find("").size() == 1 + 16 + 11 logFile.find("").size() == 2 // Probe version logFile.find("").size() == 2 + 11 + logFile.find("").size() == 11 logFile.find("").size() == 16 * 2 logFile.containsOne("* Running scenario assemble using Gradle $latestSupportedGradleVersion (scenario 1/3)") @@ -460,8 +461,8 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { then: // Probe version, 6 warm up, 10 builds logFile.find("").size() == 17 + logFile.find("").size() == 1 // Probe version logFile.find("").size() == 1 logFile.find("").size() == 16 logFile.containsOne("* Running scenario xyz using Gradle $minimalSupportedGradleVersion (scenario 1/1)") @@ -482,7 +483,7 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { tasks = assemble } help { - tasks = ":help" + tasks = help } """ @@ -498,7 +499,8 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { then: logFile.find("").size() == 7 - logFile.find("").size() == 4 + logFile.find("").size() == 1 // Probe version + logFile.find("").size() == 3 logFile.find("").size() == 3 logFile.containsOne("* Running scenario assemble using Gradle $minimalSupportedGradleVersion (scenario 1/2)") @@ -516,7 +518,7 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { tasks = assemble } help { - tasks = ":help" + tasks = help } """ @@ -533,7 +535,8 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { then: logFile.find("").size() == 7 logFile.find("").size() == 7 - logFile.find("").size() == 8 + logFile.find("").size() == 2 // Probe version + logFile.find("").size() == 6 logFile.find("").size() == 6 logFile.containsOne("* Running scenario assemble using Gradle $minimalSupportedGradleVersion (scenario 1/4)") @@ -564,7 +567,7 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { tasks = assemble } help = \${defaults} { - tasks = ":help" + tasks = help } """ @@ -581,8 +584,9 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { then: logFile.find("").size() == 7 logFile.find("").size() == 7 + logFile.find("").size() == 2 // Probe version logFile.find("").size() == 6 - logFile.find("").size() == 8 + logFile.find("").size() == 6 logFile.containsOne("* Running scenario assemble using Gradle $minimalSupportedGradleVersion (scenario 1/4)") logFile.containsOne("* Running scenario assemble using Gradle $latestSupportedGradleVersion (scenario 2/4)") @@ -600,7 +604,7 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { help { versions = "$minimalSupportedGradleVersion" cleanup-tasks = clean - tasks = ":help" + tasks = help } """ @@ -618,13 +622,14 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { then: // Probe version, 6 warm up, 10 builds logFile.find("").size() == 33 - logFile.find("").size() == 17 + logFile.find("").size() == 1 + logFile.find("").size() == 16 def lines = resultFile.lines lines.size() == totalLinesForExecutions(16) lines.get(0) == "scenario,help" lines.get(1) == "version,Gradle ${minimalSupportedGradleVersion}" - lines.get(2) == "tasks,:help" + lines.get(2) == "tasks,help" lines.get(3) == "value,total execution time" lines.get(4).matches("warm-up build #1,$SAMPLE") lines.get(9).matches("warm-up build #6,$SAMPLE") @@ -691,9 +696,9 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest { // Probe version, 1 warm up, 1 build logFile.find("").size() == 5 logFile.find("").size() == 2 logFile.find("").size() == 2 logFile.find("").size() == 6 - logFile.find("").size() == 2 logFile.find("").size() == 4 logFile.find("").size() == 2