Fixed test_util.py so that golden data can be found.

pull/13171/head
Joshua Haberman 3 years ago
parent c2209d1a29
commit 33b6049871
  1. 26
      bazel/protobuf.patch
  2. 3
      python/pb_unit_tests/BUILD
  3. 8
      python/pb_unit_tests/message_test_wrapper.py

@ -1,5 +1,14 @@
--- BUILD
+++ BUILD
@@ -525,7 +525,7 @@ cc_binary(
filegroup(
name = "testdata",
srcs = glob(["src/google/protobuf/testdata/**/*"]),
- visibility = ["//:__subpackages__"],
+ visibility = ["//visibility:public"],
)
RELATIVE_LITE_TEST_PROTOS = [
@@ -931,13 +931,10 @@ py_library(
[
"python/google/protobuf/**/*.py",
@ -45,3 +54,20 @@
)
py_library(
--- python/google/protobuf/internal/test_util.py
+++ python/google/protobuf/internal/test_util.py
@@ -634,6 +634,13 @@ def GoldenFile(filename):
# Found it. Load the golden file from the testdata directory.
return open(full_path, 'rb')
+ # Search for cross-repo path.
+ full_path = os.path.join('external/com_google_protobuf/src/google/protobuf/testdata',
+ filename)
+ if os.path.exists(full_path):
+ # Found it. Load the golden file from the testdata directory.
+ return open(full_path, 'rb')
+
raise RuntimeError(
'Could not find golden files. This test must be run from within the '
'protobuf source package so that it can read test data files from the '

@ -124,6 +124,9 @@ py_test(
"@com_google_protobuf//:python_common_test_protos",
"@com_google_protobuf//:python_specific_test_protos",
],
data = [
"@com_google_protobuf//:testdata",
],
legacy_create_init = False,
)

@ -36,19 +36,11 @@ message_test.MessageTest.testExtendStringWithNothing_proto2.__unittest_expecting
message_test.MessageTest.testExtendStringWithNothing_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testFloatPrinting_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testFloatPrinting_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testGoldenMessage_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testGoldenMessage_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testGoldenPackedMessage_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testGoldenPackedMessage_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testHighPrecisionDoublePrinting_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testHighPrecisionDoublePrinting_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testInsertRepeatedCompositeField_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testInsertRepeatedCompositeField_proto3.__unittest_expecting_failure__ = True
message_test.MessageTest.testPickleSupport_proto2.__unittest_expecting_failure__ = True
message_test.MessageTest.testPickleSupport_proto3.__unittest_expecting_failure__ = True
message_test.Proto2Test.testExtensionsErrors.__unittest_expecting_failure__ = True
message_test.Proto2Test.testGoldenExtensions.__unittest_expecting_failure__ = True
message_test.Proto2Test.testGoldenPackedExtensions.__unittest_expecting_failure__ = True
message_test.Proto2Test.testPythonicInit.__unittest_expecting_failure__ = True
message_test.Proto2Test.test_documentation.__unittest_expecting_failure__ = True
message_test.Proto3Test.testCopyFromBadType.__unittest_expecting_failure__ = True

Loading…
Cancel
Save