| 769 | } |
| 770 | |
| 771 | bool cmCTestRunTest::ForkProcess() |
| 772 | { |
| 773 | this->TestProcess->SetId(this->Index); |
| 774 | this->TestProcess->SetWorkingDirectory(this->TestProperties->Directory); |
| 775 | this->TestProcess->SetCommand(this->ActualCommand); |
| 776 | this->TestProcess->SetCommandArguments(this->Arguments); |
| 777 | |
| 778 | cm::optional<cmDuration> timeout; |
| 779 | |
| 780 | // Check TIMEOUT test property. |
| 781 | if (this->TestProperties->Timeout && |
| 782 | *this->TestProperties->Timeout >= cmDuration::zero()) { |
| 783 | timeout = this->TestProperties->Timeout; |
| 784 | } |
| 785 | |
| 786 | // An explicit TIMEOUT=0 test property means "no timeout". |
| 787 | if (timeout) { |
| 788 | if (*timeout == std::chrono::duration<double>::zero()) { |
| 789 | timeout = cm::nullopt; |
| 790 | } |
| 791 | } else { |
| 792 | // Check --timeout. |
| 793 | if (this->CTest->GetGlobalTimeout() > cmDuration::zero()) { |
| 794 | timeout = this->CTest->GetGlobalTimeout(); |
| 795 | } |
| 796 | |
| 797 | if (!timeout) { |
| 798 | // Check CTEST_TEST_TIMEOUT. |
| 799 | cmDuration ctestTestTimeout = this->CTest->GetTimeOut(); |
| 800 | if (ctestTestTimeout > cmDuration::zero()) { |
| 801 | timeout = ctestTestTimeout; |
| 802 | } |
| 803 | } |
| 804 | } |
| 805 | |
| 806 | // Check CTEST_TIME_LIMIT. |
| 807 | cmDuration timeRemaining = this->CTest->GetRemainingTimeAllowed(); |
| 808 | if (timeRemaining != cmCTest::MaxDuration()) { |
| 809 | // This two minute buffer is historical. |
| 810 | timeRemaining -= std::chrono::minutes(2); |
| 811 | } |
| 812 | |
| 813 | // Check --stop-time. |
| 814 | std::chrono::system_clock::time_point stop_time = this->CTest->GetStopTime(); |
| 815 | if (stop_time != std::chrono::system_clock::time_point()) { |
| 816 | cmDuration timeUntilStop = |
| 817 | (stop_time - std::chrono::system_clock::now()) % std::chrono::hours(24); |
| 818 | this->TestProcess->SetStopTimeout(timeUntilStop); |
| 819 | } |
| 820 | |
| 821 | // Enforce remaining time even over explicit TIMEOUT=0. |
| 822 | if (timeRemaining <= cmDuration::zero()) { |
| 823 | timeRemaining = cmDuration::zero(); |
| 824 | } |
| 825 | if (!timeout || timeRemaining < *timeout) { |
| 826 | timeout = timeRemaining; |
| 827 | } |
| 828 |
no test coverage detected