-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Allow running doctests via rust.doctest() #13933
base: master
Are you sure you want to change the base?
Conversation
@@ -42,7 +42,7 @@ | |||
from .backend.backends import Backend | |||
from .compilers import Compiler | |||
from .interpreter.interpreter import SourceOutputs, Interpreter | |||
from .interpreter.interpreterobjects import Test | |||
from .interpreter.interpreterobjects import Test, Doctest |
Check failure
Code scanning / CodeQL
Module-level cyclic import
@@ -42,7 +42,7 @@ | |||
from .backend.backends import Backend | |||
from .compilers import Compiler | |||
from .interpreter.interpreter import SourceOutputs, Interpreter | |||
from .interpreter.interpreterobjects import Test | |||
from .interpreter.interpreterobjects import Test, Doctest |
Check failure
Code scanning / CodeQL
Module-level cyclic import
06d0967
to
625e503
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't read things too closely, but here's some initial review.
3817dbd
to
7b380be
Compare
As much to help me keep track of things: patches 1-5 (remove cratetype variable) are r-b |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reviewed up to (including) ninjabackend: remove cratetype variable
.
I've got a couple of small nits on those, but otherwise I'm happy for those to land. I'll try to get around to the rest later today
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I made it to the end before the EOD!
There's some minor stuff in here, but overall I think this is very close to being ready to land.
cef6179
to
defbf2b
Compare
Same. Let's push these preliminary fixups now: b825fae...d34c37f |
Allow reusing the code for doctests. In particular, the sources are shared between the two cases. Signed-off-by: Paolo Bonzini <[email protected]>
This will be used by rustdoc tests because the Test objects takes a single string for the command and everything else goes in the args. But apart from this, the need to split the executable from the arguments is common so create new methods to do it. While at it, fix brokenness in the handling of the zig compiler, which is checking against "zig" but failing to detect e.g. "/usr/bin/zig". Signed-off-by: Paolo Bonzini <[email protected]>
A doctest target is a separate build target (with its own linker arguments, including dependencies) that is built and added as a unit test whenever the parent target is built. The doctest's target is not accessible via ninja. Signed-off-by: Paolo Bonzini <[email protected]>
Adjust get_rust_compiler_args() to accept the crate-type externally, because rustdoc tests are an executable but are compiled with the parent target's --crate-type. Apart from that, the rustdoc arguments are very similar to the parent target, and are handled by the same functions that were split out of generate_rust_target. This concludes the backend implementation of doctests, only leaving the implementation of a doctest() function in the rust module. Signed-off-by: Paolo Bonzini <[email protected]>
rust.doctest() will have to typecheck that to a list of strings, no other argument types are allowed. Extract the field out of BaseTest, placing it in FuncBenchmark and the rust modules's FuncTest. Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
QEMU needs it in its integration tests (in order to run global constructors), and therefore in rust.doctest too. With this change I could do: # Rust executables do not support objects, so add an intermediate step. rust_qemu_api_objs = static_library( 'rust_qemu_api_objs', objects: [libqom.extract_all_objects(recursive: false), libhwcore.extract_all_objects(recursive: false)]) rust.doctest('rust-qemu-api-doc', _qemu_api_rs, dependencies: [qemu_api, qemu_api_macros], link_with: libqemuutil, link_whole: [rust_qemu_api_objs], suite: ['doc', 'rust']) followed by "meson test --suite doc". For completeness, add it to rust.test as well. Signed-off-by: Paolo Bonzini <[email protected]>
Most of the series is refactoring that avoids duplicating the code that creates arguments to rustc. The integration with build.BuildTarget is a bit rust-specific, so I am willing to change things if you guys don't like it.