Skip to content

Commit 70bf845

Browse files
authored
Merge pull request rust-lang#21681 from Wilfred/skip_test_on_nightly
internal: Skip rustfmt test if nightly toolchain is missing
2 parents d8ffd91 + 81bcf97 commit 70bf845

File tree

1 file changed

+12
-0
lines changed
  • src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests

1 file changed

+12
-0
lines changed

src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/main.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ mod testdir;
2222

2323
use std::{collections::HashMap, path::PathBuf, time::Instant};
2424

25+
use ide_db::FxHashMap;
2526
use lsp_types::{
2627
CodeActionContext, CodeActionParams, CompletionParams, DidOpenTextDocumentParams,
2728
DocumentFormattingParams, DocumentRangeFormattingParams, FileRename, FormattingOptions,
@@ -673,6 +674,17 @@ fn test_format_document_range() {
673674
return;
674675
}
675676

677+
// This test requires a nightly toolchain, so skip if it's not available.
678+
let cwd = std::env::current_dir().unwrap_or_default();
679+
let has_nightly_rustfmt = toolchain::command("rustfmt", cwd, &FxHashMap::default())
680+
.args(["+nightly", "--version"])
681+
.output()
682+
.is_ok_and(|out| out.status.success());
683+
if !has_nightly_rustfmt {
684+
tracing::warn!("skipping test_format_document_range: nightly rustfmt not available");
685+
return;
686+
}
687+
676688
let server = Project::with_fixture(
677689
r#"
678690
//- /Cargo.toml

0 commit comments

Comments
 (0)