| 70 | } |
| 71 | |
| 72 | bool cmCTestHandlerCommand::InvokeImpl( |
| 73 | BasicArguments& args, std::vector<std::string> const& unparsed, |
| 74 | cmExecutionStatus& status, std::function<bool()> handler) const |
| 75 | { |
| 76 | // save error state and restore it if needed |
| 77 | SaveRestoreErrorState errorState; |
| 78 | if (!args.CaptureCMakeError.empty()) { |
| 79 | errorState.CaptureCMakeError(); |
| 80 | } |
| 81 | |
| 82 | bool success = [&]() -> bool { |
| 83 | if (args.MaybeReportError(status.GetMakefile())) { |
| 84 | return true; |
| 85 | } |
| 86 | |
| 87 | std::sort(args.ParsedKeywords.begin(), args.ParsedKeywords.end()); |
| 88 | auto const it = std::adjacent_find(args.ParsedKeywords.begin(), |
| 89 | args.ParsedKeywords.end()); |
| 90 | if (it != args.ParsedKeywords.end()) { |
| 91 | status.SetError(cmStrCat("called with more than one value for ", *it)); |
| 92 | return false; |
| 93 | } |
| 94 | |
| 95 | if (!unparsed.empty()) { |
| 96 | status.SetError( |
| 97 | cmStrCat("called with unknown argument \"", unparsed.front(), "\".")); |
| 98 | return false; |
| 99 | } |
| 100 | |
| 101 | return handler(); |
| 102 | }(); |
| 103 | |
| 104 | if (args.CaptureCMakeError.empty()) { |
| 105 | return success; |
| 106 | } |
| 107 | |
| 108 | if (!success) { |
| 109 | cmCTestLog(this->CTest, ERROR_MESSAGE, |
| 110 | this->GetName() << ' ' << status.GetError() << '\n'); |
| 111 | } |
| 112 | |
| 113 | cmMakefile& mf = status.GetMakefile(); |
| 114 | success = success && !cmSystemTools::GetErrorOccurredFlag(); |
| 115 | mf.AddDefinition(args.CaptureCMakeError, success ? "0" : "-1"); |
| 116 | return true; |
| 117 | } |
| 118 | |
| 119 | bool cmCTestHandlerCommand::ExecuteHandlerCommand( |
| 120 | HandlerArguments& args, cmExecutionStatus& status) const |
no test coverage detected