]> git.lizzy.rs Git - rust.git/commitdiff
More host/target path conversion tests:
authorRalf Jung <post@ralfj.de>
Sun, 11 Dec 2022 18:22:55 +0000 (19:22 +0100)
committerRalf Jung <post@ralfj.de>
Mon, 12 Dec 2022 10:00:47 +0000 (11:00 +0100)
- test that the tmpdir Miri tests see is absolute and a directory
- test that current_dir returns an absolute path

src/tools/miri/tests/pass/shims/env/current_dir.rs
src/tools/miri/tests/pass/shims/fs.rs

index 069b462ab371aa148ef3fe76aaa129bc6d2df69f..ca90912eabc54c038ef506f011ce3edc2e03dd7b 100644 (file)
@@ -3,8 +3,9 @@
 use std::io::ErrorKind;
 
 fn main() {
-    // Test that `getcwd` is available
+    // Test that `getcwd` is available and an absolute path
     let cwd = env::current_dir().unwrap();
+    assert!(cwd.is_absolute(), "cwd {:?} is not absolute", cwd);
     // Test that changing dir to `..` actually sets the current directory to the parent of `cwd`.
     // The only exception here is if `cwd` is the root directory, then changing directory must
     // keep the current directory equal to `cwd`.
index 901a2ab1028c2a96bd31f19bde10cd7756fa7e3b..e3ebbc8c8d29f356ddb6d9cb0a7fdd8ef1d16f08 100644 (file)
@@ -28,6 +28,7 @@ fn main() {
     test_directory();
     test_canonicalize();
     test_from_raw_os_error();
+    test_path_conversion();
 }
 
 fn tmp() -> PathBuf {
@@ -74,6 +75,12 @@ fn prepare_with_content(filename: &str, content: &[u8]) -> PathBuf {
     path
 }
 
+fn test_path_conversion() {
+    let tmp = tmp();
+    assert!(tmp.is_absolute(), "{:?} is not absolute", tmp);
+    assert!(tmp.is_dir(), "{:?} is not a directory", tmp);
+}
+
 fn test_file() {
     let bytes = b"Hello, World!\n";
     let path = prepare("miri_test_fs_file.txt");