| 120 | } |
| 121 | |
| 122 | void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, |
| 123 | std::string const& config, |
| 124 | Indent indent) |
| 125 | { |
| 126 | this->TestGenerated = true; |
| 127 | |
| 128 | // Set up generator expression evaluation context. |
| 129 | cmGeneratorExpression ge(*this->Test->GetMakefile()->GetCMakeInstance(), |
| 130 | this->Test->GetBacktrace()); |
| 131 | |
| 132 | // Determine if policy CMP0110 is set to NEW. |
| 133 | bool const quote_test_name = |
| 134 | needToQuoteTestName(*this->Test->GetMakefile(), this->Test->GetName()); |
| 135 | // Determine the number of equal-signs needed for quoting test name with |
| 136 | // [==[...]==] syntax. |
| 137 | std::string const equalSigns( |
| 138 | 1 + countMaxConsecutiveEqualSigns(this->Test->GetName()), '='); |
| 139 | |
| 140 | // Start the test command. |
| 141 | if (quote_test_name) { |
| 142 | os << indent << "add_test([" << equalSigns << "[" << this->Test->GetName() |
| 143 | << "]" << equalSigns << "] "; |
| 144 | } else { |
| 145 | os << indent << "add_test(" << this->Test->GetName() << " "; |
| 146 | } |
| 147 | |
| 148 | // Evaluate command line arguments |
| 149 | cmList argv{ |
| 150 | this->EvaluateCommandLineArguments(this->Test->GetCommand(), ge, config), |
| 151 | // Expand arguments if COMMAND_EXPAND_LISTS is set |
| 152 | this->Test->GetCommandExpandLists() ? cmList::ExpandElements::Yes |
| 153 | : cmList::ExpandElements::No, |
| 154 | cmList::EmptyElements::Yes |
| 155 | }; |
| 156 | // Expanding lists on an empty command may have left it empty |
| 157 | if (argv.empty()) { |
| 158 | argv.emplace_back(); |
| 159 | } |
| 160 | |
| 161 | // Check whether the command executable is a target whose name is to |
| 162 | // be translated. |
| 163 | std::string exe = argv[0]; |
| 164 | cmGeneratorTarget* target = this->LG->FindGeneratorTargetToUse(exe); |
| 165 | if (target && target->GetType() == cmStateEnums::EXECUTABLE) { |
| 166 | // Use the target file on disk. |
| 167 | exe = target->GetFullPath(config); |
| 168 | |
| 169 | auto addLauncher = [this, &config, &ge, &os, |
| 170 | target](std::string const& propertyName) { |
| 171 | cmValue launcher = target->GetProperty(propertyName); |
| 172 | if (!cmNonempty(launcher)) { |
| 173 | return; |
| 174 | } |
| 175 | auto const propVal = ge.Parse(*launcher)->Evaluate(this->LG, config); |
| 176 | cmList launcherWithArgs(propVal, cmList::ExpandElements::Yes, |
| 177 | this->Test->GetCMP0178() == cmPolicies::NEW |
| 178 | ? cmList::EmptyElements::Yes |
| 179 | : cmList::EmptyElements::No); |
nothing calls this directly
no test coverage detected