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

Missing doc tests #12

Closed
josecelano opened this issue Sep 25, 2023 · 8 comments · Fixed by #20
Closed

Missing doc tests #12

josecelano opened this issue Sep 25, 2023 · 8 comments · Fixed by #20

Comments

@josecelano
Copy link
Owner

$ cargo pretty-test
thread 'main' panicked at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-pretty-test-0.2.0/src/parsing.rs:430:5:
assertion `left == right` failed: the parsed amount of running tests [265, 0, 96, 31] should equal to the number in stats.total [265, 0, 96, 0]
  left: [265, 0, 96, 31]
 right: [265, 0, 96, 0]
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The whole cargo test output I'm using:

cargo_test_ouput.txt

@zjp-CN
Copy link
Collaborator

zjp-CN commented Sep 25, 2023

Is there any reproducible code?

The error shows the amount of last type test is 31 directly from the raw output, but zero tests are actually computed afterr parsing.

Or try the patch to see if it works as expected:
cargo install cargo-pretty-test --git https://github.com/zjp-CN/pretty-test.git --branch experimental

@josecelano

This comment was marked as resolved.

@josecelano

This comment was marked as outdated.

@zjp-CN
Copy link
Collaborator

zjp-CN commented Sep 25, 2023

I can reproduce it now. But it's late now. I'll check it out tomorrow.

@josecelano
Copy link
Owner Author

I can reproduce it now. But it's late now. I'll check it out tomorrow.

OK. No worries. I would do it, but I have to review the whole code first. You have done a lot!

@zjp-CN
Copy link
Collaborator

zjp-CN commented Sep 26, 2023

Found the crux: the regex for parsing doc test items is the literally doc, but should be a \S+ pattern instead.

test src/servers/http/v1/responses/announce.rs - servers::http::v1::responses::announce::NonCompact (line 21) ... ok

And it seems to be an additional part - compile for no_run doc tests.

test src/tracker/peer.rs - tracker::peer::Peer (line 48) - compile ... ok

tree: Regex::new(r"(?m)^test (?P<split>\S+( - should panic)?( - doc \(line \d+\))?) \.\.\. (?P<status>\S+(, .*)?)$").expect(RE_ERROR),

zjp-CN added a commit to zjp-CN/pretty-test that referenced this issue Sep 26, 2023
close josecelano#12

add more doc tests to integration test
@josecelano
Copy link
Owner Author

Found the crux: the regex for parsing doc test items is the literally doc, but should be a \S+ pattern instead.

test src/servers/http/v1/responses/announce.rs - servers::http::v1::responses::announce::NonCompact (line 21) ... ok

And it seems to be an additional part - compile for no_run doc tests.

test src/tracker/peer.rs - tracker::peer::Peer (line 48) - compile ... ok

tree: Regex::new(r"(?m)^test (?P<split>\S+( - should panic)?( - doc \(line \d+\))?) \.\.\. (?P<status>\S+(, .*)?)$").expect(RE_ERROR),

Good catch! That regex deserves a crate for itself :-)

@zjp-CN
Copy link
Collaborator

zjp-CN commented Sep 26, 2023

#20 already contains full rustdoc attributes tests

88726b6#diff-b2c08f496e9c45b70893a9e0fc514f87cd9483de279fa6d1114c26f693b172a6R43

so I think the regex for doc tests is tested.

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

Successfully merging a pull request may close this issue.

2 participants