Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #21681 from Wilfred/skip_test_on_nightly
internal: Skip rustfmt test if nightly toolchain is missing
| -rw-r--r-- | crates/rust-analyzer/tests/slow-tests/main.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/crates/rust-analyzer/tests/slow-tests/main.rs b/crates/rust-analyzer/tests/slow-tests/main.rs index 26ba549a29..fcdc8bb7cd 100644 --- a/crates/rust-analyzer/tests/slow-tests/main.rs +++ b/crates/rust-analyzer/tests/slow-tests/main.rs @@ -22,6 +22,7 @@ mod testdir; use std::{collections::HashMap, path::PathBuf, time::Instant}; +use ide_db::FxHashMap; use lsp_types::{ CodeActionContext, CodeActionParams, CompletionParams, DidOpenTextDocumentParams, DocumentFormattingParams, DocumentRangeFormattingParams, FileRename, FormattingOptions, @@ -673,6 +674,17 @@ fn test_format_document_range() { return; } + // This test requires a nightly toolchain, so skip if it's not available. + let cwd = std::env::current_dir().unwrap_or_default(); + let has_nightly_rustfmt = toolchain::command("rustfmt", cwd, &FxHashMap::default()) + .args(["+nightly", "--version"]) + .output() + .is_ok_and(|out| out.status.success()); + if !has_nightly_rustfmt { + tracing::warn!("skipping test_format_document_range: nightly rustfmt not available"); + return; + } + let server = Project::with_fixture( r#" //- /Cargo.toml |