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
This commit is contained in:
parent
d19cce111c
commit
1bb027c04c
@ -790,7 +790,7 @@ struct input
|
||||
}
|
||||
explicit input(IOTYPE typ) {
|
||||
assert (typ == PIPE && "STDOUT/STDERR not allowed");
|
||||
#ifndef __USING_WINDOWS__
|
||||
#ifndef __USING_WINDOWS__
|
||||
std::tie(rd_ch_, wr_ch_) = util::pipe_cloexec();
|
||||
#endif
|
||||
}
|
||||
@ -1427,10 +1427,6 @@ inline int Popen::wait() noexcept(false)
|
||||
|
||||
inline int Popen::poll() noexcept(false)
|
||||
{
|
||||
#ifndef _MSC_VER
|
||||
if (!child_created_) return -1; // TODO: ??
|
||||
#endif
|
||||
|
||||
#ifdef __USING_WINDOWS__
|
||||
int ret = WaitForSingleObject(process_handle_, 0);
|
||||
if (ret != WAIT_OBJECT_0) return -1;
|
||||
@ -1444,6 +1440,8 @@ inline int Popen::poll() noexcept(false)
|
||||
|
||||
return retcode_;
|
||||
#else
|
||||
if (!child_created_) return -1; // TODO: ??
|
||||
|
||||
int status;
|
||||
|
||||
// Returns zero if child is still running
|
||||
|
@ -6,9 +6,15 @@ namespace sp = subprocess;
|
||||
void test_ret_code()
|
||||
{
|
||||
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"});
|
||||
#endif
|
||||
while (p.poll() == -1) {
|
||||
#ifndef _MSC_VER
|
||||
#ifdef __USING_WINDOWS__
|
||||
Sleep(100);
|
||||
#else
|
||||
usleep(1000 * 100);
|
||||
#endif
|
||||
}
|
||||
@ -43,7 +49,7 @@ void test_ret_code_check_output()
|
||||
}
|
||||
|
||||
int main() {
|
||||
// test_ret_code();
|
||||
test_ret_code();
|
||||
#ifndef __USING_WINDOWS__
|
||||
test_ret_code_comm();
|
||||
test_ret_code_check_output();
|
||||
|
Loading…
x
Reference in New Issue
Block a user