Skip to content

Commit

Permalink
More host/target path conversion tests:
Browse files Browse the repository at this point in the history
- test that the tmpdir Miri tests see is absolute and a directory
- test that current_dir returns an absolute path
  • Loading branch information
RalfJung committed Dec 12, 2022
1 parent d267f7f commit 4bf26df
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/pass/shims/env/current_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use std::env;
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`.
Expand Down
7 changes: 7 additions & 0 deletions tests/pass/shims/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ fn main() {
test_directory();
test_canonicalize();
test_from_raw_os_error();
test_path_conversion();
}

fn tmp() -> PathBuf {
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 4bf26df

Please sign in to comment.