Skip to content

Commit

Permalink
fix windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuzu CI committed Feb 29, 2024
1 parent 7036b66 commit 4633255
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions test/include/test_runner/test_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct TestStatement {
uint64_t numThreads = 4;
std::string encodedJoin;
bool expectedError = false;
bool expectedErrorRegex = false;
std::string errorMessage;
bool expectedOk = false;
uint64_t expectedNumTuples = 0;
Expand Down
2 changes: 1 addition & 1 deletion test/test_files/copy/export_import_db.test
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@ Binder exception: Directory ${KUZU_EXPORT_DB_DIRECTORY}_case3/demo-db5 does not
-REMOVE_FILE "${KUZU_EXPORT_DB_DIRECTORY}_case3/demo-db4/schema.cypher"
-IMPORT_DATABASE "${KUZU_EXPORT_DB_DIRECTORY}_case3/demo-db4"
-STATEMENT IMPORT DATABASE "${KUZU_EXPORT_DB_DIRECTORY}_case3/demo-db4"
---- error
---- error(regex)
Binder exception: File ${KUZU_EXPORT_DB_DIRECTORY}_case3/demo-db4/schema.cypher does not exist.
4 changes: 4 additions & 0 deletions test/test_runner/test_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ void TestParser::extractExpectedResult(TestStatement* statement) {
statement->expectedError = true;
statement->errorMessage = extractTextBeforeNextStatement();
replaceVariables(statement->errorMessage);
} else if (result == "error(regex)") {
statement->expectedErrorRegex = true;
statement->errorMessage = extractTextBeforeNextStatement();
replaceVariables(statement->errorMessage);
} else if (result.substr(0, 4) == "hash") {
statement->expectHash = true;
checkMinimumParams(1);
Expand Down
16 changes: 15 additions & 1 deletion test/test_runner/test_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ bool TestRunner::testStatement(
preparedStatement = conn.prepareNoLock(parsedStatement.get(), true, statement->encodedJoin);
}
// Check for wrong statements
if (!statement->expectedError && !preparedStatement->isSuccess()) {
if (!statement->expectedError && !statement->expectedErrorRegex &&
!preparedStatement->isSuccess()) {
spdlog::error(preparedStatement->getErrorMessage());
return false;
}
Expand Down Expand Up @@ -99,6 +100,19 @@ bool TestRunner::checkLogicalPlan(std::unique_ptr<PreparedStatement>& preparedSt
return true;
}
spdlog::info("EXPECTED ERROR: {}", expectedError);
} else if (statement->expectedErrorRegex) {
std::string expectedError = StringUtils::rtrim(result->getErrorMessage());
std::regex pattern("^.*[\\\\/]+([^\\\\/]+)$");
std::smatch match1;
bool is_match1 = std::regex_match(expectedError, match1, pattern);
std::smatch match2;
bool is_match2 = std::regex_match(statement->errorMessage, match2, pattern);
if (is_match1 && is_match2) {
if (match1[1] == match2[1]) {
return true;
}
}
spdlog::info("EXPECTED ERROR: {}", expectedError);
} else if (statement->expectedOk && result->isSuccess()) {
return true;
} else {
Expand Down

0 comments on commit 4633255

Please sign in to comment.