MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / main

Function main

test/runner/e2e_test.cpp:394–444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

392}
393
394int main(int argc, char** argv) {
395 try {
396 // Main logic
397 std::string test_dir;
398 std::string import_data_dir;
399 bool rewrite_tests = false;
400 char* env_test_dir = std::getenv("E2E_TEST_FILES_DIRECTORY");
401 char* env_import_data_dir = std::getenv("E2E_IMPORT_DB_DIR");
402 char* env_rewrite_tests = std::getenv("E2E_REWRITE_TESTS");
403 if (env_test_dir != nullptr) {
404 test_dir = env_test_dir;
405 } else {
406 test_dir = "test/test_files";
407 }
408
409 if (env_import_data_dir != nullptr) {
410 auto path =
411 TestHelper::appendLbugRootPath(std::filesystem::path(env_import_data_dir).string());
412 if (!std::filesystem::exists(path)) {
413 throw TestException("IMPORT DATABASE path does not exist: " + path);
414 }
415 import_data_dir = env_import_data_dir;
416 }
417
418 TestHelper::setE2ETestFilesDirectory(test_dir);
419 TestHelper::setE2EImportDataDirectory(import_data_dir);
420
421 if (env_rewrite_tests != nullptr && std::string(env_rewrite_tests) != "FALSE" &&
422 std::string(env_rewrite_tests) != "OFF") {
423 rewrite_tests = true;
424 spdlog::info("Starting runner in Rewrite Mode");
425 }
426 TestHelper::setRewriteTests(rewrite_tests);
427
428 checkGtestParams(argc, argv);
429 testing::InitGoogleTest(&argc, argv);
430 if (argc > 1) {
431 auto path = TestHelper::appendLbugRootPath(
432 (std::filesystem::path(TestHelper::E2E_TEST_FILES_DIRECTORY) / argv[1]).string());
433 if (!std::filesystem::exists(path)) {
434 throw TestException("Test path does not exist [" + path + "].");
435 }
436 scanTestFiles(path);
437 }
438
439 return RUN_ALL_TESTS();
440 } catch (const std::exception& ex) {
441 std::cerr << "Error: " << ex.what() << std::endl;
442 return EXIT_FAILURE;
443 }
444}

Callers

nothing calls this directly

Calls 4

TestExceptionClass · 0.85
checkGtestParamsFunction · 0.85
scanTestFilesFunction · 0.85
whatMethod · 0.80

Tested by

no test coverage detected