| 91 | } |
| 92 | |
| 93 | int 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 |
no test coverage detected