Sha256: dadd007f1815d0cea7bfad8db7323adb7778c27d643db04b643869fd70bf2965

Contents?: true

Size: 1.75 KB

Versions: 3

Compression:

Stored size: 1.75 KB

Contents

--- BUILD.bazel
+++ BUILD.bazel
@@ -896,6 +896,10 @@ py_library(
         [
             "python/google/protobuf/**/*.py",
         ],
+        exclude = [
+            "python/google/protobuf/internal/*_test.py",
+            "python/google/protobuf/internal/test_util.py",
+        ]
     ),
     imports = ["python"],
     srcs_version = "PY2AND3",

--- python/google/protobuf/internal/test_util.py
+++ python/google/protobuf/internal/test_util.py
@@ -39,6 +39,7 @@ __author__ = 'robinson@google.com (Will Robinson)'
 import numbers
 import operator
 import os.path
+import pathlib
 
 from google.protobuf import unittest_import_pb2
 from google.protobuf import unittest_pb2
@@ -617,17 +618,22 @@ def ExpectAllFieldsSet(test_case, message):
                           message.default_import_enum)
 
 
+def _SearchUp(path, filename):
+  path = pathlib.Path(path).resolve()
+  for parent in [path] + list(path.parents):
+    file_path = parent / ('src/google/protobuf/testdata/' + filename)
+    if file_path.exists():
+      # Found it.  Load the golden file from the testdata directory.
+      return file_path.open('rb')
+  return None
+
 def GoldenFile(filename):
   """Finds the given golden file and returns a file object representing it."""
 
   # Search up the directory tree looking for the C++ protobuf source code.
-  path = '.'
-  while os.path.exists(path):
-    if os.path.exists(os.path.join(path, 'src/google/protobuf')):
-      # Found it.  Load the golden file from the testdata directory.
-      full_path = os.path.join(path, 'src/google/protobuf/testdata', filename)
-      return open(full_path, 'rb')
-    path = os.path.join(path, '..')
+  f = _SearchUp('.', filename) or _SearchUp(__file__, filename)
+  if f:
+      return f
 
   # Search internally.
   path = '.'

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby_memprofiler_pprof-0.0.4 ext/ruby_memprofiler_pprof_ext/vendor/upb/bazel/protobuf.patch
ruby_memprofiler_pprof-0.0.3 ext/ruby_memprofiler_pprof/vendor/upb/bazel/protobuf.patch
ruby_memprofiler_pprof-0.0.1 ext/ruby_memprofiler_pprof/vendor/upb/bazel/protobuf.patch