dep-protobuf/conformance
Protobuf Team Bot 02a9c9dec8 Fix messageset conformance for pure Python to match Py-C++ and Py-upb
MessageSet is a legacy affordance holdover from pre-proto2 days. Unlike the rest of Protobuf, it has first-wins instead of last-wins semantic in the case of duplicate ids or values within the same message set entry.

No serializer would ever write such sequences, but the same hypothetical byte sequence being parsed differently by two implementations is undesirable.

Note that other nonconformance fixes would commonly be held to breaking change releases to avoid any possible disruption of single-language users who may be relying on it as a load-bearing bug. However, the nature of this particular case is such that there is little reason to hold it back.

PiperOrigin-RevId: 964043226
2026-08-13 06:25:58 -07:00
..
ruby Add conformance test for edition unstable 2025-12-29 07:41:37 -08:00
test_protos Make default_symbol_visibility STRICT in edition 2026 2026-06-25 13:11:42 -07:00
autoload.php Clean up PHP CI (#18610) 2024-10-04 15:54:43 -07:00
bazel_conformance_test_runner.sh Use Bazel's $(location) to determine location of conformance data dependencies 2025-03-05 15:16:44 -08:00
binary_json_conformance_suite.cc Add conformance tests for MessageSet duplicates-within-one-entry handling. 2026-08-05 10:34:05 -07:00
binary_json_conformance_suite.h Update conformance tests with updated relaxed duplicate key handling in ProtoJSON 2026-08-02 09:58:52 -07:00
binary_wireformat.cc Add helpers for length delimited sub-messages and packed wire format 2025-05-20 12:31:08 -07:00
binary_wireformat.h Add helpers for length delimited sub-messages and packed wire format 2025-05-20 12:31:08 -07:00
binary_wireformat_test.cc Add helpers for length delimited sub-messages and packed wire format 2025-05-20 12:31:08 -07:00
BUILD Update conformance tests with updated relaxed duplicate key handling in ProtoJSON 2026-08-02 09:58:52 -07:00
conformance.proto Add conformance test for edition unstable 2025-12-29 07:41:37 -08:00
conformance_cpp.cc Add conformance test for edition unstable 2025-12-29 07:41:37 -08:00
conformance_objc.m Add conformance test for edition unstable 2025-12-29 07:41:37 -08:00
conformance_php.php Add conformance test for edition unstable 2025-12-29 07:41:37 -08:00
conformance_python.py Add conformance test for edition unstable 2025-12-29 07:41:37 -08:00
conformance_rust.rs Change _opt() accessors to return an std::Option instead of protobuf::Optional 2026-03-13 08:31:00 -07:00
conformance_test.cc Add conformance test for edition unstable 2025-12-29 07:41:37 -08:00
conformance_test.h Refactor conformance library 2025-05-09 20:46:35 -07:00
conformance_test_main.cc Refactor conformance library 2025-05-09 20:46:35 -07:00
conformance_test_runner.cc Clean up ForkPipeRunner API 2025-05-19 19:23:45 -07:00
ConformanceJava.java Remove redundant binary decoders from Java and Java Lite conformance testees 2026-07-28 15:13:25 -07:00
ConformanceJavaLite.java Remove redundant binary decoders from Java and Java Lite conformance testees 2026-07-28 15:13:25 -07:00
defs.bzl Add conformance performance test suite for csharp (#26194) 2026-03-09 06:25:24 -07:00
failure_list_cpp.txt Update conformance tests with updated relaxed duplicate key handling in ProtoJSON 2026-08-02 09:58:52 -07:00
failure_list_csharp.txt Update conformance tests with updated relaxed duplicate key handling in ProtoJSON 2026-08-02 09:58:52 -07:00
failure_list_csharp_performance.txt Add conformance performance test suite for csharp (#26194) 2026-03-09 06:25:24 -07:00
failure_list_dart_upb.txt Add conformance test for Dart UPB VM 2023-08-11 12:57:58 -07:00
failure_list_java.txt Add conformance tests for MessageSet duplicates-within-one-entry handling. 2026-08-05 10:34:05 -07:00
failure_list_java_lite.txt Add conformance tests for MessageSet duplicates-within-one-entry handling. 2026-08-05 10:34:05 -07:00
failure_list_jruby.txt Add conformance tests for MessageSet duplicates-within-one-entry handling. 2026-08-05 10:34:05 -07:00
failure_list_jruby_ffi.txt Update conformance tests with updated relaxed duplicate key handling in ProtoJSON 2026-08-02 09:58:52 -07:00
failure_list_objc.txt [ObjC] Revise tag parsing to have a 5 byte limit. 2025-12-15 07:44:58 -08:00
failure_list_objc_performance.txt Internal Change. 2026-08-04 14:52:53 -07:00
failure_list_php.txt Update conformance tests with updated relaxed duplicate key handling in ProtoJSON 2026-08-02 09:58:52 -07:00
failure_list_php_c.txt Update conformance tests with updated relaxed duplicate key handling in ProtoJSON 2026-08-02 09:58:52 -07:00
failure_list_python-post26.txt Down-integrate from google3. 2018-08-08 17:00:41 -07:00
failure_list_python.txt Fix messageset conformance for pure Python to match Py-C++ and Py-upb 2026-08-13 06:25:58 -07:00
failure_list_python_cpp.txt Update conformance tests with updated relaxed duplicate key handling in ProtoJSON 2026-08-02 09:58:52 -07:00
failure_list_python_upb.txt Update conformance tests with updated relaxed duplicate key handling in ProtoJSON 2026-08-02 09:58:52 -07:00
failure_list_ruby.txt Update conformance tests with updated relaxed duplicate key handling in ProtoJSON 2026-08-02 09:58:52 -07:00
failure_list_rust_cc.txt Fix UTF-8 Validation of string extensions in C++ 2026-01-27 21:21:28 -08:00
failure_list_rust_upb.txt Added infrastructure for Rust Extensions support, but left it disabled for now. 2026-04-08 08:08:46 -07:00
failure_list_trie_node.cc Switch back to using absl::optional everywhere for compatibility with older versions of Abseil 2025-11-21 12:45:34 -08:00
failure_list_trie_node.h Switch back to using absl::optional everywhere for compatibility with older versions of Abseil 2025-11-21 12:45:34 -08:00
failure_list_trie_node_test.cc Switch back to using absl::optional everywhere for compatibility with older versions of Abseil 2025-11-21 12:45:34 -08:00
fork_pipe_runner.cc Suppress failure to consume parse/serialize return values. 2025-12-05 08:01:34 -08:00
fork_pipe_runner.h Clean up ForkPipeRunner API 2025-05-19 19:23:45 -07:00
naming.h Add conformance test for edition unstable 2025-12-29 07:41:37 -08:00
naming_test.cc Add conformance test for edition unstable 2025-12-29 07:41:37 -08:00
README.md update min mac ver from 11 to 12 2025-12-16 10:18:38 -08:00
test_manager.cc Use std::optional (#21864) 2025-05-22 11:19:40 -07:00
test_manager.h Introduce a new test manager class for handling conformance results. 2025-05-20 12:51:48 -07:00
test_manager_test.cc Introduce a new test manager class for handling conformance results. 2025-05-20 12:51:48 -07:00
test_runner.h Clean up ForkPipeRunner API 2025-05-19 19:23:45 -07:00
testee.cc Suppress failure to consume parse/serialize return values. 2025-12-05 08:01:34 -08:00
testee.h Add metadata annotations for generated Python protobuf symbols. 2026-01-06 16:05:56 -08:00
testee_test.cc Breaking change: Add [[nodiscard]] to many APIs. 2026-01-05 08:41:35 -08:00
text_format_conformance_suite.cc Add conformance tests for parsing custom Any type URLs in text-protos. 2026-02-06 00:49:09 -08:00
text_format_conformance_suite.h Automated Code Change 2025-04-01 01:12:54 -07:00
text_format_failure_list_cpp.txt Wildcard support for Protobuf conformance failure lists by using a Trie made up of nodes that contain a section of a test name (divided by '.'). 2024-08-14 13:48:26 -07:00
text_format_failure_list_dart_upb.txt Add conformance test for Dart UPB VM 2023-08-11 12:57:58 -07:00
text_format_failure_list_java.txt Add conformance tests for parsing custom Any type URLs in text-protos. 2026-02-06 00:49:09 -08:00
text_format_failure_list_java_lite.txt Sync from Piper @368903491 2021-04-16 12:59:54 -07:00
text_format_failure_list_php.txt Clean up PHP CI (#18610) 2024-10-04 15:54:43 -07:00
text_format_failure_list_python.txt Add conformance tests for parsing custom Any type URLs in text-protos. 2026-02-06 00:49:09 -08:00
text_format_failure_list_rust_cc.txt Make Rust Conformance skip non-wire output test cases by using an overlay proto. 2024-01-02 10:33:11 -08:00
text_format_failure_list_rust_upb.txt Make Rust Conformance skip non-wire output test cases by using an overlay proto. 2024-01-02 10:33:11 -08:00
update_failure_list.py Create a test fixture for update_failure_list.py and carry out three tests. 2024-08-16 12:00:46 -07:00

Protocol Buffers - Google's data interchange format

Copyright 2008 Google LLC.

This directory contains conformance tests for testing completeness and correctness of Protocol Buffers implementations. These tests are designed to be easy to run against any Protocol Buffers implementation.

This directory contains the tester process conformance-test, which contains all of the tests themselves. Then separate programs written in whatever language you want to test communicate with the tester program over a pipe.

If you're not using Bazel to run these tests, make sure you build the C++ tester code beforehand, e.g. from the base directory:

$ cmake . -Dprotobuf_BUILD_CONFORMANCE=ON && cmake --build .

This will produce a conformance_test_runner binary that can be used to run conformance tests on any executable. Pass it --help for more information.

Running the tests for C++

To run the tests against the C++ implementation, run:

$ bazel test //src:conformance_test

Or alternatively with CMake:

$ ctest -R conformance_cpp_test

Running the tests for other languages

All of the languages in the Protobuf source tree are set up to run conformance tests using similar patterns. You can either use Bazel to run the conformance_test target defined in the language's root BUILD.bazel file, or create an executable for a custom test and pass it to conformance_test_runner.

Note: CMake can be used to build the conformance test runner, but not any of the conformance test executables outside C++. So if you aren't using Bazel you'll need to create the executable you pass to conformance_test_runner via some alternate build system.

While we plan to model all our supported languages more completely in Bazel, today some of them are a bit tricky to run. Below is a list of the commands (and prerequisites) to run each language's conformance tests.

C#:

$ which dotnet || echo "You must have dotnet installed!"
$ bazel test //csharp:conformance_test \
    --action_env=DOTNET_CLI_TELEMETRY_OPTOUT=1 --test_env=DOTNET_CLI_HOME=~ \
    --action_env=DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1

Java:

$ bazel test //java/core:conformance_test //java/lite:conformance_test

Objective-C (Mac only):

$ bazel test //objectivec:conformance_test --macos_minimum_os=12.0

PHP:

$ bazel test //php:conformance_test

PHP (C):

$ which gcc     || echo "gcc is required!"
$ which libtool || echo "libtool is required!"
$ which make    || echo "make is required!"
$ which pear    || echo "pear is required! It might require a development version of PHP such as a php-dev package"
$ which pecl    || echo "pecl is required! It might require a development version of PHP such as a php-dev package"
$ which phpize  || echo "phpize is required! It might require a development version of PHP such as a php-dev package"
$ bazel test //php:conformance_test_c

Python:

$ bazel test //python:conformance_test

Python (C++):

$ bazel test //python:conformance_test_cpp --define=use_fast_cpp_protos=true

Ruby:

$ [[ $(ruby --version) == "ruby"* ]] || echo "Select a C Ruby!"
$ bazel test //ruby:conformance_test --define=ruby_platform=c \
    --action_env=PATH --action_env=GEM_PATH --action_env=GEM_HOME

Ruby (JRuby):

$ [[ $(ruby --version) == "jruby"* ]] || echo "Switch to Java Ruby!"
$ bazel test //ruby:conformance_test_jruby --define=ruby_platform=java \
    --action_env=PATH --action_env=GEM_PATH --action_env=GEM_HOME

Testing other Protocol Buffer implementations

To run these tests against a new Protocol Buffers implementation, write a program in your language that uses the protobuf implementation you want to test. This program should implement the testing protocol defined in conformance.proto. This is designed to be as easy as possible: the C++ version is only 150 lines and is a good example for what this program should look like (see conformance_cpp.cc). The program only needs to be able to read from stdin and write to stdout.

Portability

Note that the test runner currently does not work on Windows. Patches to fix this are welcome! (But please get in touch first to settle on a general implementation strategy).