Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

add dir walking test

+37
+37
compiler-core/src/io/memory.rs
··· 436 436 Ok(()) // Always succeed. 437 437 } 438 438 } 439 + 440 + #[test] 441 + fn test_in_memory_dir_walking() -> Result<(), Error> { 442 + use itertools::Itertools; 443 + let imfs = InMemoryFileSystem::new(); 444 + imfs.write(&Utf8PathBuf::from("/a/b/a.txt"), "a")?; 445 + imfs.write(&Utf8PathBuf::from("/a/b/b.txt"), "a")?; 446 + imfs.write(&Utf8PathBuf::from("/a/b/c.txt"), "a")?; 447 + imfs.write(&Utf8PathBuf::from("/b/d.txt"), "a")?; 448 + imfs.write(&Utf8PathBuf::from("/a/c/e.txt"), "a")?; 449 + imfs.write(&Utf8PathBuf::from("/a/c/d/f.txt"), "a")?; 450 + imfs.write(&Utf8PathBuf::from("/a/g.txt"), "a")?; 451 + imfs.write(&Utf8PathBuf::from("/h.txt"), "a")?; 452 + imfs.mkdir(&Utf8PathBuf::from("/a/e"))?; 453 + 454 + let mut walked_entries: Vec<String> = DirWalker::new(Utf8PathBuf::from("/a/")) 455 + .into_file_iter(&imfs) 456 + .map_ok(Utf8PathBuf::into_string) 457 + .try_collect()?; 458 + 459 + // Keep test deterministic due to hash map usage 460 + walked_entries.sort(); 461 + 462 + assert_eq!( 463 + vec![ 464 + "/a/b/a.txt".to_owned(), 465 + "/a/b/b.txt".to_owned(), 466 + "/a/b/c.txt".to_owned(), 467 + "/a/c/d/f.txt".to_owned(), 468 + "/a/c/e.txt".to_owned(), 469 + "/a/g.txt".to_owned(), 470 + ], 471 + walked_entries, 472 + ); 473 + 474 + Ok(()) 475 + }