Skip to content
This repository was archived by the owner on Apr 16, 2020. It is now read-only.
This repository was archived by the owner on Apr 16, 2020. It is now read-only.

Protobuf comments may be interpreted as doctests #214

@olix0r

Description

@olix0r

When a protobuf file includes comments that indent or triple-quote text, the generated code fails doctests. For example, a protobuf like the following:

https://github.com/linkerd/linkerd2-proxy/blob/fffe76dae9c72a2184848de5e863206f7e5ebd4b/opencensus-proto/opencensus/proto/trace/v1/trace.proto#L154-L157

will cause test failures like:

running 1 test
test /home/ver/b/l2-proxy/target/debug/build/opencensus-proto-052098f4f8ec2ee6/out/opencensus.proto.trace.v1.rs - trace::v1::span::Attributes::attribute_map (line 150) ... FAILED

failures:

---- /home/ver/b/l2-proxy/target/debug/build/opencensus-proto-052098f4f8ec2ee6/out/opencensus.proto.trace.v1.rs - trace::v1::span::Attributes::attribute_map (line 150) stdout ----
error: expected type, found `"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"`
 --> /home/ver/b/l2-proxy/target/debug/build/opencensus-proto-052098f4f8ec2ee6/out/opencensus.proto.trace.v1.rs:151:21
  |
3 | "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
  |                   - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type
  |                   |
  |                   tried to parse a type due to this

error: aborting due to previous error

Couldn't compile the test.

failures:
    /home/ver/b/l2-proxy/target/debug/build/opencensus-proto-052098f4f8ec2ee6/out/opencensus.proto.trace.v1.rs - trace::v1::span::Attributes::attribute_map (line 150)

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

The generated code should disable doctest from attempting to compile comments originating from protobuf.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions