Page MenuHomePhabricator

[comm-services-lib] Fix doctests
ClosedPublic

Authored by michal on Aug 21 2023, 6:02 AM.
Tags
None
Referenced Files
F3385568: D8889.id30137.diff
Fri, Nov 29, 1:02 AM
Unknown Object (File)
Tue, Nov 26, 4:01 AM
Unknown Object (File)
Mon, Nov 25, 6:58 PM
Unknown Object (File)
Mon, Nov 25, 12:49 PM
Unknown Object (File)
Mon, Nov 25, 9:12 AM
Unknown Object (File)
Tue, Nov 19, 11:38 PM
Unknown Object (File)
Tue, Nov 19, 11:16 PM
Unknown Object (File)
Fri, Nov 15, 10:02 AM
Subscribers

Details

Summary

We have some examples in services lib (which is great!) but when running cargo test in comm-services-lib they all fail. This diff improves the examples so they can also be run alongside tests.

Here is some more info about documentation tests: https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html

We can use /// # syntax to include utility code that allows the example to be run, but won't be visible when generating the docs/ hovering over the definition in IDE.

This all adds some verbosity, so if it's decided that it's not the best option we should at least add ignore so the examples aren't run/compiled when running cargo test

Test Plan

cargo test --all-features

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

Harbormaster returned this revision to the author for changes because remote builds failed.Aug 21 2023, 6:08 AM
Harbormaster failed remote builds in B21945: Diff 30137!

Okay, this is the one thing I hate about rust - these are MY comments and it shoul not be doctest's business unless I explicitly ask it for opinions.
Examples should be readable for us, for our use cases, I don't care about what doctest expects.

We can use /// # syntax to include utility code that allows the example to be run, but won't be visible when generating the docs/ hovering over the definition in IDE.

I don't care about running examples - it's useless when it comes to database/external services related code. I wrote these on purpose to be displayed in IDE when hovering.

This all adds some verbosity, so if it's decided that it's not the best option we should at least add ignore so the examples aren't run/compiled when running cargo test

Yeah, there should be an option to ignore this and tbh I'd prefer that

Cool, changed approach to just ignoring the examples

This revision is now accepted and ready to land.Aug 22 2023, 3:49 AM