The test wrappers were another way to document nonconformant behaviour between
different python backends. We can achieve the same by removing the wrapper
script and adding an if-condition in the test itself based on
api_implementation.Type(). Since we already do that for nonconformance between
pure Python vs. C++ backends, this change makes it easier to look for UPB
nonconformance instead of going through another layer of indirection.
PiperOrigin-RevId: 702723759
The Cargo.toml sets both path and version for its dependencies: the mechanism is that path is used if possible (which it is for our test script), but is automatically stripped from the .toml file when uploadeded to Crates.io
PiperOrigin-RevId: 702721439
Some of the more complex GHA were invoking inline bash scripts without setting `-e`, meaning that failures would go unnoticed.
#test-continuous
PiperOrigin-RevId: 702413176
Rename upb_Log2CeilingSize() to upb_RoundUpToPowerOfTwo() to minimize the chance of this confusion happening in the future.
In practice this condition could never be hit by descriptors generated by protoc since FeatureSet is small and 1-byte-on-wire fields.
PiperOrigin-RevId: 702381123
Upgrading to rules_rust 0.54.1 seems to have fixed some of our Rust linking
problems, but not all, so this change adds back in the
`--@rules_rust//rust/settings:experimental_use_cc_common_link=True` flag.
This fixes some local build errors like the following:
```
$ bazel build //rust/test/shared:bad_names_cpp_test
...
= note: bazel-out/k8-fastbuild/bin/rust/test/shared/_ambiguous_libs/bad_names_cpp_test/libport-330124825.a(port.pic.o):port.cc:function google::protobuf::internal::CounterMap():(.text+0xe6): error: undefined reference to 'atexit'
```
PiperOrigin-RevId: 702380176
Enable Bazel 7 macOS test coverage which otherwise fails with
```
Undefined symbols for architecture arm64:
"_PyModule_AddIntConstant", referenced from:
_PyInit__api_implementation in api_implementation.o
"_PyModule_Create2", referenced from:
_PyInit__api_implementation in api_implementation.o
"__Py_Dealloc", referenced from:
_PyInit__api_implementation in api_implementation.o
ld: symbol(s) not found for architecture arm64
```
Fixes https://github.com/protocolbuffers/protobuf/issues/19454
#test-continuous
PiperOrigin-RevId: 702375059
Our use of `std::derived_from` reportedly fails with libc++ because we don't
include the `<concepts>` header. This change should fix the problem by just
using `std::is_base_of_v` instead, which has the advantage of not requiring
C++20.
Fixes#19364.
PiperOrigin-RevId: 702351498
This will have the side effect of upgrading the Rust version we test against to
1.82.0.
This should fix some build issues caused by Bazel trying to use two separate
linkers, one for for Rust and one for C++. The workaround for that was setting
`--@rules_rust//rust/settings:experimental_use_cc_common_link=True`, but this
upgrade makes that unnecessary.
PiperOrigin-RevId: 702349267
There was no mechanism to recognize test names as prefix of another. Although it seems hard to see where this might occur in practice, this is the way that a trie **should** behave. In other words, this behavior should be here just in case.
The current behavior is that if someone were to insert "Recommended.Proto2.Whatever" and "Recommended.Proto2" to the trie and tried to match "Recommended.Proto2", then it would return false when it should return true. Although this example is not good on a practical sense (why would we ever have a test name like "Recommended.Proto2"...), I can imagine a test name being a derivative of a general case: "Recommended.Proto2.General" and "Recommended.Proto2.General.Specific". Maybe we shouldn't ever have a naming convention like that
; but since there's no standard/enforced naming convention, there's no way to say if we want this behavior or not.
There might be some debate of whether or not to consider these prefixes as duplicates, but I'm not completely sure. We might be able to further enforce naming convention in that "no new test name should be a prefix of another".
Let me know what you think whoever reviews this!
Closes#19207
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/19207 from yamilmorales:main 01b8baba77
PiperOrigin-RevId: 702122383
Some qsort implementations will allocate buffers rather than sorting purely in-place; this new algorithm avoids that and also works in O(n) time rather than O(nlogn).
PiperOrigin-RevId: 702081436
Repeated/map extensions are semantically equivalent to an extension that is not present at all. We had code paths that were treating them differently, which led to incorrect results.
In particular, we were considering `{.repeated_ext = []}` to be different from `{}` when comparing with `upb_Message_IsEqual()`. This change fixes this bug so that they will be considered equivalent.
PiperOrigin-RevId: 702072912
The way it is implemented before this CL is that the 'entry point' file goes through the public imports of all .proto files in the current crate and re-exports them (and applies that transitively).
Instead, this lets each .proto->.rs file handle the public imports for that .proto file, and the 'primary entry point' behavior gets any public imports automatically.
PiperOrigin-RevId: 702044709
Refactor the Message_get method to accurately handle optional fields with presence checks by returning NULL if the field is not set. Also, add new unit tests in WellKnownTest.php to ensure correct behavior of reflection properties for optional fields with various data types.
should fix https://github.com/protocolbuffers/protobuf/issues/18966Closes#18982
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/18982 from s2x:fix-property-reflection-values 9d7030bfb5
PiperOrigin-RevId: 701986724
The test wrappers were another way to document nonconformant behaviour between
different python backends. We can achieve the same by removing the wrapper
script and adding an if-condition in the test itself based on
api_implementation.Type(). Since we already do that for nonconformance between
pure Python vs. C++ backends, this change makes it easier to look for UPB
nonconformance instead of going through another layer of indirection.
PiperOrigin-RevId: 700829382
This is needed for `rules_java` which requires additional loads for Bazel 8. This provides a single entrypoint for extra dependencies so we can add these moving forward without breaking users, and is similar to https://github.com/grpc/grpc/blob/master/bazel/grpc_extra_deps.bzl.
Non-bzlmod users should make sure to set the following in their WORKSPACE file:
```
http_archive(
name = "protobuf",
strip_prefix = "protobuf-VERSION",
sha256 = ...,
url = ...,
)
load("@protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()
load("@protobuf//:protobuf_extra_deps.bzl", "protobuf_extra_deps")
protobuf_extra_deps();
```
PiperOrigin-RevId: 700810708
Add a new implementation of Message.__dir__ method that filters out
attributes which are not accessible. Such an attribute is currently
only `Extensions`, which is only accessible if any extension exists.
Add a unit test that verifies all remaining attributes can be accessed.
PiperOrigin-RevId: 700778715
Before, the upb_ExtensionRegistry_AddArray API would just return a boolean
indicating whether the operation succeeded or failed. This is not descriptive
enough in some cases and made the error output confusing.
Specifically, when trying to register an extension with a duplicate extension
number, AddArray first performs a map lookup before inserting the extension
entry into the registry. The code handled lookup failure (due to duplicates)
the same way as insertion failure (due to OOM), and printed an error message
that showed OOM when there is a duplicate array entry.
This was acknolwedged in a TODO in the AddArray code comment -- which is now
fixed. :)
PiperOrigin-RevId: 700764584
`PyObject_HEAD` already expands to a field with a semicolon; the extra semicolon is unnecessary, and makes some compilers unhappy.
Closes#16123
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/16123 from goffrie:pyobject_head 947438678f
PiperOrigin-RevId: 700735003