zabetak commented on code in PR #6225:
URL: https://github.com/apache/hive/pull/6225#discussion_r2597605532
##########
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:
nit: The `static` modifier is a redundant and a bit misleading on how the
field should be accessed. Since we have an accessor method it would be more
appropriate to declare this as:
```java
private final Pattern pattern = ...
```
--
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]