Github user jihoonson commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/441#discussion_r26892972
  
    --- Diff: tajo-core/src/test/java/org/apache/tajo/QueryTestCaseBase.java ---
    @@ -317,6 +333,60 @@ public ResultSet executeQuery() throws Exception {
         return executeFile(getMethodName() + ".sql");
       }
     
    +  private volatile Description current;
    +
    +  @Rule
    +  public TestRule watcher = new TestWatcher() {
    +    @Override
    +    protected void starting(Description description) {
    +      QueryTestCaseBase.this.current = description;
    +    }
    +  };
    +
    +  @Target({ElementType.METHOD})
    +  @Retention(RetentionPolicy.RUNTIME)
    +  protected static @interface SimpleTest {
    +    String[] queries();
    +    String[] cleanupTables() default {};
    +  }
    +
    +  protected void runSimpleTests() throws Exception {
    +    String methodName = getMethodName();
    +    Method method = current.getTestClass().getMethod(methodName);
    +    SimpleTest annotation = method.getAnnotation(SimpleTest.class);
    +    if (annotation == null) {
    +      throw new IllegalStateException("Cannot find test annotation");
    +    }
    +    String[] queries = annotation.queries();
    +    try {
    +      for (int i = 0; i < queries.length; i++) {
    +        ResultSet result = client.executeQueryAndGetResult(queries[i]);
    +        Path resultPath = StorageUtil.concatPath(
    +            currentResultPath, methodName + "." + String.valueOf(i + 1) + 
".result");
    +        if (currentResultFS.exists(resultPath)) {
    +          assertEquals("Result Verification",
    +              
FileUtil.readTextFromStream(currentResultFS.open(resultPath)), 
resultSetToString(result).trim());
    +        } else if (!isNull(result)) {
    +          FileUtil.writeTextToStream(resultSetToString(result).trim(), 
currentResultFS.create(resultPath));
    --- End diff --
    
    Would you explain the purpose of the else if clause?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to