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

Allow specifying alternate JRS test directory for JTR report #9940

Merged
merged 1 commit into from
Nov 16, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,23 @@ private JrsTestReaderReportCommand() {}
* <p>
* If the input string is a number, then it is interpreted as a release number. Otherwise, it is interpreted as a
* branch name.
* <p>
* If the input string contains a slash, then it is interpreted as a path to a non-standard test directory.
* Otherwise, it is assumed that the desired tests are in the `swirlds-automation` directory.
*
* @param inputString the input string
* @return the interpreted target directory
*/
@NonNull
private static String interpretTargetDirectory(@NonNull final String inputString) {
final StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("swirlds-automation/");

// allow the user to specify a path to a non-standard test directory
if (!inputString.contains("/")) {
stringBuilder.append("swirlds-automation/");
}

// if the input string is a number, then it is interpreted as a release number
if (inputString.matches("\\d+")) {
stringBuilder.append("release/0.");
}
Expand Down Expand Up @@ -163,13 +171,16 @@ private void generateIndividualReport(
* @return the auto generated output directory name
*/
@NonNull
private Path autoGenerateOutputDirectoryName(@NonNull final String target) {
private static Path autoGenerateOutputDirectoryName(@NonNull final String target) {
// remove everything before a slash, if one exists
final String targetWithoutPath = target.substring(target.lastIndexOf("/") + 1);

// format example 'ThursdaySeptember21'
final DateTimeFormatter formatter =
DateTimeFormatter.ofPattern("EEEELLLLd").withZone(ZoneId.systemDefault());
final String todayString = formatter.format(Instant.now());

return getAbsolutePath(Path.of("jtr-" + target + "-" + todayString + ".html"));
return getAbsolutePath(Path.of("jtr-" + targetWithoutPath + "-" + todayString + ".html"));
}

@Override
Expand Down