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

Rust: Allow running doctests and unit tests #5435

Closed
wants to merge 2 commits into from

Conversation

mkrasnitski
Copy link
Contributor

@mkrasnitski mkrasnitski commented May 18, 2024

Adding the cargo::rustc-link-arg option to the build.rs file of the binaryninja crate allows doctests and unit tests to be linked against binaryninjacore.so.1 and ran when invoking cargo test.

Also, the single-colon cargo: syntax is deprecated as of Rust 1.77, and future features will all use the cargo:: syntax. Since the MSRV is already Rust 1.77, it's fine to switch for consistency's sake going forward.

@mkrasnitski mkrasnitski changed the title Switch to cargo:: syntax for build.rs output Rust: Allow running doctests and unit tests May 20, 2024
@mkrasnitski
Copy link
Contributor Author

I guess CI is failing because binja isn't actually installed as part of the GH action? I wouldn't know how to set it up to allow for the linking to succeed - as far as I know the build.rs changes are correct (works on my machine lol)

@emesare
Copy link
Member

emesare commented Jul 10, 2024

I guess CI is failing because binja isn't actually installed as part of the GH action?

You are correct we do not install binja on GH actions, we only use it for PR checks. I think it would be fine to just not run tests in CI.

@mkrasnitski
Copy link
Contributor Author

What's odd is that the doctests compile fine, whereas cargo test --no-run fails to even compile. What could be the difference here?

@emesare
Copy link
Member

emesare commented Jul 10, 2024

What's odd is that the doctests compile fine, whereas cargo test --no-run fails to even compile. What could be the difference here?

The doctests are all annotated with no_run

@mkrasnitski
Copy link
Contributor Author

mkrasnitski commented Jul 10, 2024

Exactly: they type check and compile just fine but don't run. For some reason though, the unit tests don't link correctly even though --no-run is passed, whereas the doctests do. I wonder if there's some subtle difference between how doctests and unit tests are treated here.

@emesare
Copy link
Member

emesare commented Aug 24, 2024

This PR is superseded by rust_break_everything.

Specifically 8a24a43 (Warning: this branch will rewrite history, these commits may not be accurate later)

@emesare emesare closed this Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Rust API Issue needs changes to the Rust API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants