MCPcopy Create free account
hub / github.com/catboost/catboost / ListTests

Method ListTests

library/cpp/testing/gtest/main.cpp:389–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

387}
388
389void NGTest::ListTests(int listLevel, const std::string& listPath) {
390 // NOTE: do not use `std::endl`, use `\n`; `std::endl` produces `\r\n`s on windows,
391 // and ya make does not handle them well.
392
393 if (listLevel > 0) {
394 std::ostream* listOut = &std::cout;
395 std::ofstream listFile;
396
397 if (!listPath.empty()) {
398 listFile.open(listPath, std::ios::out | std::ios::binary);
399 if (!listFile.is_open()) {
400 std::cerr << "Failed to open file " << listPath << " for write" << std::endl;
401 exit(2);
402 }
403 listOut = &listFile;
404 }
405
406 for (int i = 0; i < testing::UnitTest::GetInstance()->total_test_suite_count(); ++i) {
407 auto suite = testing::UnitTest::GetInstance()->GetTestSuite(i);
408 if (listLevel > 1) {
409 for (int j = 0; j < suite->total_test_count(); ++j) {
410 auto test = suite->GetTestInfo(j);
411 if (false) {
412 // TODO: YA-3943 будет открыто в следующем PR, активироввать функционал нужно в два шага
413 NJson::TJsonValue testObj(NJson::JSON_MAP);
414
415 testObj["test_suite_name"] = test->test_suite_name();
416 testObj["name"] = test->name();
417 testObj["file"] = test->file() ? test->file() : "";
418 testObj["line"] = test->line();
419 testObj["nodeid"] = std::string(test->test_suite_name()) + "::" + test->name();
420 if (test->value_param()) {
421 testObj["params"] = test->value_param();
422 }
423
424 (*listOut) << NJson::WriteJson(&testObj) << "\n";
425 } else {
426 (*listOut) << suite->name() << "::" << test->name() << "\n";
427 }
428 }
429 } else {
430 (*listOut) << suite->name() << "\n";
431 }
432 }
433
434 (*listOut) << std::flush;
435
436 exit(0);
437 }
438}
439
440void NGTest::UnsetDefaultReporter() {
441 ::testing::TestEventListeners& listeners = ::testing::UnitTest::GetInstance()->listeners();

Callers

nothing calls this directly

Calls 12

exitFunction · 0.85
GetTestSuiteMethod · 0.80
total_test_countMethod · 0.80
GetTestInfoMethod · 0.80
stringClass · 0.50
WriteJsonFunction · 0.50
emptyMethod · 0.45
openMethod · 0.45
nameMethod · 0.45
fileMethod · 0.45
lineMethod · 0.45

Tested by

no test coverage detected