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

Protobuf comments may be interpreted as doctests #214

Open
olix0r opened this issue Oct 22, 2019 · 1 comment
Open

Protobuf comments may be interpreted as doctests #214

olix0r opened this issue Oct 22, 2019 · 1 comment
Labels

Comments

@olix0r
Copy link
Contributor

olix0r commented Oct 22, 2019

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.

@olix0r olix0r added the bug label Oct 22, 2019
@mzabaluev
Copy link
Contributor

There should be a generator option on how to treat the comments from .proto: ignore, include verbatim as markdown, or try to sanitize as markdown-neutral text.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants