mirror of https://github.com/grpc/grpc.git
Revert "[Windows] Make resolver_component_tests_runner_invoker run wi… (#34129)
…th Bazel on Windows (#34107)"
This reverts commit d540b4c088
.
pull/34133/head
parent
cedef1b7f3
commit
cd873f355b
8 changed files with 41 additions and 221 deletions
@ -1,39 +0,0 @@ |
|||||||
# Copyright 2023 The gRPC Authors. |
|
||||||
# |
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||||
# you may not use this file except in compliance with the License. |
|
||||||
# You may obtain a copy of the License at |
|
||||||
# |
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0 |
|
||||||
# |
|
||||||
# Unless required by applicable law or agreed to in writing, software |
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
# See the License for the specific language governing permissions and |
|
||||||
# limitations under the License. |
|
||||||
|
|
||||||
load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_package") |
|
||||||
|
|
||||||
licenses(["notice"]) |
|
||||||
|
|
||||||
grpc_package( |
|
||||||
name = "test/cpp/util/windows", |
|
||||||
visibility = "tests", |
|
||||||
) |
|
||||||
|
|
||||||
grpc_cc_library( |
|
||||||
name = "manifest_file", |
|
||||||
testonly = True, |
|
||||||
srcs = [ |
|
||||||
"manifest_file.cc", |
|
||||||
], |
|
||||||
hdrs = [ |
|
||||||
"manifest_file.h", |
|
||||||
], |
|
||||||
external_deps = [ |
|
||||||
"absl/strings", |
|
||||||
], |
|
||||||
deps = [ |
|
||||||
"//:gpr", |
|
||||||
], |
|
||||||
) |
|
@ -1,71 +0,0 @@ |
|||||||
// Copyright 2023 The gRPC Authors.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include <grpc/support/port_platform.h> |
|
||||||
|
|
||||||
#include "test/cpp/util/windows/manifest_file.h" |
|
||||||
|
|
||||||
#ifdef GPR_WINDOWS |
|
||||||
|
|
||||||
#include <fstream> |
|
||||||
#include <string> |
|
||||||
#include <vector> |
|
||||||
|
|
||||||
#include "absl/strings/str_format.h" |
|
||||||
#include "absl/strings/str_replace.h" |
|
||||||
#include "absl/strings/str_split.h" |
|
||||||
|
|
||||||
#include <grpc/support/log.h> |
|
||||||
|
|
||||||
#include "src/core/lib/gprpp/crash.h" |
|
||||||
|
|
||||||
namespace grpc { |
|
||||||
namespace testing { |
|
||||||
|
|
||||||
std::string NormalizeFilePath(const std::string& filepath) { |
|
||||||
return absl::StrReplaceAll(filepath, {{"/", "\\"}}); |
|
||||||
} |
|
||||||
|
|
||||||
ManifestFile::ManifestFile(const std::string& filepath) |
|
||||||
: filestream_(filepath, std::ios::in | std::ios::binary) { |
|
||||||
if (!filestream_.is_open()) { |
|
||||||
grpc_core::Crash(absl::StrFormat("Failed to open %s", filepath)); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
std::string ManifestFile::Get(const std::string& key) { |
|
||||||
auto iter = cache_.find(key); |
|
||||||
if (iter != cache_.end()) { |
|
||||||
return iter->second; |
|
||||||
} |
|
||||||
do { |
|
||||||
std::string line; |
|
||||||
std::getline(filestream_, line); |
|
||||||
if (!line.empty()) { |
|
||||||
std::vector<std::string> kv = absl::StrSplit(line, " "); |
|
||||||
GPR_ASSERT(kv.size() == 2); |
|
||||||
cache_.emplace(kv[0], kv[1]); |
|
||||||
if (kv[0] == key) { |
|
||||||
return kv[1]; |
|
||||||
} |
|
||||||
} |
|
||||||
} while (!filestream_.eof() && !filestream_.fail()); |
|
||||||
grpc_core::Crash( |
|
||||||
absl::StrFormat("Failed to find key: %s in MANIFEST file", key)); |
|
||||||
} |
|
||||||
|
|
||||||
} // namespace testing
|
|
||||||
} // namespace grpc
|
|
||||||
|
|
||||||
#endif // GPR_WINDOWS
|
|
@ -1,57 +0,0 @@ |
|||||||
// Copyright 2023 The gRPC Authors.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef GRPC_TEST_CPP_UTIL_WINDOWS_MANIFEST_FILE_H |
|
||||||
#define GRPC_TEST_CPP_UTIL_WINDOWS_MANIFEST_FILE_H |
|
||||||
|
|
||||||
#include <grpc/support/port_platform.h> |
|
||||||
|
|
||||||
#ifdef GPR_WINDOWS |
|
||||||
|
|
||||||
#include <fstream> |
|
||||||
#include <string> |
|
||||||
#include <unordered_map> |
|
||||||
|
|
||||||
namespace grpc { |
|
||||||
namespace testing { |
|
||||||
|
|
||||||
std::string NormalizeFilePath(const std::string& filepath); |
|
||||||
|
|
||||||
// This class is used for handling Runfiles for a Bazel target on Windows (e.g.
|
|
||||||
// the output of targets specified in the data attribute of the target). On
|
|
||||||
// Linux/macOS, Bazel creates a runfiles tree which contains symlinks to the
|
|
||||||
// actual runfiles. But on Windows, it only creates a MANIFEST file which
|
|
||||||
// contains a list of <symlink relative path, absolute symlink target path>.
|
|
||||||
// Thus one initializes a ManifestFile object with the filepath to a MANIFEST
|
|
||||||
// file and uses it as a key-value datastore by querying the absolute symlink
|
|
||||||
// target path with the imaginative symlink relative path. See
|
|
||||||
// https://github.com/bazelbuild/bazel/issues/4261#issuecomment-350723457 for
|
|
||||||
// more details.
|
|
||||||
class ManifestFile { |
|
||||||
public: |
|
||||||
explicit ManifestFile(const std::string& filepath); |
|
||||||
|
|
||||||
std::string Get(const std::string& key); |
|
||||||
|
|
||||||
private: |
|
||||||
std::fstream filestream_; |
|
||||||
std::unordered_map<std::string, std::string> cache_; |
|
||||||
}; |
|
||||||
|
|
||||||
} // namespace testing
|
|
||||||
} // namespace grpc
|
|
||||||
|
|
||||||
#endif // GPR_WINDOWS
|
|
||||||
|
|
||||||
#endif // GRPC_TEST_CPP_UTIL_WINDOWS_MANIFEST_FILE_H
|
|
Loading…
Reference in new issue