MCPcopy Create free account
hub / github.com/Kitware/CMake / main

Function main

Tests/RunCMake/GoogleTest/timeout_test.cpp:22–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22int main(int argc, char** argv)
23{
24 // Note: GoogleTest.cmake doesn't actually depend on Google Test as such;
25 // it only requires that we produce output in the expected format when
26 // invoked with --gtest_list_tests. Thus, we fake that here. This allows us
27 // to test the module without actually needing Google Test.
28 if (argc > 1 && std::string(argv[1]) == "--gtest_list_tests" &&
29 std::string(argv[2]).find("--gtest_output=json:") != std::string::npos) {
30 printf("timeout.\n case\n");
31 fflush(stdout);
32
33 std::string output_param(argv[2]);
34 std::string::size_type split = output_param.find(":");
35 std::string filepath = output_param.substr(split + 1);
36 // The full file path is passed
37 FILE* ofile = fopen(filepath.c_str(), "wb");
38
39 if (!ofile) {
40 fprintf(stderr, "Failed to create file: %s\n", filepath.c_str());
41 return 1;
42 }
43 std::string json_output = "{\n"
44 " \"tests\": 1,\n"
45 " \"name\": \"AllTests\",\n"
46 " \"testsuites\": [\n"
47 " {\n"
48 " \"name\": \"timeout\",\n"
49 " \"tests\": 1,\n"
50 " \"testsuite\": [\n"
51 " { \"name\": \"case\", "
52 "\"file\": \"file.cpp\", \"line\": 42 }\n"
53 " ]\n"
54 " }\n"
55 " ]\n"
56 " }";
57 fprintf(ofile, "%s", json_output.c_str());
58 fclose(ofile);
59
60#ifdef discoverySleepSec
61 sleepFor(discoverySleepSec);
62#endif
63 return 0;
64 }
65
66#ifdef sleepSec
67 sleepFor(sleepSec);
68#endif
69
70 return 0;
71}

Callers

nothing calls this directly

Calls 4

sleepForFunction · 0.85
c_strMethod · 0.80
findMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…