Skip to content

Commit

Permalink
poll test passes
Browse files Browse the repository at this point in the history
  • Loading branch information
graph committed Apr 3, 2020
1 parent da4dd24 commit 4df272b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ Have both is too confusing.
# current progress
Hello world tests are passing on macos, linux, and cross compiling on linux for
windows using mingw. The library is almost feature complete.
All tests are passing on macos, linux. Most tests pass on cross compiling on
linux for windows using mingw. The library is almost feature complete.
must to be implemented
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/subprocess/ProcessBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ namespace subprocess {
DWORD exit_code;
GetExitCodeProcess(process_info.hProcess, &exit_code);
returncode = exit_code;
return returncode;
return true;
}

int Popen::wait(double timeout) {
Expand Down
18 changes: 18 additions & 0 deletions test/basic_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,24 @@ class BasicSuite : public CxxTest::TestSuite {
}

void testPoll() {
subprocess::EnvGuard guard;
std::string path = subprocess::cenv["PATH"];
path = TEST_BINARY_DIR + subprocess::kPathDelimiter + path;
subprocess::cenv["PATH"] = path;

auto popen = RunBuilder({"sleep", "3"}).popen();
subprocess::StopWatch timer;

int count = 0;
while(!popen.poll())
++count;
TS_TRACE("poll did " + std::to_string(count) + " iterations");
TS_ASSERT(count > 100);

popen.close();

double timeout = timer.seconds();
TS_ASSERT_DELTA(timeout, 3, 0.1);

}

Expand Down

0 comments on commit 4df272b

Please sign in to comment.