Debian Codegraph @

third_party/upb/bazel/protobuf.patch

raw
1 --- BUILD.bazel
2 +++ BUILD.bazel
3 @@ -896,6 +896,10 @@ py_library(
4 [
5 "python/google/protobuf/**/*.py",
6 ],
7 + exclude = [
8 + "python/google/protobuf/internal/*_test.py",
9 + "python/google/protobuf/internal/test_util.py",
10 + ]
11 ),
12 imports = ["python"],
13 srcs_version = "PY2AND3",
14
15 --- python/google/protobuf/internal/test_util.py
16 +++ python/google/protobuf/internal/test_util.py
17 @@ -39,6 +39,7 @@ __author__ = '[email protected] (Will Robinson)'
18 import numbers
19 import operator
20 import os.path
21 +import pathlib
22
23 from google.protobuf import unittest_import_pb2
24 from google.protobuf import unittest_pb2
25 @@ -617,17 +618,22 @@ def ExpectAllFieldsSet(test_case, message):
26 message.default_import_enum)
27
28
29 +def _SearchUp(path, filename):
30 + path = pathlib.Path(path).resolve()
31 + for parent in [path] + list(path.parents):
32 + file_path = parent / ('src/google/protobuf/testdata/' + filename)
33 + if file_path.exists():
34 + # Found it. Load the golden file from the testdata directory.
35 + return file_path.open('rb')
36 + return None
37 +
38 def GoldenFile(filename):
39 """Finds the given golden file and returns a file object representing it."""
40
41 # Search up the directory tree looking for the C++ protobuf source code.
42 - path = '.'
43 - while os.path.exists(path):
44 - if os.path.exists(os.path.join(path, 'src/google/protobuf')):
45 - # Found it. Load the golden file from the testdata directory.
46 - full_path = os.path.join(path, 'src/google/protobuf/testdata', filename)
47 - return open(full_path, 'rb')
48 - path = os.path.join(path, '..')
49 + f = _SearchUp('.', filename) or _SearchUp(__file__, filename)
50 + if f:
51 + return f
52
53 # Search internally.
54 path = '.'