MCPcopy Create free account
hub / github.com/catchorg/Catch2 / exec_cmd

Function exec_cmd

tools/misc/coverage-helper.cpp:93–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93int exec_cmd(std::string const& cmd, int log_num, std::string const& path) {
94 std::array<char, 128> buffer;
95
96 // cmd has already been escaped outside this function.
97 auto real_cmd = "OpenCppCoverage --export_type binary:cov-report" + std::to_string(log_num)
98 + ".bin --quiet " + "--sources " + escape_arg(path) + "\\src" + " --cover_children -- " + cmd;
99 std::cout << "=== Marker ===: Cmd: " << real_cmd << '\n';
100 auto pipe = _popen(real_cmd.c_str(), "r");
101
102 if (!pipe) {
103 throw std::runtime_error("popen() failed!");
104 }
105 while (!feof(pipe)) {
106 if (fgets(buffer.data(), 128, pipe) != nullptr) {
107 std::cout << buffer.data();
108 }
109 }
110
111 auto ret = _pclose(pipe);
112 if (ret == -1) {
113 throw std::runtime_error("underlying error in pclose()");
114 }
115
116 return ret;
117}
118
119// argv should be:
120// [0]: our path

Callers 1

mainFunction · 0.85

Calls 2

escape_argFunction · 0.85
to_stringFunction · 0.50

Tested by

no test coverage detected