Skip to content

Commit 8438e78

Browse files
committed
Introduce cli module to avoid dead code warning
1 parent b3dd973 commit 8438e78

20 files changed

+3
-79
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ use anyhow::Result;
1212
use insta_cmd::{assert_cmd_snapshot, get_cargo_bin};
1313
use tempfile::TempDir;
1414

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

1917
const BIN_NAME: &str = "ruff";
2018
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: 2 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ use std::{
1414
};
1515
use tempfile::TempDir;
1616

17+
mod lint;
18+
1719
const BIN_NAME: &str = "ruff";
1820

1921
/// Creates a regex filter for replacing temporary directory paths in snapshots
@@ -195,79 +197,3 @@ impl RuffTestFixture {
195197
command
196198
}
197199
}
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)