use of org.apache.asterix.test.common.ComparisonException in project asterixdb by apache.
the class ParserTestExecutor method executeTest.
@Override
public void executeTest(String actualPath, TestCaseContext testCaseCtx, ProcessBuilder pb, boolean isDmlRecoveryTest, TestGroup failedGroup) throws Exception {
int queryCount = 0;
List<CompilationUnit> cUnits = testCaseCtx.getTestCase().getCompilationUnit();
for (CompilationUnit cUnit : cUnits) {
LOGGER.info("Starting [TEST]: " + testCaseCtx.getTestCase().getFilePath() + "/" + cUnit.getName() + " ... ");
List<TestFileContext> testFileCtxs = testCaseCtx.getTestFiles(cUnit);
List<TestFileContext> expectedResultFileCtxs = testCaseCtx.getExpectedResultFiles(cUnit);
for (TestFileContext ctx : testFileCtxs) {
File testFile = ctx.getFile();
try {
if (queryCount >= expectedResultFileCtxs.size() && !cUnit.getOutputDir().getValue().equals("none")) {
throw new ComparisonException("no result file for " + testFile.toString() + "; queryCount: " + queryCount + ", filectxs.size: " + expectedResultFileCtxs.size());
}
// Runs the test query.
File expectedResultFile = expectedResultFileCtxs.get(queryCount).getFile();
File actualResultFile = testCaseCtx.getActualResultFile(cUnit, expectedResultFile, new File(actualPath));
testSQLPPParser(testFile, actualResultFile, expectedResultFile);
LOGGER.info("[TEST]: " + testCaseCtx.getTestCase().getFilePath() + "/" + cUnit.getName() + " PASSED ");
queryCount++;
} catch (Exception e) {
System.err.println("testFile " + testFile.toString() + " raised an exception: " + e);
if (cUnit.getExpectedError().isEmpty()) {
e.printStackTrace();
System.err.println("...Unexpected!");
if (failedGroup != null) {
failedGroup.getTestCase().add(testCaseCtx.getTestCase());
}
throw new Exception("Test \"" + testFile + "\" FAILED!", e);
} else {
// must compare with the expected failure message
if (e instanceof ComparisonException) {
throw e;
}
LOGGER.info("[TEST]: " + testCaseCtx.getTestCase().getFilePath() + "/" + cUnit.getName() + " failed as expected: " + e.getMessage());
System.err.println("...but that was expected.");
}
}
}
}
}
Aggregations