Skip to content
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

Apply default outputDir indexing logic to user-provided output dir #461

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/main/java/org/gradle/profiler/CommandLineParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public InvocationSettings parseSettings(String[] args) throws IOException, Setti
OptionSpecBuilder disableStudioSandbox = parser.accepts("no-studio-sandbox", "Marks that Android Studio should not use sandbox");
ArgumentAcceptingOptionSpec<File> scenarioFileOption = parser.accepts("scenario-file", "Scenario definition file to use").withRequiredArg().ofType(File.class);
ArgumentAcceptingOptionSpec<String> sysPropOption = parser.accepts("D", "Defines a system property").withRequiredArg();
ArgumentAcceptingOptionSpec<File> outputDirOption = parser.accepts("output-dir", "Directory to write results to").withRequiredArg()
.ofType(File.class).defaultsTo(findOutputDir());
ArgumentAcceptingOptionSpec<String> outputDirPathOption = parser.accepts("output-dir", "Directory to write results to").withRequiredArg().defaultsTo("profile-out");
ArgumentAcceptingOptionSpec<Integer> warmupsOption = parser.accepts("warmups", "Number of warm-up build to run for each scenario").withRequiredArg().ofType(Integer.class);
ArgumentAcceptingOptionSpec<Integer> iterationsOption = parser.accepts("iterations", "Number of builds to run for each scenario").withRequiredArg().ofType(Integer.class);
ArgumentAcceptingOptionSpec<String> profilerOption = parser.accepts("profile",
Expand Down Expand Up @@ -111,7 +110,8 @@ public InvocationSettings parseSettings(String[] args) throws IOException, Setti
return fail(parser, "Neither --profile or --benchmark specified.");
}

File outputDir = toAbsoluteFileOrNull(parsedOptions.valueOf(outputDirOption));
String outputDirPath = parsedOptions.valueOf(outputDirPathOption);
File outputDir = toAbsoluteFileOrNull(findOutputDir(outputDirPath));
File gradleUserHome = toAbsoluteFileOrNull(parsedOptions.valueOf(gradleUserHomeOption));
Integer warmups = parsedOptions.valueOf(warmupsOption);
Integer iterations = parsedOptions.valueOf(iterationsOption);
Expand Down Expand Up @@ -190,13 +190,13 @@ public InvocationSettings parseSettings(String[] args) throws IOException, Setti
.build();
}

private File findOutputDir() {
File outputDir = new File("profile-out");
private File findOutputDir(String path) {
File outputDir = new File(path);
if (!outputDir.exists()) {
return outputDir;
}
for (int i = 2; ; i++) {
outputDir = new File("profile-out-" + i);
outputDir = new File(path + "-" + i);
if (!outputDir.exists()) {
return outputDir;
}
Expand Down