|
3 | 3 |
|
4 | 4 | #include <doctest/doctest.h>
|
5 | 5 | #include <loguru.hpp>
|
6 |
| -#include <process-lib/process.hpp> |
| 6 | +#include <reproc/reproc.hpp> |
7 | 7 |
|
8 | 8 | #include <iterator>
|
9 | 9 | #include <sstream>
|
@@ -90,59 +90,57 @@ void MakeDirectoryRecursive(const AbsolutePath& path) {
|
90 | 90 |
|
91 | 91 | optional<std::string> RunExecutable(const std::vector<std::string>& command,
|
92 | 92 | std::string_view input) {
|
93 |
| - using process_lib::Process; |
94 |
| - |
95 | 93 | std::string command_string = "\"" + StringJoin(command, " ") + "\"";
|
96 |
| - auto command_with_error = [command_string](Process::Error error) { |
97 |
| - return command_string + ": " + Process::error_to_string(error); |
| 94 | + auto command_with_error = [command_string](Reproc::Error error) { |
| 95 | + return command_string + ": " + Reproc::error_to_string(error); |
98 | 96 | };
|
99 | 97 |
|
100 |
| - Process process; |
101 |
| - Process::Error error = Process::SUCCESS; |
| 98 | + Reproc reproc; |
| 99 | + Reproc::Error error = Reproc::SUCCESS; |
102 | 100 |
|
103 |
| - error = process.start(command, nullptr); |
| 101 | + error = reproc.start(command, nullptr); |
104 | 102 | if (error) {
|
105 |
| - LOG_S(ERROR) << "Error starting process " << command_with_error(error); |
| 103 | + LOG_S(ERROR) << "Error starting reproc " << command_with_error(error); |
106 | 104 | return nullopt;
|
107 | 105 | }
|
108 | 106 |
|
109 | 107 | unsigned int bytes_written = 0;
|
110 |
| - error = process.write(input.data(), input.length(), &bytes_written); |
| 108 | + error = reproc.write(input.data(), input.length(), &bytes_written); |
111 | 109 | if (error) {
|
112 | 110 | LOG_S(ERROR) << "Error writing to stdin of " << command_with_error(error)
|
113 | 111 | << ". " << bytes_written << " out of " << input.length()
|
114 | 112 | << " bytes were written";
|
115 | 113 | return nullopt;
|
116 | 114 | }
|
117 | 115 |
|
118 |
| - error = process.close_stdin(); |
| 116 | + error = reproc.close_stdin(); |
119 | 117 | if (error) {
|
120 | 118 | LOG_S(ERROR) << "Error closing stdin of " << command_with_error(error);
|
121 | 119 | return nullopt;
|
122 | 120 | }
|
123 | 121 |
|
124 | 122 | std::string output{};
|
125 |
| - error = process.read_all(output); |
| 123 | + error = reproc.read_all(output); |
126 | 124 | if (error) {
|
127 | 125 | LOG_S(ERROR) << "Error reading output of " << command_with_error(error);
|
128 | 126 | return nullopt;
|
129 | 127 | }
|
130 | 128 |
|
131 |
| - error = process.read_all_stderr(output); |
| 129 | + error = reproc.read_all_stderr(output); |
132 | 130 | if (error) {
|
133 | 131 | LOG_S(ERROR) << "Error reading stderr output of "
|
134 | 132 | << command_with_error(error);
|
135 | 133 | return nullopt;
|
136 | 134 | }
|
137 | 135 |
|
138 |
| - error = process.wait(Process::INFINITE); |
| 136 | + error = reproc.wait(Reproc::INFINITE); |
139 | 137 | if (error) {
|
140 | 138 | LOG_S(ERROR) << "Error waiting for exit of " << command_with_error(error);
|
141 | 139 | return nullopt;
|
142 | 140 | }
|
143 | 141 |
|
144 | 142 | int exit_status = 0;
|
145 |
| - error = process.exit_status(&exit_status); |
| 143 | + error = reproc.exit_status(&exit_status); |
146 | 144 | if (error) {
|
147 | 145 | LOG_S(ERROR) << "Error retrieving exit status of "
|
148 | 146 | << command_with_error(error);
|
|
0 commit comments