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+
68use anyhow:: { Context as _, Result } ;
79use insta:: internals:: SettingsBindDropGuard ;
810use insta_cmd:: get_cargo_bin;
@@ -14,6 +16,8 @@ use std::{
1416} ;
1517use tempfile:: TempDir ;
1618
19+ mod lint;
20+
1721const 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