Skip to content

Expected include to be processed before mdbook test #855

@carols10cents

Description

@carols10cents

What happened:

I'm experimenting with extracting code examples from TRPL into their own files for a variety of reasons. However, I'd like to retain the mdbook test functionality.

I extracted an example that compiles and currently passes mdbook test into its own file in this commit.

I then ran mdbook test, and got this error (mdbook --version = v0.1.7):

failures:

---- /var/folders/qc/0ry2bjtd7wd9q8r1c7wylplr0000gn/T/mdbookmFaM3A/ch03-01-variables-and-mutability.md - _::Variables_and_Mutability (line 74) stdout ----
error: expected `[`, found `include`
 --> /var/folders/qc/0ry2bjtd7wd9q8r1c7wylplr0000gn/T/mdbookmFaM3A/ch03-01-variables-and-mutability.md:75:4
  |
3 | {{#include ../examples/ch03-01-variables-and-mutability/unnumbered-02/src/main.rs }}
  |    ^^^^^^^ expected `[`

thread '/var/folders/qc/0ry2bjtd7wd9q8r1c7wylplr0000gn/T/mdbookmFaM3A/ch03-01-variables-and-mutability.md - _::Variables_and_Mutability (line 74)' panicked at 'couldn't compile the test', librustdoc/test.rs:332:13

I just tried with mdbook 0.2.2 and got the same result. I'm using Rust 1.31.0.

What I expected to happen:

I expected the #include preprocessing to happen before running doctests so that mdbook test would have the same behavior as it did before I extracted the file. It looks like that's not happening because rustdoc is trying to compile {{#include.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-TestsArea: `mbdook test` related tests

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions