Skip to content

Commit 336133b

Browse files
committed
Introduce cli module to avoid dead code warning
1 parent b3dd973 commit 336133b

35 files changed

+5
-81
lines changed

crates/ruff/tests/lint.rs renamed to crates/ruff/tests/cli/lint.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! Tests the interaction of the `lint` configuration section
22
3-
#![cfg(not(target_family = "wasm"))]
4-
53
use regex::escape;
64
use std::process::Command;
75
use std::str;
@@ -12,9 +10,7 @@ use anyhow::Result;
1210
use insta_cmd::{assert_cmd_snapshot, get_cargo_bin};
1311
use tempfile::TempDir;
1412

15-
mod test_fixture;
16-
17-
use test_fixture::RuffTestFixture;
13+
use crate::RuffTestFixture;
1814

1915
const BIN_NAME: &str = "ruff";
2016
const STDIN_BASE_OPTIONS: &[&str] = &["check", "--no-cache", "--output-format", "concise"];

crates/ruff/tests/test_fixture.rs renamed to crates/ruff/tests/cli/main.rs

Lines changed: 4 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
//! The core concept is borrowed from ty/tests/cli/main.rs and can be extended
44
//! with more functionality from there in the future if needed.
55
6+
#![cfg(not(target_family = "wasm"))]
7+
68
use anyhow::{Context as _, Result};
79
use insta::internals::SettingsBindDropGuard;
810
use insta_cmd::get_cargo_bin;
@@ -14,6 +16,8 @@ use std::{
1416
};
1517
use tempfile::TempDir;
1618

19+
mod lint;
20+
1721
const BIN_NAME: &str = "ruff";
1822

1923
/// Creates a regex filter for replacing temporary directory paths in snapshots
@@ -195,79 +199,3 @@ impl RuffTestFixture {
195199
command
196200
}
197201
}
198-
199-
#[cfg(test)]
200-
mod tests {
201-
use super::*;
202-
use std::fs;
203-
204-
#[test]
205-
fn test_tempdir_filter() {
206-
let path = "/tmp/test/path";
207-
let filter = tempdir_filter(path);
208-
assert!(filter.contains("test"));
209-
assert!(filter.contains("path"));
210-
}
211-
212-
#[test]
213-
fn test_fixture_new() -> Result<()> {
214-
let fixture = RuffTestFixture::new()?;
215-
assert!(fixture.root().exists());
216-
Ok(())
217-
}
218-
219-
#[test]
220-
fn test_fixture_with_file() -> Result<()> {
221-
let fixture = RuffTestFixture::with_file("test.py", "print('hello')")?;
222-
let file_path = fixture.root().join("test.py");
223-
assert!(file_path.exists());
224-
let content = fs::read_to_string(file_path)?;
225-
assert_eq!(content, "print('hello')");
226-
Ok(())
227-
}
228-
229-
#[test]
230-
fn test_write_file() -> Result<()> {
231-
let fixture = RuffTestFixture::new()?;
232-
fixture.write_file("nested/dir/file.py", "test content")?;
233-
let file_path = fixture.root().join("nested/dir/file.py");
234-
assert!(file_path.exists());
235-
let content = fs::read_to_string(file_path)?;
236-
assert_eq!(content, "test content");
237-
Ok(())
238-
}
239-
240-
#[test]
241-
fn test_tempdir_filter_method() -> Result<()> {
242-
let fixture = RuffTestFixture::new()?;
243-
let filter = fixture.tempdir_filter();
244-
assert!(!filter.is_empty());
245-
Ok(())
246-
}
247-
248-
#[test]
249-
fn test_command_creation() -> Result<()> {
250-
let fixture = RuffTestFixture::new()?;
251-
let command = fixture.command();
252-
assert_eq!(command.get_current_dir(), Some(fixture.root()));
253-
Ok(())
254-
}
255-
256-
#[test]
257-
fn test_dedent_functionality() -> Result<()> {
258-
let fixture = RuffTestFixture::new()?;
259-
let indented_content = "
260-
def hello():
261-
print('hello')
262-
return True
263-
";
264-
fixture.write_file("test_dedent.py", indented_content)?;
265-
let file_path = fixture.root().join("test_dedent.py");
266-
let content = fs::read_to_string(file_path)?;
267-
// Verify that the indentation was removed
268-
assert!(content.trim().starts_with("def hello():"));
269-
assert!(content.contains(" print('hello')")); // Still has relative indentation
270-
assert!(content.contains(" return True"));
271-
Ok(())
272-
}
273-
}

0 commit comments

Comments
 (0)