conformance.proto 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. // https://developers.google.com/protocol-buffers/
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions are
  7. // met:
  8. //
  9. // * Redistributions of source code must retain the above copyright
  10. // notice, this list of conditions and the following disclaimer.
  11. // * Redistributions in binary form must reproduce the above
  12. // copyright notice, this list of conditions and the following disclaimer
  13. // in the documentation and/or other materials provided with the
  14. // distribution.
  15. // * Neither the name of Google Inc. nor the names of its
  16. // contributors may be used to endorse or promote products derived from
  17. // this software without specific prior written permission.
  18. //
  19. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. syntax = "proto3";
  31. package conformance;
  32. option java_package = "com.google.protobuf.conformance";
  33. // This defines the conformance testing protocol. This protocol exists between
  34. // the conformance test suite itself and the code being tested. For each test,
  35. // the suite will send a ConformanceRequest message and expect a
  36. // ConformanceResponse message.
  37. //
  38. // You can either run the tests in two different ways:
  39. //
  40. // 1. in-process (using the interface in conformance_test.h).
  41. //
  42. // 2. as a sub-process communicating over a pipe. Information about how to
  43. // do this is in conformance_test_runner.cc.
  44. //
  45. // Pros/cons of the two approaches:
  46. //
  47. // - running as a sub-process is much simpler for languages other than C/C++.
  48. //
  49. // - running as a sub-process may be more tricky in unusual environments like
  50. // iOS apps, where fork/stdin/stdout are not available.
  51. enum WireFormat {
  52. UNSPECIFIED = 0;
  53. PROTOBUF = 1;
  54. JSON = 2;
  55. JSPB = 3; // Google internal only. Opensource testees just skip it.
  56. TEXT_FORMAT = 4;
  57. }
  58. enum TestCategory {
  59. UNSPECIFIED_TEST = 0;
  60. BINARY_TEST = 1; // Test binary wire format.
  61. JSON_TEST = 2; // Test json wire format.
  62. // Similar to JSON_TEST. However, during parsing json, testee should ignore
  63. // unknown fields. This feature is optional. Each implementation can descide
  64. // whether to support it. See
  65. // https://developers.google.com/protocol-buffers/docs/proto3#json_options
  66. // for more detail.
  67. JSON_IGNORE_UNKNOWN_PARSING_TEST = 3;
  68. // Test jspb wire format. Google internal only. Opensource testees just skip it.
  69. JSPB_TEST = 4;
  70. // Test text format. For cpp, java and python, testees can already deal with
  71. // this type. Testees of other languages can simply skip it.
  72. TEXT_FORMAT_TEST = 5;
  73. }
  74. // The conformance runner will request a list of failures as the first request.
  75. // This will be known by message_type == "conformance.FailureSet", a conformance
  76. // test should return a serialized FailureSet in protobuf_payload.
  77. message FailureSet {
  78. repeated string failure = 1;
  79. }
  80. // Represents a single test case's input. The testee should:
  81. //
  82. // 1. parse this proto (which should always succeed)
  83. // 2. parse the protobuf or JSON payload in "payload" (which may fail)
  84. // 3. if the parse succeeded, serialize the message in the requested format.
  85. message ConformanceRequest {
  86. // The payload (whether protobuf of JSON) is always for a
  87. // protobuf_test_messages.proto3.TestAllTypes proto (as defined in
  88. // src/google/protobuf/proto3_test_messages.proto).
  89. //
  90. // TODO(haberman): if/when we expand the conformance tests to support proto2,
  91. // we will want to include a field that lets the payload/response be a
  92. // protobuf_test_messages.proto2.TestAllTypes message instead.
  93. oneof payload {
  94. bytes protobuf_payload = 1;
  95. string json_payload = 2;
  96. // Google internal only. Opensource testees just skip it.
  97. string jspb_payload = 7;
  98. string text_payload = 8;
  99. }
  100. // Which format should the testee serialize its message to?
  101. WireFormat requested_output_format = 3;
  102. // The full name for the test message to use; for the moment, either:
  103. // protobuf_test_messages.proto3.TestAllTypesProto3 or
  104. // protobuf_test_messages.proto2.TestAllTypesProto2.
  105. string message_type = 4;
  106. // Each test is given a specific test category. Some category may need
  107. // spedific support in testee programs. Refer to the definition of TestCategory
  108. // for more information.
  109. TestCategory test_category = 5;
  110. // Specify details for how to encode jspb.
  111. JspbEncodingConfig jspb_encoding_options = 6;
  112. // This can be used in json and text format. If true, testee should print
  113. // unknown fields instead of ignore. This feature is optional.
  114. bool print_unknown_fields = 9;
  115. }
  116. // Represents a single test case's output.
  117. message ConformanceResponse {
  118. oneof result {
  119. // This string should be set to indicate parsing failed. The string can
  120. // provide more information about the parse error if it is available.
  121. //
  122. // Setting this string does not necessarily mean the testee failed the
  123. // test. Some of the test cases are intentionally invalid input.
  124. string parse_error = 1;
  125. // If the input was successfully parsed but errors occurred when
  126. // serializing it to the requested output format, set the error message in
  127. // this field.
  128. string serialize_error = 6;
  129. // This should be set if some other error occurred. This will always
  130. // indicate that the test failed. The string can provide more information
  131. // about the failure.
  132. string runtime_error = 2;
  133. // If the input was successfully parsed and the requested output was
  134. // protobuf, serialize it to protobuf and set it in this field.
  135. bytes protobuf_payload = 3;
  136. // If the input was successfully parsed and the requested output was JSON,
  137. // serialize to JSON and set it in this field.
  138. string json_payload = 4;
  139. // For when the testee skipped the test, likely because a certain feature
  140. // wasn't supported, like JSON input/output.
  141. string skipped = 5;
  142. // If the input was successfully parsed and the requested output was JSPB,
  143. // serialize to JSPB and set it in this field. JSPB is google internal only
  144. // format. Opensource testees can just skip it.
  145. string jspb_payload = 7;
  146. // If the input was successfully parsed and the requested output was
  147. // TEXT_FORMAT, serialize to TEXT_FORMAT and set it in this field.
  148. string text_payload = 8;
  149. }
  150. }
  151. // Encoding options for jspb format.
  152. message JspbEncodingConfig {
  153. // Encode the value field of Any as jspb array if true, otherwise binary.
  154. bool use_jspb_array_any_format = 1;
  155. }