| 134 | } |
| 135 | |
| 136 | Valdi::Path resolveOpenSourceTestPath(const std::string& path) { |
| 137 | // Runfiles layouts differ between the standalone Valdi workspace and the |
| 138 | // mobile monorepo. Standalone runs put data at <runfiles>/valdi/<path>; |
| 139 | // the monorepo exposes Valdi as a canonical repo named +local_repos+valdi |
| 140 | // and puts data at <runfiles>/+local_repos+valdi/valdi/<path>. Probe each |
| 141 | // candidate and return the first one that exists. |
| 142 | std::vector<Valdi::Path> candidates; |
| 143 | auto pushCandidate = [&](const char* base, const char* prefix) { |
| 144 | Valdi::Path p(base); |
| 145 | if (prefix != nullptr && *prefix != '\0') { |
| 146 | p.append(prefix); |
| 147 | } |
| 148 | p.append(path); |
| 149 | p.normalize(); |
| 150 | candidates.push_back(std::move(p)); |
| 151 | }; |
| 152 | |
| 153 | for (const char* envName : {"TEST_SRCDIR", "RUNFILES_DIR"}) { |
| 154 | const char* base = std::getenv(envName); |
| 155 | if (base != nullptr && *base != '\0') { |
| 156 | pushCandidate(base, "valdi"); |
| 157 | pushCandidate(base, "+local_repos+valdi/valdi"); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | char cwdBuffer[PATH_MAX]; |
| 162 | if (::getcwd(cwdBuffer, PATH_MAX) != nullptr) { |
| 163 | pushCandidate(cwdBuffer, "external/+local_repos+valdi/valdi"); |
| 164 | pushCandidate(cwdBuffer, "valdi"); |
| 165 | pushCandidate(cwdBuffer, ""); |
no test coverage detected