From 830a4b37aa3e301761dbf94407ce5896a2cf6c88 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Wed, 26 Jul 2023 13:08:27 -0400 Subject: cmUVProcessChain::Wait(): Treat timeout of 0 as no timeout --- Source/cmUVProcessChain.cxx | 4 ++-- Source/cmUVProcessChain.h | 2 +- Tests/CMakeLib/testUVProcessChain.cxx | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Source/cmUVProcessChain.cxx b/Source/cmUVProcessChain.cxx index 3de7ae5..119851c 100644 --- a/Source/cmUVProcessChain.cxx +++ b/Source/cmUVProcessChain.cxx @@ -393,12 +393,12 @@ bool cmUVProcessChain::Valid() const return this->Data->Valid; } -bool cmUVProcessChain::Wait(int64_t milliseconds) +bool cmUVProcessChain::Wait(uint64_t milliseconds) { bool timeout = false; cm::uv_timer_ptr timer; - if (milliseconds >= 0) { + if (milliseconds > 0) { timer.init(*this->Data->Loop, &timeout); timer.start( [](uv_timer_t* handle) { diff --git a/Source/cmUVProcessChain.h b/Source/cmUVProcessChain.h index d7a4a0e..5ba1bf9 100644 --- a/Source/cmUVProcessChain.h +++ b/Source/cmUVProcessChain.h @@ -102,7 +102,7 @@ public: int ErrorStream(); bool Valid() const; - bool Wait(int64_t milliseconds = -1); + bool Wait(uint64_t milliseconds = 0); std::vector GetStatus() const; const Status& GetStatus(std::size_t index) const; bool Finished() const; diff --git a/Tests/CMakeLib/testUVProcessChain.cxx b/Tests/CMakeLib/testUVProcessChain.cxx index 7630aa0..22373ef 100644 --- a/Tests/CMakeLib/testUVProcessChain.cxx +++ b/Tests/CMakeLib/testUVProcessChain.cxx @@ -652,6 +652,20 @@ bool testUVProcessChainInputFile(const char* helperCommand) return true; } +bool testUVProcessChainWait0(const char* helperCommand) +{ + cmUVProcessChainBuilder builder; + builder.AddCommand({ helperCommand, "echo" }); + + auto chain = builder.Start(); + if (!chain.Wait(0)) { + std::cout << "Wait(0) returned false, should be true" << std::endl; + return false; + } + + return true; +} + int testUVProcessChain(int argc, char** const argv) { if (argc < 2) { @@ -699,5 +713,10 @@ int testUVProcessChain(int argc, char** const argv) return -1; } + if (!testUVProcessChainWait0(argv[1])) { + std::cout << "While executing testUVProcessChainWait0().\n"; + return -1; + } + return 0; } -- cgit v0.12