Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f76ebd6

Browse files
committed
Auto merge of rust-lang#2309 - RalfJung:read_link, r=RalfJung
test fs::read_link surface function The shim got implemented a while ago but we never ensured that that is actually what std uses.
2 parents c9d5c3f + b4520e4 commit f76ebd6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tests/pass/fs.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ extern crate libc;
88

99
use std::ffi::CString;
1010
use std::fs::{
11-
create_dir, read_dir, remove_dir, remove_dir_all, remove_file, rename, File, OpenOptions,
11+
create_dir, read_dir, read_link, remove_dir, remove_dir_all, remove_file, rename, File,
12+
OpenOptions,
1213
};
1314
use std::io::{Error, ErrorKind, Read, Result, Seek, SeekFrom, Write};
1415
use std::path::{Path, PathBuf};
@@ -317,10 +318,12 @@ fn test_symlink() {
317318
assert_eq!(Error::last_os_error().kind(), ErrorKind::NotFound);
318319
}
319320

320-
// Test that metadata of a symbolic link is correct.
321+
// Test that metadata of a symbolic link (i.e., the file it points to) is correct.
321322
check_metadata(bytes, &symlink_path).unwrap();
322323
// Test that the metadata of a symbolic link is correct when not following it.
323324
assert!(symlink_path.symlink_metadata().unwrap().file_type().is_symlink());
325+
// Check that we can follow the link.
326+
assert_eq!(read_link(&symlink_path).unwrap(), path);
324327
// Removing symbolic link should succeed.
325328
remove_file(&symlink_path).unwrap();
326329

0 commit comments

Comments
 (0)