Skip to content

Document and automate the command for running doc/unit tests #281

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

Closed
GabrielMajeri opened this issue Sep 7, 2021 · 3 comments · Fixed by #283
Closed

Document and automate the command for running doc/unit tests #281

GabrielMajeri opened this issue Sep 7, 2021 · 3 comments · Fixed by #283
Assignees

Comments

@GabrielMajeri
Copy link
Collaborator

GabrielMajeri commented Sep 7, 2021

Running the main crate's doc/unit tests requires the following command:

CARGO_PROFILE_DEV_PANIC=unwind cargo test -Z build-std=std test --target x86_64-unknown-linux-gnu

We should document it, or integrate it into the existing build.py script, to make it easier for developers to run such tests locally.

@necauqua
Copy link
Contributor

necauqua commented Sep 8, 2021

If you setup a proper .cargo/config file for your architecture (at least build-std and target can be moved to that file, not so sure about CARGO_PROFILE_DEV_PANIC) , the command can be just cargo test.

And also you can specify a runner script in .cargo/config, so you can make it run your python harness so that cargo run/cargo test run/test with qemu and stuff.

Not sure how it would work for the lib repo, but for end-crates depending on it (like my one) things I've described above are pretty cool

@GabrielMajeri
Copy link
Collaborator Author

@necauqua we have a .cargo/config file in the repo, but it builds the core crates for the library to run in the bare metal UEFI environment, while the tests run using std on the host machine. Is it possible to specify such settings per target?

@necauqua
Copy link
Contributor

Oh wait, now I see, I misunderstood - you run tests on a host machine and those tests need full std, so you override the .cargo/config setting from the command line.

My thought was that you can specify a runner script in the .cargo/config and then have plain cargo test command execute the python script which would set up and run a qemu instance.


That's actually related to my proof of concept thing that I've been working on sometimes - making use of a custom_test_frameworks nightly feature where unit tests in the code (except the attribute is uefi_test proc-macro instead of plain test one - would be awesome, but not possible for now) are run on the qemu through the plain cargo test command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants