| 94 | } |
| 95 | |
| 96 | void parseTestExpectation(const std::string &filename, const std::vector<std::string> &lines_with_endings, |
| 97 | TextReplacer *replacer, std::vector<std::string> *flags, |
| 98 | std::unordered_map<std::string, std::string> *output_sections) { |
| 99 | // Scan for EXTRA_FLAGS: |
| 100 | { |
| 101 | bool in_output = false; |
| 102 | for (StringRef line : lines_with_endings) { |
| 103 | line = line.trim(); |
| 104 | |
| 105 | if (line.startswith("EXTRA_FLAGS:")) { |
| 106 | assert(!in_output && "multiple EXTRA_FLAGS sections"); |
| 107 | in_output = true; |
| 108 | continue; |
| 109 | } |
| 110 | |
| 111 | if (in_output && line.empty()) |
| 112 | break; |
| 113 | |
| 114 | if (in_output) |
| 115 | flags->push_back(line.str()); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | // Scan for OUTPUT: |
| 120 | { |
| 121 | std::string active_output_filename; |
| 122 | std::string active_output_contents; |
| 123 | |
| 124 | bool in_output = false; |
| 125 | for (StringRef line_with_ending : lines_with_endings) { |
| 126 | if (line_with_ending.startswith("*/")) |
| 127 | break; |
| 128 | |
| 129 | if (line_with_ending.startswith("OUTPUT:")) { |
| 130 | // Terminate the previous output section if we found a new one. |
| 131 | if (in_output) { |
| 132 | (*output_sections)[active_output_filename] = active_output_contents; |
| 133 | } |
| 134 | |
| 135 | // Try to tokenize OUTPUT: based one whitespace. If there is more than |
| 136 | // one token assume it is a filename. |
| 137 | SmallVector<StringRef, 2> tokens; |
| 138 | line_with_ending.split(tokens, ' '); |
| 139 | if (tokens.size() > 1) { |
| 140 | active_output_filename = tokens[1].str(); |
| 141 | } else { |
| 142 | active_output_filename = filename; |
| 143 | } |
| 144 | active_output_contents = ""; |
| 145 | |
| 146 | in_output = true; |
| 147 | } else if (in_output) { |
| 148 | active_output_contents += line_with_ending; |
| 149 | active_output_contents.push_back('\n'); |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | if (in_output) |