Skip to content

Add requirements to cargo_test. #9892

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

Merged
merged 6 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions crates/cargo-test-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ pub fn cargo_test(attr: TokenStream, item: TokenStream) -> TokenStream {
requires_reason = true;
ignore |= is_not_nightly();
}
"disable_git_cli" => {
ignore |= disable_git_cli();
}
s if s.starts_with("requires_") => {
let command = &s[9..];
ignore |= !has_command(command);
Expand Down Expand Up @@ -155,13 +152,6 @@ fn version() -> &'static (u32, bool) {
unsafe { &VERSION }
}

fn disable_git_cli() -> bool {
// mingw git on Windows does not support Windows-style file URIs.
// Appveyor in the rust repo has that git up front in the PATH instead
// of Git-for-Windows, which causes this to fail.
matches!(option_env!("CARGO_TEST_DISABLE_GIT_CLI"), Some("1"))
}

fn has_command(command: &str) -> bool {
let output = match Command::new(command).arg("--version").output() {
Ok(output) => output,
Expand Down
2 changes: 0 additions & 2 deletions src/doc/contrib/src/tests/writing.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ The options it supports are:
* `>=1.64` — This indicates that the test will only run with the given version of `rustc` or newer.
This can be used when a new `rustc` feature has been stabilized that the test depends on.
If this is specified, a `reason` is required to explain why it is being checked.
* `disable_git_cli` — This is needed for `git-fetch-with-cli` tests.
This disables the test in rust-lang/rust's CI due to a compatibility issue.

#### Testing Nightly Features

Expand Down
8 changes: 4 additions & 4 deletions tests/testsuite/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2642,7 +2642,7 @@ fn failed_submodule_checkout() {
t.join().unwrap();
}

#[cargo_test(disable_git_cli)]
#[cargo_test]
fn use_the_cli() {
let project = project();
let git_project = git::new("dep1", |project| {
Expand Down Expand Up @@ -2743,7 +2743,7 @@ fn templatedir_doesnt_cause_problems() {
p.cargo("build").run();
}

#[cargo_test(disable_git_cli)]
#[cargo_test]
fn git_with_cli_force() {
// Supports a force-pushed repo.
let git_project = git::new("dep1", |project| {
Expand Down Expand Up @@ -2800,7 +2800,7 @@ fn git_with_cli_force() {
p.rename_run("foo", "foo2").with_stdout("two").run();
}

#[cargo_test(disable_git_cli)]
#[cargo_test]
fn git_fetch_cli_env_clean() {
// This tests that git-fetch-with-cli works when GIT_DIR environment
// variable is set (for whatever reason).
Expand Down Expand Up @@ -3500,7 +3500,7 @@ fn corrupted_checkout() {
_corrupted_checkout(false);
}

#[cargo_test(disable_git_cli)]
#[cargo_test]
fn corrupted_checkout_with_cli() {
// Test what happens if the checkout is corrupted somehow with git cli.
_corrupted_checkout(true);
Expand Down