Skip to content

Commit

Permalink
restore cmake logic
Browse files Browse the repository at this point in the history
  • Loading branch information
markdroth committed Nov 14, 2024
1 parent 3e2d1e8 commit 518be14
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/core/http/httpcli_test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
Expand All @@ -41,12 +42,19 @@ namespace testing {
HttpRequestTestServer StartHttpRequestTestServer(int argc, char** argv,
bool use_ssl) {
int server_port = grpc_pick_unused_port_or_die();
// Find root path.
// Find root path. The logic is different for bazel vs. cmake.
std::string root;
absl::string_view me(argv[0]);
size_t last_slash = me.rfind('/');
if (last_slash != me.npos) {
root = absl::StrCat(me.substr(0, last_slash), "/../../..");
absl::string_view dirname = me.substr(0, last_slash);
if (absl::EndsWith(dirname, "/http")) {
// Bazel paths will end in "test/core/http".
root = absl::StrCat(dirname, "/../../..");
} else {
// Cmake paths will be "cmake/build".
root = absl::StrCat(dirname, "/../..");
}
} else {
root = ".";
}
Expand Down

0 comments on commit 518be14

Please sign in to comment.