History

Test that relative `EXEPATH` doesn't trigger the optimization

This tests that a nonempty value of `EXEPATH` that is a realtive path does not trigger the `EXEPATH` optimization of `system_prefix()` on Windows. This is similar to the previously introduced test for an empty value, in that both are treated as relative paths. Like that test, this one currently fails, but both will pass once the `EXEPATH` optimization is refined to refuse to look under a non-absolute path.

Eliah Kagan committed 1 year ago

Commit f4bb7731 parent 84f96721 file · +17 −0Browse files

Unified · Split

gix-path/src/env/tests.rs+17−0
@@ -121,4 +121,21 @@ mod system_prefix { · 120 unmodified lines
121121 assert_eq!(outcome, None);
122122 }
123123 }
124+
125+ #[test]
126+ #[serial]
127+ fn exepath_nonempty_relative() {
128+ for name in ["mingw32", "mingw64", "clangarm64"] {
129+ let grandparent = tempfile::tempdir().expect("can create new temporary directory");
130+ let parent = grandparent
131+ .path()
132+ .canonicalize()
133+ .expect("path to the new directory works")
134+ .join("dir");
135+ std::fs::create_dir_all(parent.join(name)).expect("can create directories");
136+ let _cwd = gix_testtools::set_current_dir(grandparent.path()).expect("can change to test dir");
137+ let outcome = system_prefix_from_exepath_var(|key| if_exepath(key, "dir"));
138+ assert_eq!(outcome, None);
139+ }
140+ }
124141 }