Revert "WIP: Add windows compatibility (#30)" (#31)

This reverts commit 5d92f4849276aa313dc1ba56c1556f4cca27fc7f.
This commit is contained in:
Arun Muralidharan 2019-05-02 12:24:40 +05:30 committed by GitHub
parent 5d92f48492
commit 871577770a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 217 additions and 641 deletions

View File

@ -1 +0,0 @@
BreakBeforeBraces: Stroustrup

2
.gitignore vendored
View File

@ -1,2 +0,0 @@
build*
.vscode

View File

@ -1,6 +0,0 @@
cmake_minimum_required(VERSION 3.9)
project(subprocess CXX)
enable_testing()
add_subdirectory(test)

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +0,0 @@
add_executable(test_subprocess test_subprocess.cc)
add_test(
NAME test_subprocess
COMMAND $<TARGET_FILE:test_subprocess>
)

View File

@ -1,27 +1,19 @@
#include "../subprocess.hpp"
#include <iostream>
#include "../subprocess.hpp"
using namespace subprocess;
void test_exename()
{
#ifdef _MSC_VER
auto ret = call({"--version"}, executable{"cmake"}, shell{false});
#else
auto ret = call({"-l"}, executable{"ls"}, shell{false});
#endif
std::cout << ret << std::endl;
}
void test_input()
{
#if 0
auto p = Popen({"cmake", "--version"}, output{PIPE}, input{PIPE});
#else
auto p = Popen({"grep", "f"}, output{PIPE}, input{PIPE});
const char *msg = "one\ntwo\nthree\nfour\nfive\n";
const char* msg = "one\ntwo\nthree\nfour\nfive\n";
p.send(msg, strlen(msg));
#endif
auto res = p.communicate(nullptr, 0);
std::cout << res.first.buf.data() << std::endl;
}
@ -30,8 +22,7 @@ void test_piping()
{
auto cat = Popen({"cat", "../subprocess.hpp"}, output{PIPE});
auto grep = Popen({"grep", "template"}, input{cat.output()}, output{PIPE});
auto cut =
Popen({"cut", "-d,", "-f", "1"}, input{grep.output()}, output{PIPE});
auto cut = Popen({"cut", "-d,", "-f", "1"}, input{grep.output()}, output{PIPE});
auto res = cut.communicate().first;
std::cout << res.buf.data() << std::endl;
}
@ -54,10 +45,7 @@ void test_sleep()
while (p.poll() == -1) {
std::cout << "Waiting..." << std::endl;
#ifdef _MSC_VER
#else
sleep(1);
#endif
}
std::cout << "Sleep ended: ret code = " << p.retcode() << std::endl;
@ -68,7 +56,7 @@ void test_read_all()
Popen p = Popen({"echo","12345678"}, output{PIPE});
std::vector<char> buf(6);
int rbytes = util::read_all(p.output(), buf);
int rbytes = util::read_all(fileno(p.output()), buf);
std::string out(buf.begin(), buf.end());