···6464 .collect()
6565 }
66666767- /// All paths (files and directories) currently in the filesystem,
6868- /// excluding the filesystem root ("/").
6969- pub fn subpaths(&self) -> Vec<Utf8PathBuf> {
6767+ /// All files currently in the filesystem (directories are not included).
6868+ pub fn files(&self) -> Vec<Utf8PathBuf> {
7069 self.files
7170 .borrow()
7272- .keys()
7373- .filter(|p| p.as_path() != Utf8Path::new("/"))
7171+ .iter()
7272+ .filter(|(_, f)| !f.is_directory())
7373+ .map(|(path, _)| path)
7474 .cloned()
7575 .collect()
7676 }
···468468}
469469470470#[test]
471471-fn test_subpaths_exclude_root() -> Result<(), Error> {
471471+fn test_files() -> Result<(), Error> {
472472 let imfs = InMemoryFileSystem::new();
473473 imfs.write(&Utf8PathBuf::from("/a/b/c.txt"), "a")?;
474474 imfs.write(&Utf8PathBuf::from("/d/e.txt"), "a")?;
475475476476- let mut subpaths = imfs.subpaths();
476476+ let mut files = imfs.files();
477477478478 // Sort for test determinism due to hash map usage.
479479- subpaths.sort_unstable();
479479+ files.sort_unstable();
480480481481 assert_eq!(
482482 vec![
483483- Utf8PathBuf::from("/a"),
484484- Utf8PathBuf::from("/a/b"),
485483 Utf8PathBuf::from("/a/b/c.txt"),
486486- Utf8PathBuf::from("/d"),
487484 Utf8PathBuf::from("/d/e.txt"),
488485 ],
489489- subpaths
486486+ files
490487 );
491488492489 Ok(())
+2-4
test-package-compiler/src/lib.rs
···4040 let warnings = VectorWarningEmitterIO::default();
4141 let warning_emitter = WarningEmitter::new(Rc::new(warnings.clone()));
4242 let filesystem = test_helpers_rs::to_in_memory_filesystem(&root);
4343- let initial_files = filesystem.subpaths();
4343+ let initial_files = filesystem.files();
4444 let root = Utf8PathBuf::from("");
4545 let out = Utf8PathBuf::from("/out/lib/the_package");
4646 let lib = Utf8PathBuf::from("/out/lib");
···6969 match result {
7070 Outcome::Ok(_) => {
7171 for path in initial_files {
7272- if filesystem.is_directory(&path) {
7373- filesystem.delete_directory(&path).unwrap();
7474- } else {
7272+ if filesystem.is_file(&path) {
7573 filesystem.delete_file(&path).unwrap();
7674 }
7775 }
+2-4
test-project-compiler/src/lib.rs
···1515pub fn prepare(path: &str, mode: Mode) -> String {
1616 let root = Utf8PathBuf::from(path).canonicalize_utf8().unwrap();
1717 let filesystem = test_helpers_rs::to_in_memory_filesystem(&root);
1818- let initial_files = filesystem.subpaths();
1818+ let initial_files = filesystem.files();
19192020 let toml = std::fs::read_to_string(root.join("gleam.toml")).unwrap();
2121 let config: PackageConfig = toml::from_str(&toml).unwrap();
···4545 compiler.compile().unwrap();
46464747 for path in initial_files {
4848- if filesystem.is_directory(&path) {
4949- filesystem.delete_directory(&path).unwrap();
5050- } else {
4848+ if filesystem.is_file(&path) {
5149 filesystem.delete_file(&path).unwrap();
5250 }
5351 }