-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multiple statements, statement blocks and exceptions. * Move the logic from TestCase to TestParser * Converted current test files to the new framework * Separate TestRunner from TestHelper * Removed CMakefiles and syntax adjustments * Cleanup functions not being used anymore * Cleanup unused variables * Changes after review * Remove using namespaces from headers * bfs_sssp test adjustment
- Loading branch information
Showing
105 changed files
with
976 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
add_kuzu_test(types_test | ||
date_test.cpp | ||
interval_test.cpp | ||
string_test.cpp | ||
time_test.cpp | ||
timestamp_test.cpp | ||
types_test.cpp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <string> | ||
|
||
#include "common/types/types_include.h" | ||
#include "gtest/gtest.h" | ||
|
||
using namespace kuzu::common; | ||
|
||
TEST(StringTest, splitBySpace) { | ||
std::string str = " a b c\td "; | ||
std::vector<std::string> result = StringUtils::splitBySpace(str); | ||
EXPECT_EQ(result.size(), 4); | ||
EXPECT_EQ(result[0], "a"); | ||
EXPECT_EQ(result[1], "b"); | ||
EXPECT_EQ(result[2], "c"); | ||
EXPECT_EQ(result[3], "d"); | ||
} | ||
|
||
TEST(StringTest, leftTrim) { | ||
std::string str = " command "; | ||
std::string result = StringUtils::ltrim(str); | ||
EXPECT_EQ(result, "command "); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#pragma once | ||
|
||
#include "main/kuzu.h" | ||
|
||
namespace kuzu { | ||
namespace testing { | ||
|
||
struct TestStatement { | ||
std::string name; | ||
std::string query; | ||
uint64_t numThreads = 4; | ||
std::string encodedJoin; | ||
uint64_t expectedNumTuples = 0; | ||
bool expectedError = false; | ||
bool expectedOk = false; | ||
std::vector<std::string> expectedTuples; | ||
std::string errorMessage; | ||
bool enumerate = false; | ||
bool checkOutputOrder = false; | ||
}; | ||
|
||
struct TestCase { | ||
std::string group; | ||
std::string name; | ||
std::string dataset; | ||
std::vector<std::unique_ptr<TestStatement>> statements; | ||
std::unordered_map<std::string, std::vector<std::unique_ptr<TestStatement>>> variableStatements; | ||
|
||
bool skipTest = false; | ||
|
||
bool isValid() const { return !group.empty() && !name.empty() && !dataset.empty(); } | ||
|
||
bool hasStatements() const { return !statements.empty(); } | ||
}; | ||
|
||
} // namespace testing | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#include <cstring> | ||
|
||
#include "common/file_utils.h" | ||
#include "test_runner/test_case.h" | ||
|
||
namespace kuzu { | ||
namespace testing { | ||
|
||
enum class TokenType { | ||
GROUP, | ||
DATASET, | ||
TEST, | ||
CASE, | ||
CHECK_ORDER, | ||
DEFINE_STATEMENT_BLOCK, | ||
EMPTY, | ||
ENCODED_JOIN, | ||
END_OF_STATEMENT_BLOCK, | ||
ENUMERATE, | ||
NAME, | ||
PARALLELISM, | ||
QUERY, | ||
READ_ONLY, | ||
RESULT, | ||
SEPARATOR, | ||
SKIP, | ||
STATEMENT, | ||
STATEMENT_BLOCK | ||
}; | ||
|
||
const std::unordered_map<std::string, TokenType> tokenMap = {{"-GROUP", TokenType::GROUP}, | ||
{"-TEST", TokenType::TEST}, {"-DATASET", TokenType::DATASET}, {"-CASE", TokenType::CASE}, | ||
{"-CHECK_ORDER", TokenType::CHECK_ORDER}, {"-ENCODED_JOIN", TokenType::ENCODED_JOIN}, | ||
{"-DEFINE_STATEMENT_BLOCK", TokenType::DEFINE_STATEMENT_BLOCK}, | ||
{"-ENUMERATE", TokenType::ENUMERATE}, {"-NAME", TokenType::NAME}, | ||
{"-PARALLELISM", TokenType::PARALLELISM}, {"-QUERY", TokenType::QUERY}, | ||
{"-READ_ONLY", TokenType::READ_ONLY}, {"-SKIP", TokenType::SKIP}, | ||
{"-STATEMENT", TokenType::STATEMENT}, {"-STATEMENT_BLOCK", TokenType::STATEMENT_BLOCK}, | ||
{"]", TokenType::END_OF_STATEMENT_BLOCK}, {"----", TokenType::RESULT}, | ||
{"--", TokenType::SEPARATOR}, {"#", TokenType::EMPTY}}; | ||
|
||
class LogicToken { | ||
public: | ||
TokenType type; | ||
std::vector<std::string> params; | ||
}; | ||
|
||
class TestParser { | ||
public: | ||
TestParser() : testCase(std::make_unique<TestCase>()) {} | ||
|
||
std::unique_ptr<TestCase> parseTestFile(const std::string& path); | ||
|
||
private: | ||
std::ifstream fileStream; | ||
std::string line; | ||
std::string name; | ||
LogicToken currentToken; | ||
std::unique_ptr<TestCase> testCase; | ||
|
||
std::string paramsToString(); | ||
|
||
void openFile(const std::string& path); | ||
|
||
void tokenize(); | ||
|
||
void parseHeader(); | ||
|
||
void parseBody(); | ||
|
||
void extractExpectedResult(TestStatement* currentStatement); | ||
|
||
void extractStatementBlock(); | ||
|
||
void addStatementBlock(const std::string& blockName); | ||
|
||
inline bool endOfFile() { return fileStream.eof(); } | ||
|
||
inline bool nextLine() { return static_cast<bool>(getline(fileStream, line)); } | ||
|
||
inline void checkMinimumParams(int minimumParams) { | ||
if (currentToken.params.size() < minimumParams) { | ||
throw common::Exception("Invalid number of parameters for statement [" + line + "]"); | ||
} | ||
} | ||
|
||
TestStatement* extractStatement(TestStatement* currentStatement); | ||
|
||
TestStatement* addNewStatement(); | ||
}; | ||
|
||
} // namespace testing | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "common/file_utils.h" | ||
#include "gtest/gtest.h" | ||
#include "parser/parser.h" | ||
#include "planner/logical_plan/logical_plan_util.h" | ||
#include "planner/planner.h" | ||
#include "test_runner/test_case.h" | ||
|
||
namespace kuzu { | ||
namespace testing { | ||
|
||
class TestRunner { | ||
public: | ||
static void runTest( | ||
const std::vector<std::unique_ptr<TestStatement>>& statements, main::Connection& conn); | ||
|
||
static std::unique_ptr<planner::LogicalPlan> getLogicalPlan( | ||
const std::string& query, main::Connection& conn); | ||
|
||
private: | ||
static void initializeConnection(TestStatement* statement, main::Connection& conn); | ||
static bool testStatement(TestStatement* statement, main::Connection& conn); | ||
static bool checkLogicalPlans(std::unique_ptr<main::PreparedStatement>& preparedStatement, | ||
TestStatement* statement, main::Connection& conn); | ||
static std::vector<std::string> convertResultToString( | ||
main::QueryResult& queryResult, bool checkOutputOrder = false); | ||
}; | ||
|
||
} // namespace testing | ||
} // namespace kuzu |
Oops, something went wrong.