File tree Expand file tree Collapse file tree 1 file changed +29
-16
lines changed
Expand file tree Collapse file tree 1 file changed +29
-16
lines changed Original file line number Diff line number Diff line change @@ -4598,30 +4598,43 @@ fn test_ls_hyperlink_dirs() {
45984598fn test_ls_hyperlink_recursive_dirs ( ) {
45994599 let scene = TestScenario :: new ( util_name ! ( ) ) ;
46004600 let at = & scene. fixtures ;
4601- at. mkdir ( "example" ) ;
4602- at. mkdir ( "example/a" ) ;
4601+ let path = at. root_dir_resolved ( ) ;
4602+ let separator = std:: path:: MAIN_SEPARATOR_STR ;
4603+
4604+ let dir_a = "a" ;
4605+ let dir_b = "b" ;
4606+ at. mkdir ( dir_a) ;
4607+ at. mkdir ( format ! ( "{dir_a}/{dir_b}" ) ) ;
46034608
46044609 let result = scene
46054610 . ucmd ( )
46064611 . arg ( "--hyperlink" )
46074612 . arg ( "--recursive" )
4608- . arg ( "example" )
4613+ . arg ( dir_a )
46094614 . succeeds ( ) ;
46104615
4616+ macro_rules! assert_hyperlink {
4617+ ( $line: expr, $expected: expr) => {
4618+ assert!( matches!( $line, Some ( l) if l. starts_with( "\x1b ]8;;file://" ) && l. ends_with( $expected) ) ) ;
4619+ } ;
4620+ }
4621+
46114622 let mut lines = result. stdout_str ( ) . lines ( ) ;
4612- assert ! ( & lines
4613- . next( )
4614- . unwrap( )
4615- . ends_with( "/example\u{7} example\u{1b} ]8;;\u{7} :" ) ) ;
4616- assert ! ( & lines
4617- . next( )
4618- . unwrap( )
4619- . ends_with( "/example/a\u{7} a\u{1b} ]8;;\u{7} " ) ) ;
4620- assert ! ( & lines. next( ) . unwrap( ) . is_empty( ) ) ;
4621- assert ! ( & lines
4622- . next( )
4623- . unwrap( )
4624- . ends_with( "/example/a\u{7} example/a\u{1b} ]8;;\u{7} :" ) ) ;
4623+ assert_hyperlink ! (
4624+ lines. next( ) ,
4625+ & format!( "{path}{separator}{dir_a}\x07 {dir_a}\x1b ]8;;\x07 :" )
4626+ ) ;
4627+ assert_hyperlink ! (
4628+ lines. next( ) ,
4629+ & format!( "{path}{separator}{dir_a}{separator}{dir_b}\x07 {dir_b}\x1b ]8;;\x07 " )
4630+ ) ;
4631+ assert ! ( matches!( lines. next( ) , Some ( l) if l. is_empty( ) ) ) ;
4632+ assert_hyperlink ! (
4633+ lines. next( ) ,
4634+ & format!(
4635+ "{path}{separator}{dir_a}{separator}{dir_b}\x07 {dir_a}{separator}{dir_b}\x1b ]8;;\x07 :"
4636+ )
4637+ ) ;
46254638}
46264639
46274640#[ test]
You can’t perform that action at this time.
0 commit comments