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

tests: fix doctests and run in Makefile target #94

Merged
merged 2 commits into from
Sep 15, 2023

Conversation

00xc
Copy link
Member

@00xc 00xc commented Sep 13, 2023

Our custom bare-metal allocator (SvsmAllocator) does not work during tests, as they run as regular userspace binaries. Thus, we must not set it as the global Rust allocator. To do this, we need a compile-time directive that lets us know we are building doctests and not the regular binary (cfg(doctests)), but sadly it is not properly set during test compilation (see rust-lang/rust#45599, rust-lang/rust#67295 and #93).

In order to bypass this, set the compile time flag ourselves via the RUSTFLAGS environment variable so that tests work. Also add the new invocation to the test target in the Makefile.

Closes #93

Remove the deprecated documentation for
ImmutAfterInitRef::new_from_cell(), which caused a doctest to fail.
This method got got removed in order to not depend on a nightly
feature.

Fixes: 0b9c951 ("svsm: do not depend on nightly const_mut_refs feature")
Signed-off-by: Carlos López <carlos.lopez@suse.com>
Our custom bare-metal allocator (`SvsmAllocator`) does not work during
tests, as they run as regular userspace binaries. Thus, we must not
set it as the global Rust allocator. To do this, we need a
compile-time directive that lets us know we are building doctests and
not the regular binary (`cfg(doctests)`), but sadly it is not
properly set during test compilation (see rust-lang/rust#45599,
rust-lang/rust#67295 and coconut-svsm#93).

In order to bypass this, set the compile time flag ourselves via the
RUSTFLAGS environment variable so that tests work. Also add the new
invocation to the `test` target in the Makefile.

Fixes: coconut-svsm#93
Fixes: 8cdea8e ("Cargo manifest: disable doctests")
Signed-off-by: Carlos López <carlos.lopez@suse.com>
Copy link
Collaborator

@roy-hopkins roy-hopkins left a comment

Choose a reason for hiding this comment

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

LGTM

@joergroedel joergroedel merged commit b8a5474 into coconut-svsm:main Sep 15, 2023
2 checks passed
@00xc 00xc deleted the doc/tests branch June 10, 2024 13:14
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.

Fix doctests
3 participants