thomasrebele commented on code in PR #6225:
URL: https://github.com/apache/hive/pull/6225#discussion_r2597699415
##########
itests/hive-unit/src/test/java/org/apache/hive/beeline/TestHplSqlViaBeeLine.java:
##########
@@ -1411,8 +1403,148 @@ private void testScriptFile(String scriptText,
List<String> argList, String expe
testScriptFile(scriptText, argList, expectedPattern, OutStream.OUT);
}
+ /**
+ * Checks that the pattern appears in the output.
+ * <p><b>Warning:</b> If the output depends on the time of the execution,
+ * use {@link #testScriptFile(String, List, TimeCheckHelper)}. This may be
the case if
+ * the script contains CURRENT_DATE, CURRENT_TIME_MILLIS, etc.</p>
+ */
private void testScriptFile(String scriptText, List<String> argList, String
expectedPattern,
TestBeeLineWithArgs.OutStream outStream) throws Throwable {
+ String output = runScriptFile(scriptText, argList, outStream);
+ if (!Pattern.compile(".*" + expectedPattern + ".*",
Pattern.DOTALL).matcher(output).matches()) {
+ fail("Output: '" + output + "' should match " + expectedPattern);
+ }
+ }
+
+ enum TimeCheckHelper {
+
+ /** Supports timestamps in second resolution such as 1764680360. */
+ TIMESTAMP_SECONDS {
+ // works for timestamps a few hours after the epoch (1970-01-01 00:00:00
GMT)
+ static final Pattern PATTERN = Pattern.compile("[0-9]{5,}");
Review Comment:
Thank you for the suggestion. It will also free the memory after the test
has been executed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]