From 6f9efb4709538be239faa5df9f3b4cbd662066ab Mon Sep 17 00:00:00 2001 From: Austin Littley Date: Thu, 16 Nov 2023 11:04:41 -0500 Subject: [PATCH] Allow for specifying alternate directory containing JRS tests for JTR report Signed-off-by: Austin Littley --- .../cli/JrsTestReaderReportCommand.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/cli/JrsTestReaderReportCommand.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/cli/JrsTestReaderReportCommand.java index c8c24eb1ba9e..b2b33a19077c 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/cli/JrsTestReaderReportCommand.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/cli/JrsTestReaderReportCommand.java @@ -114,6 +114,9 @@ private JrsTestReaderReportCommand() {} *

* If the input string is a number, then it is interpreted as a release number. Otherwise, it is interpreted as a * branch name. + *

+ * 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 @@ -121,8 +124,13 @@ private JrsTestReaderReportCommand() {} @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."); } @@ -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