Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated code breaks doc tests #1478

Closed
izderadicka opened this issue Dec 29, 2018 · 1 comment
Closed

Generated code breaks doc tests #1478

izderadicka opened this issue Dec 29, 2018 · 1 comment

Comments

@izderadicka
Copy link

I'm generating binding for libavformat (ffmpeg libraries).
Code works however generated binding breaks doc tests.
Using ffmpeg-4.1 code

Input C/C++ Header

#include "libavformat/avformat.h"

Bindgen Invocation

bindgen \
--whitelist-type AVFormatContext \
--whitelist-function av_log_set_level \
--whitelist-function av_register_all \
--whitelist-function avformat_version \
--whitelist-function avformat_alloc_context \
--whitelist-function avformat_open_input \
--whitelist-function avformat_find_stream_info \
--whitelist-function avformat_close_input \
--whitelist-function av_dump_format \
--whitelist-var AV_LOG_QUIET \
wrapper.h -- -I ffmpeg-4.1 \
> src/ffi.rs

Actual Results

this is result of cargo test (doc tests section)

   Doc-tests media_info

running 3 tests
test src/ffi.rs - ffi::AVCodecContext::hw_frames_ctx (line 4100) ... FAILED
test src/ffi.rs - ffi::AVCodecContext::hw_frames_ctx (line 4111) ... FAILED
test src/ffi.rs - ffi::AVChromaLocation (line 947) ... FAILED

failures:

---- src/ffi.rs - ffi::AVCodecContext::hw_frames_ctx (line 4100) stdout ----
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `the`
 --> src/ffi.rs:4101:4
  |
3 | If the default get_buffer2() is used with a hwaccel pixel
  |    ^^^ expected one of 8 possible tokens here

error[E0425]: cannot find value `If` in this scope
 --> src/ffi.rs:4101:1
  |
3 | If the default get_buffer2() is used with a hwaccel pixel
  | ^^ not found in this scope

thread 'src/ffi.rs - ffi::AVCodecContext::hw_frames_ctx (line 4100)' panicked at 'couldn't compile the test', librustdoc/test.rs:333:13
note: Run with `RUST_BACKTRACE=1` for a backtrace.

---- src/ffi.rs - ffi::AVCodecContext::hw_frames_ctx (line 4111) stdout ----
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `field`
 --> src/ffi.rs:4112:6
  |
3 | This field should be set before avcodec_open2() is called.
  |      ^^^^^ expected one of 8 possible tokens here

error[E0425]: cannot find value `This` in this scope
 --> src/ffi.rs:4112:1
  |
3 | This field should be set before avcodec_open2() is called.
  | ^^^^ not found in this scope

thread 'src/ffi.rs - ffi::AVCodecContext::hw_frames_ctx (line 4111)' panicked at 'couldn't compile the test', librustdoc/test.rs:333:13

---- src/ffi.rs - ffi::AVChromaLocation (line 947) stdout ----
error: invalid suffix `st` for numeric literal
 --> src/ffi.rs:948:1
  |
3 | 1st 2nd       1st 2nd horizontal luma sample positions
  | ^^^
  |
  = help: the suffix must be one of the integral types (`u32`, `isize`, etc)

error: expected one of `.`, `;`, `?`, `}`, or an operator, found `2nd`
 --> src/ffi.rs:948:5
  |
3 | 1st 2nd       1st 2nd horizontal luma sample positions
  |     ^^^ expected one of `.`, `;`, `?`, `}`, or an operator here

error[E0308]: mismatched types
 --> src/ffi.rs:948:1
  |
2 | fn main() {
  |           - expected `()` because of default return type
3 | 1st 2nd       1st 2nd horizontal luma sample positions
  | ^^^ expected (), found integral variable
  |
  = note: expected type `()`
             found type `{integer}`

thread 'src/ffi.rs - ffi::AVChromaLocation (line 947)' panicked at 'couldn't compile the test', librustdoc/test.rs:333:13


failures:
    src/ffi.rs - ffi::AVChromaLocation (line 947)
    src/ffi.rs - ffi::AVCodecContext::hw_frames_ctx (line 4100)
    src/ffi.rs - ffi::AVCodecContext::hw_frames_ctx (line 4111)

Expected Results

Of course expected that doc tests will pass.
After added option --no-doc-comments problem is resolved, but would expect to include comments in a way that will not infer with doc tests.

bindgen version

bindgen 0.45.0

@emilio
Copy link
Contributor

emilio commented Dec 29, 2018

This is a dupe of #1313.

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

No branches or pull requests

2 participants