Skip to content
Myr

Add test when running from non-existent directory

Before adoption: this commit came in with the history the project adopted, so no landing records it.

When fd is run from a non-existent directory, but a search path is passed in the arguments, it should still run. This tests for that.

authored by Sijmen · committed by David Peter · parent cb6295d · Browse files · 2 files+27 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+27 added−0 removed

  • tests:+27 added−0 removed

2 files+27 added−0 removed

modified:tests/testenv/mod.rs+5 added
183 unmodified lines
184 pub fn test_root(&self) -> PathBuf {185 self.temp_dir.path().to_path_buf()186 }187188 /// Get the path of the fd executable.189 pub fn test_exe(&self) -> &PathBuf {190 &self.fd_exe191 }192193 /// Get the root directory of the file system.194 pub fn system_root(&self) -> PathBuf {195 let mut components = self.temp_dir.path().components();196 PathBuf::from(components.next().expect("root directory").as_os_str())
124 unmodified lines
modified:tests/tests.rs+22 added
2112 unmodified lines
2113 one/two/three/directory_foo/2114 symlink",2115 );2116}21172118/// When fd is ran from a non-existent working directory, but an existent2119/// directory is passed in the arguments, it should still run fine2120#[test]2121fn test_invalid_cwd() {2122 let te = TestEnv::new(&[], &[]);21232124 let root = te.test_root().join("foo");2125 fs::create_dir(&root).unwrap();2126 std::env::set_current_dir(&root).unwrap();2127 fs::remove_dir(&root).unwrap();21282129 let output = std::process::Command::new(&te.test_exe())2130 .arg("query")2131 .arg(te.test_root())2132 .output()2133 .unwrap();21342135 if !output.status.success() {2136 panic!("{:?}", output);2137 }2138}