@@ -937,9 +937,25 @@ impl Default for FileSystemInner {
937
937
}
938
938
}
939
939
940
+ #[ allow( dead_code) ] // The `No` variant.
941
+ pub ( super ) enum DirectoryMustBeEmpty {
942
+ Yes ,
943
+ No ,
944
+ }
945
+
946
+ impl DirectoryMustBeEmpty {
947
+ pub ( super ) fn yes ( & self ) -> bool {
948
+ matches ! ( self , Self :: Yes )
949
+ }
950
+
951
+ pub ( super ) fn no ( & self ) -> bool {
952
+ !self . yes ( )
953
+ }
954
+ }
955
+
940
956
#[ cfg( test) ]
941
957
mod test_filesystem {
942
- use crate :: { mem_fs:: * , DirEntry , FileSystem as FS , FileType , FsError } ;
958
+ use crate :: { mem_fs:: * , DirEntry , FileSystem as FS , FileSystemExt , FileType , FsError } ;
943
959
944
960
macro_rules! path {
945
961
( $path: expr) => {
@@ -1686,20 +1702,26 @@ mod test_filesystem {
1686
1702
"canonicalizing a crazily stupid path name" ,
1687
1703
) ;
1688
1704
}
1689
- }
1690
-
1691
- #[ allow( dead_code) ] // The `No` variant.
1692
- pub ( super ) enum DirectoryMustBeEmpty {
1693
- Yes ,
1694
- No ,
1695
- }
1696
1705
1697
- impl DirectoryMustBeEmpty {
1698
- pub ( super ) fn yes ( & self ) -> bool {
1699
- matches ! ( self , Self :: Yes )
1700
- }
1706
+ #[ test]
1707
+ #[ ignore = "Not yet supported. See https://github.com/wasmerio/wasmer/issues/3678" ]
1708
+ fn mount_to_overlapping_directories ( ) {
1709
+ let top_level = FileSystem :: default ( ) ;
1710
+ top_level. touch ( "/file.txt" ) . unwrap ( ) ;
1711
+ let nested = FileSystem :: default ( ) ;
1712
+ nested. touch ( "/another-file.txt" ) . unwrap ( ) ;
1713
+ let top_level: Arc < dyn crate :: FileSystem + Send + Sync > = Arc :: new ( top_level) ;
1714
+ let nested: Arc < dyn crate :: FileSystem + Send + Sync > = Arc :: new ( nested) ;
1701
1715
1702
- pub ( super ) fn no ( & self ) -> bool {
1703
- !self . yes ( )
1716
+ let fs = FileSystem :: default ( ) ;
1717
+ fs. mount ( "/top-level" . into ( ) , & top_level, "/" . into ( ) )
1718
+ . unwrap ( ) ;
1719
+ fs. mount ( "/top-level/nested" . into ( ) , & nested, "/" . into ( ) )
1720
+ . unwrap ( ) ;
1721
+
1722
+ assert ! ( fs. is_dir( "/top-level" ) ) ;
1723
+ assert ! ( fs. is_file( "/top-level/file.txt" ) ) ;
1724
+ assert ! ( fs. is_dir( "/top-level/nested" ) ) ;
1725
+ assert ! ( fs. is_file( "/top-level/nested/another-file.txt" ) ) ;
1704
1726
}
1705
1727
}
0 commit comments