فهرست منبع

cmUVProcessChain::Wait(): Treat timeout of 0 as no timeout

Kyle Edwards 2 سال پیش
والد
کامیت
830a4b37aa
3فایلهای تغییر یافته به همراه22 افزوده شده و 3 حذف شده
  1. 2 2
      Source/cmUVProcessChain.cxx
  2. 1 1
      Source/cmUVProcessChain.h
  3. 19 0
      Tests/CMakeLib/testUVProcessChain.cxx

+ 2 - 2
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) {

+ 1 - 1
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<const Status*> GetStatus() const;
   const Status& GetStatus(std::size_t index) const;
   bool Finished() const;

+ 19 - 0
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;
 }