diff --git a/src/com/sun/javatest/batch/RunTestsCommand.java b/src/com/sun/javatest/batch/RunTestsCommand.java index d5646083..8ed124b9 100644 --- a/src/com/sun/javatest/batch/RunTestsCommand.java +++ b/src/com/sun/javatest/batch/RunTestsCommand.java @@ -135,16 +135,9 @@ public void run(CommandContext ctx) throws Fault { h.notifyOfTheFinalStats(stats != null ? Collections.unmodifiableMap(stats) : Collections.emptyMap(), boStats); if (!ctx.isVerboseQuiet()) { - long totalTimeSec = h.getElapsedTime() / 1000L; - long setupTimeSec = h.getTotalSetupTime() / 1000L; - long cleanupTimeSec = h.getTotalCleanupTime() / 1000L; - ctx.printMessage(i18n, "runTests.totalTime", formattedDuration(totalTimeSec), - totalTimeSec <= 60 ? "" : " (" + totalTimeSec + " seconds)"); - ctx.printMessage(i18n, "runTests.setupTime", formattedDuration(setupTimeSec), - setupTimeSec <= 60 ? "" : " (" + setupTimeSec + " seconds)"); - ctx.printMessage(i18n, "runTests.cleanupTime", formattedDuration(cleanupTimeSec), - cleanupTimeSec <= 60 ? "" : " (" + cleanupTimeSec + " seconds)"); - + printTime("runTests.totalTime", h.getElapsedTime() / 1000L); + printTime("runTests.setupTime", h.getTotalSetupTime() / 1000L); + printTime("runTests.cleanupTime", h.getTotalCleanupTime() / 1000L); showResultStats(skipped, boStats); } @@ -170,6 +163,25 @@ public void run(CommandContext ctx) throws Fault { } } + /** + * Writes a message to the log stream printing given time in seconds + * using message template with the given key, + * or printing additionally the absolute time as-is in seconds + * using a different template name + * constructed as the given message key plus ".withSecondsTotal" suffix + * + * @param messageKey the key for the required message template + * @param timeSeconds time value in seconds to be printed + */ + private void printTime(String messageKey, long timeSeconds) { + if (timeSeconds <= 60) { + ctx.printMessage(i18n, messageKey, formattedDuration(timeSeconds)); + } else { + ctx.printMessage(i18n, messageKey + ".withSecondsTotal", + formattedDuration(timeSeconds), timeSeconds); + } + } + private void showResultStats(int skipped, int... stats) { int passed = stats[Status.PASSED]; diff --git a/src/com/sun/javatest/batch/i18n.properties b/src/com/sun/javatest/batch/i18n.properties index 267a74f5..7de502d3 100644 --- a/src/com/sun/javatest/batch/i18n.properties +++ b/src/com/sun/javatest/batch/i18n.properties @@ -53,17 +53,20 @@ observer.noClassName=No class name given observer.badArg=Bad option: {0} observer.badClassPath=Bad class path ({0}): {1} -runTests.cleanupTime=Cleanup time: {0}{1} +runTests.cleanupTime=Cleanup time: {0} +runTests.cleanupTime.withSecondsTotal=Cleanup time: {0} ({1} seconds) runTests.error=Error: {0} runTests.harnessError=An error occurred while running the tests:\n{0} runTests.interrupted=The test run was interrupted. runTests.noTests=Test results: no tests selected runTests.resultsDone=Results written to {0} -runTests.setupTime=Setup time: {0}{1} +runTests.setupTime=Setup time: {0} +runTests.setupTime.withSecondsTotal=Setup time: {0} ({1} seconds) runTests.tests=Test results: {0,choice,0#|0