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

mtest: rust: allow parsing doctest output #13905

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bonzini
Copy link
Contributor

@bonzini bonzini commented Nov 15, 2024

Doctests have a slightly different output compared to what "protocol: rust" supports:

running 2 tests
test rust/qemu-api/libqemu_api.rlib.p/structured/lib.rs - QemuAllocator (line 49) ... ignored
test rust/qemu-api/libqemu_api.rlib.p/structured/zeroable.rs - zeroable::Zeroable (line 9) ... ok

test result: ok. 1 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.11s

Add a little more parsing in order to parse this correctly. I plan to contribute an extension of the rust module to invoke doctests, for now this allows running rustdoc --test with "protocol: rust" and get information about the subtests:

2/3 qemu:unit+rust / rust-qemu-api-doctests           RUNNING
...
▶ 2/3 test rust/qemu-api/libqemu_api.rlib.p/structured/lib.rs:QemuAllocator:49 SKIP
▶ 2/3 test rust/qemu-api/libqemu_api.rlib.p/structured/zeroable.rs:zeroable.Zeroable:9 OK
2/3 qemu:unit+rust / rust-qemu-api-doctests           OK              1.20s   1 subtests passed

@bonzini bonzini marked this pull request as ready for review November 15, 2024 12:03
@bonzini
Copy link
Contributor Author

bonzini commented Nov 15, 2024

CI failures seem to be independent.

Copy link
Member

@dcbaker dcbaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks fine, I think we have a test for the main rust code, I would appreciate a test for the doctest portion as well, with the assumption that in the future that test would use the doctest code you're interested in.

Doctests have a slightly different output compared to what "protocol: rust"
supports:

  running 2 tests
  test ../doctest1.rs - my_func (line 7) ... ignored
  test ../doctest1.rs - (line 3) ... ok

  test result: ok. 1 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.12s

Add a little more parsing in order to accept this; a simple minded split()
fails to unpack the tuple.  I plan to contribute an extension of the rust
module to invoke doctests, for now this allows running rustdoc --test with
"protocol: 'rust'" and get information about the subtests:

  ▶ 4/8 ../doctest1.rs:my_func:7                     SKIP
  ▶ 4/8 ../doctest1.rs:3                             OK
  4/8 rust_unit_tests:doctests / rust doctest        OK              0.28s   1 subtests passed

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
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 this pull request may close these issues.

2 participants