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

Add preliminary support for running doctests. #721

Merged
merged 1 commit into from
May 26, 2022

Conversation

Alexhuszagh
Copy link
Contributor

This partially addresses #225.

This only works on nightly, due to the use of the unstable feature doctest-xcompile

The relevant tracking issues are:

If the subcommand is test and the compiler is nightly, we provide the -Zdoctest-xcompile flag if CROSS_UNSTABLE_ENABLE_DOCTESTS=true.

@Alexhuszagh
Copy link
Contributor Author

@Emilgardis I'm not sure how desirable adding unstable features is, but this seems pretty important to testing cross-compiled libraries, so I've added it behind an environment variable (CROSS_UNSTABLE_ENABLE_DOCTESTS), it is only used if run with a nightly compiler, and clearly documents it might be removed at any time.

The README mentions:

### Unstable Features

Certain unstable features can enable additional functionality useful to 
cross-compiling. Note that these are unstable, and may be removed at any
time (particularly if the feature is stabilized or removed), and will
only be used on a nightly channel.

- `CROSS_UNSTABLE_ENABLE_DOCTESTS=true`: also run doctests.

Alexhuszagh added a commit to Alexhuszagh/cross that referenced this pull request May 26, 2022
Allow values of 0, 1, so values other than `true` or `false` can be
provided. `VAR=0`, `VAR=`, `VAR=-0`, or `VAR=false` will evaluate to
false, while the rest will evaluate to true.

Affects cross-rs#661 and cross-rs#721.
Alexhuszagh added a commit to Alexhuszagh/cross that referenced this pull request May 26, 2022
Allow values of 0, 1, so values other than `true` or `false` can be
provided. `VAR=0`, `VAR=`, `VAR=-0`, or `VAR=false` will evaluate to
false, while the rest will evaluate to true.

Affects cross-rs#661 and cross-rs#721.
bors bot added a commit that referenced this pull request May 26, 2022
722: Evaluate boolean environment variables as truthy or falsey. r=Emilgardis a=Alexhuszagh

Allow values of 0, 1, so values other than `true` or `false` can be provided. `VAR=0`, `VAR=`, `VAR=-0`, or `VAR=false` will evaluate to false, while the rest will evaluate to true.

Affects #661 and #721.

Co-authored-by: Alex Huszagh <ahuszagh@gmail.com>
src/main.rs Outdated Show resolved Hide resolved
@Alexhuszagh Alexhuszagh force-pushed the issue225 branch 2 times, most recently from 0919c42 to a35066d Compare May 26, 2022 19:04
src/rustup.rs Outdated Show resolved Hide resolved
@Emilgardis
Copy link
Member

could you squash the changes? feel free to remove the co-authored by for me

@Emilgardis Emilgardis marked this pull request as ready for review May 26, 2022 19:52
@Emilgardis Emilgardis requested a review from a team as a code owner May 26, 2022 19:52
This partially addresses cross-rs#225.

This only works on nightly, due to the use of the unstable feature [doctest-xcompile](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#doctest-xcompile)

The relevant tracking issues are:
- rust-lang/cargo#7040
- rust-lang/rust#64245

If the subcommand is `test` and the compiler is nightly, we provide the `-Zdoctest-xcompile` flag if `CROSS_UNSTABLE_ENABLE_DOCTESTS=true`.
Copy link
Member

@Emilgardis Emilgardis left a comment

Choose a reason for hiding this comment

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

bors r+

@bors
Copy link
Contributor

bors bot commented May 26, 2022

Build succeeded:

@bors bors bot merged commit 459e03e into cross-rs:main May 26, 2022
@Emilgardis Emilgardis added this to the v0.2.2 milestone Jun 15, 2022
@Alexhuszagh Alexhuszagh deleted the issue225 branch July 2, 2022 09:26
@Alexhuszagh Alexhuszagh added enhancement no-ci-targets PRs that do not affect any cross-compilation targets. labels Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement no-ci-targets PRs that do not affect any cross-compilation targets.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants