mirror of
https://github.com/arun11299/cpp-subprocess.git
synced 2025-08-05 04:46:21 -04:00

* Support CMake 4 CMake 4 has removed compatibility with CMake < 3.5 Bumping minimum required version to 3.5 enables CMake 4 to build this code. * Move header into subdir * Improve CMake setup This commit configures and installs CMake metadata files. This also provides the namespaced ALIAS target `cpp-subprocess::subprocess`. * Update README with CMake instructions * Update include paths in tests
24 lines
730 B
C++
24 lines
730 B
C++
#include <cpp-subprocess/subprocess.hpp>
|
|
|
|
#include <cstdlib>
|
|
#include <string>
|
|
#include <tuple>
|
|
|
|
using namespace subprocess;
|
|
|
|
int main() {
|
|
auto p = Popen("python3 @TEST_REDIRECTION_PYTHON_SCRIPT_PATH@", output{PIPE}, error{PIPE});
|
|
OutBuffer out_buf;
|
|
ErrBuffer err_buf;
|
|
std::tie(out_buf, err_buf) = p.communicate();
|
|
std::string out{out_buf.buf.data()};
|
|
std::string err{err_buf.buf.data()};
|
|
|
|
if (out.find("Hello message.") == std::string::npos) return EXIT_FAILURE;
|
|
if (err.find("Hello message.") != std::string::npos) return EXIT_FAILURE;
|
|
if (out.find("Error report.") != std::string::npos) return EXIT_FAILURE;
|
|
if (err.find("Error report.") == std::string::npos) return EXIT_FAILURE;
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|