@@ -18,6 +18,94 @@ use gix_dir::walk::EmissionMode::*;
1818use gix_dir:: walk:: ForDeletionMode ;
1919use gix_ignore:: Kind :: * ;
2020
21+ #[ test]
22+ #[ cfg( unix) ]
23+ fn root_is_fifo ( ) {
24+ let root = fixture_in ( "fifo" , "top-level" ) ;
25+
26+ let err = try_collect ( & root, None , |keep, ctx| {
27+ walk (
28+ & root,
29+ ctx,
30+ gix_dir:: walk:: Options {
31+ emit_ignored : Some ( Matching ) ,
32+ ..options ( )
33+ } ,
34+ keep,
35+ )
36+ } )
37+ . unwrap_err ( ) ;
38+ assert ! (
39+ matches!( err, gix_dir:: walk:: Error :: WorktreeRootIsFile { .. } ) ,
40+ "roots simply need to be directories to work"
41+ ) ;
42+ }
43+
44+ #[ test]
45+ #[ cfg( unix) ]
46+ fn one_top_level_fifo ( ) {
47+ let root = fixture_in ( "fifo" , "single-top-level-fifo" ) ;
48+
49+ let ( ( out, _root) , entries) = collect ( & root, None , |keep, ctx| {
50+ walk (
51+ & root,
52+ ctx,
53+ gix_dir:: walk:: Options {
54+ emit_pruned : false ,
55+ ..options ( )
56+ } ,
57+ keep,
58+ )
59+ } ) ;
60+ assert_eq ! (
61+ out,
62+ walk:: Outcome {
63+ read_dir_calls: 1 ,
64+ returned_entries: entries. len( ) ,
65+ seen_entries: 2 ,
66+ }
67+ ) ;
68+
69+ assert_eq ! ( entries, & [ ] , "Non-files are simply pruned by default" ) ;
70+ }
71+
72+ #[ test]
73+ #[ cfg( unix) ]
74+ fn fifo_in_traversal ( ) {
75+ let root = fixture_in ( "fifo" , "two-fifos-two-files" ) ;
76+
77+ let ( ( out, _root) , entries) = collect ( & root, None , |keep, ctx| {
78+ walk (
79+ & root,
80+ ctx,
81+ gix_dir:: walk:: Options {
82+ emit_pruned : true ,
83+ ..options ( )
84+ } ,
85+ keep,
86+ )
87+ } ) ;
88+ assert_eq ! (
89+ out,
90+ walk:: Outcome {
91+ read_dir_calls: 3 ,
92+ returned_entries: entries. len( ) ,
93+ seen_entries: 5 ,
94+ }
95+ ) ;
96+
97+ assert_eq ! (
98+ entries,
99+ & [
100+ entry( "dir-with-file/nested-file" , Untracked , File ) ,
101+ entry_nokind( "dir/nested" , Pruned ) ,
102+ entry( "file" , Untracked , File ) ,
103+ entry_nokind( "top" , Untracked ) ,
104+ ] ,
105+ "Non-files are simply pruned, and don't have a disk kind"
106+ ) ;
107+ }
108+
21109#[ test]
22110fn symlink_to_dir_can_be_excluded ( ) -> crate :: Result {
23111 let root = fixture_in ( "many-symlinks" , "excluded-symlinks-to-dir" ) ;
0 commit comments