mirror of
https://github.com/arun11299/cpp-subprocess.git
synced 2025-08-04 12:26:19 -04:00
test: Adjust test_ret_code
for Windows and re-enable it (#97)
This commit is contained in:
parent
d19cce111c
commit
06858e5fd7
@ -790,7 +790,7 @@ struct input
|
|||||||
}
|
}
|
||||||
explicit input(IOTYPE typ) {
|
explicit input(IOTYPE typ) {
|
||||||
assert (typ == PIPE && "STDOUT/STDERR not allowed");
|
assert (typ == PIPE && "STDOUT/STDERR not allowed");
|
||||||
#ifndef __USING_WINDOWS__
|
#ifndef __USING_WINDOWS__
|
||||||
std::tie(rd_ch_, wr_ch_) = util::pipe_cloexec();
|
std::tie(rd_ch_, wr_ch_) = util::pipe_cloexec();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -1427,10 +1427,6 @@ inline int Popen::wait() noexcept(false)
|
|||||||
|
|
||||||
inline int Popen::poll() noexcept(false)
|
inline int Popen::poll() noexcept(false)
|
||||||
{
|
{
|
||||||
#ifndef _MSC_VER
|
|
||||||
if (!child_created_) return -1; // TODO: ??
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __USING_WINDOWS__
|
#ifdef __USING_WINDOWS__
|
||||||
int ret = WaitForSingleObject(process_handle_, 0);
|
int ret = WaitForSingleObject(process_handle_, 0);
|
||||||
if (ret != WAIT_OBJECT_0) return -1;
|
if (ret != WAIT_OBJECT_0) return -1;
|
||||||
@ -1444,6 +1440,8 @@ inline int Popen::poll() noexcept(false)
|
|||||||
|
|
||||||
return retcode_;
|
return retcode_;
|
||||||
#else
|
#else
|
||||||
|
if (!child_created_) return -1; // TODO: ??
|
||||||
|
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
// Returns zero if child is still running
|
// Returns zero if child is still running
|
||||||
|
@ -6,9 +6,15 @@ namespace sp = subprocess;
|
|||||||
void test_ret_code()
|
void test_ret_code()
|
||||||
{
|
{
|
||||||
std::cout << "Test::test_poll_ret_code" << std::endl;
|
std::cout << "Test::test_poll_ret_code" << std::endl;
|
||||||
|
#ifdef __USING_WINDOWS__
|
||||||
|
auto p = sp::Popen({"cmd.exe", "/c", "exit", "1"});
|
||||||
|
#else
|
||||||
auto p = sp::Popen({"/usr/bin/false"});
|
auto p = sp::Popen({"/usr/bin/false"});
|
||||||
|
#endif
|
||||||
while (p.poll() == -1) {
|
while (p.poll() == -1) {
|
||||||
#ifndef _MSC_VER
|
#ifdef __USING_WINDOWS__
|
||||||
|
Sleep(100);
|
||||||
|
#else
|
||||||
usleep(1000 * 100);
|
usleep(1000 * 100);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -43,7 +49,7 @@ void test_ret_code_check_output()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
// test_ret_code();
|
test_ret_code();
|
||||||
#ifndef __USING_WINDOWS__
|
#ifndef __USING_WINDOWS__
|
||||||
test_ret_code_comm();
|
test_ret_code_comm();
|
||||||
test_ret_code_check_output();
|
test_ret_code_check_output();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user