mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2024-12-12 19:18:24 +02:00
Fix symlink test.
We attempt to run it on Windows, but I'm getting "access denied" errors when trying to create a file symlink. So we disable the test on Windows.
This commit is contained in:
parent
e8645dc8ae
commit
27a980c1bc
@ -542,7 +542,7 @@ sherlock!(symlink_nofollow, "Sherlock", ".", |wd: WorkDir, mut cmd: Command| {
|
||||
wd.remove("sherlock");
|
||||
wd.create_dir("foo");
|
||||
wd.create_dir("foo/bar");
|
||||
wd.link("foo/baz", "foo/bar/baz");
|
||||
wd.link_dir("foo/baz", "foo/bar/baz");
|
||||
wd.create_dir("foo/baz");
|
||||
wd.create("foo/baz/sherlock", hay::SHERLOCK);
|
||||
cmd.current_dir(wd.path().join("foo/bar"));
|
||||
@ -555,7 +555,7 @@ sherlock!(symlink_follow, "Sherlock", ".", |wd: WorkDir, mut cmd: Command| {
|
||||
wd.create_dir("foo/bar");
|
||||
wd.create_dir("foo/baz");
|
||||
wd.create("foo/baz/sherlock", hay::SHERLOCK);
|
||||
wd.link("foo/baz", "foo/bar/baz");
|
||||
wd.link_dir("foo/baz", "foo/bar/baz");
|
||||
cmd.arg("-L");
|
||||
cmd.current_dir(wd.path().join("foo/bar"));
|
||||
|
||||
@ -783,9 +783,13 @@ clean!(regression_131, "test", ".", |wd: WorkDir, mut cmd: Command| {
|
||||
});
|
||||
|
||||
// See: https://github.com/BurntSushi/ripgrep/issues/137
|
||||
//
|
||||
// TODO(burntsushi): Figure out why Windows gives "access denied" errors
|
||||
// when trying to create a file symlink. For now, disable test on Windows.
|
||||
#[cfg(not(windows))]
|
||||
sherlock!(regression_137, "Sherlock", ".", |wd: WorkDir, mut cmd: Command| {
|
||||
wd.link("sherlock", "sym1");
|
||||
wd.link("sherlock", "sym2");
|
||||
wd.link_file("sherlock", "sym1");
|
||||
wd.link_file("sherlock", "sym2");
|
||||
cmd.arg("sym1");
|
||||
cmd.arg("sym2");
|
||||
cmd.arg("-j1");
|
||||
|
@ -83,7 +83,7 @@ impl WorkDir {
|
||||
/// Creates a directory symlink to the src with the given target name
|
||||
/// in this directory.
|
||||
#[cfg(not(windows))]
|
||||
pub fn link<S: AsRef<Path>, T: AsRef<Path>>(&self, src: S, target: T) {
|
||||
pub fn link_dir<S: AsRef<Path>, T: AsRef<Path>>(&self, src: S, target: T) {
|
||||
use std::os::unix::fs::symlink;
|
||||
let src = self.dir.join(src);
|
||||
let target = self.dir.join(target);
|
||||
@ -91,8 +91,10 @@ impl WorkDir {
|
||||
nice_err(&target, symlink(&src, &target));
|
||||
}
|
||||
|
||||
/// Creates a directory symlink to the src with the given target name
|
||||
/// in this directory.
|
||||
#[cfg(windows)]
|
||||
pub fn link<S: AsRef<Path>, T: AsRef<Path>>(&self, src: S, target: T) {
|
||||
pub fn link_dir<S: AsRef<Path>, T: AsRef<Path>>(&self, src: S, target: T) {
|
||||
use std::os::windows::fs::symlink_dir;
|
||||
let src = self.dir.join(src);
|
||||
let target = self.dir.join(target);
|
||||
@ -100,6 +102,32 @@ impl WorkDir {
|
||||
nice_err(&target, symlink_dir(&src, &target));
|
||||
}
|
||||
|
||||
/// Creates a file symlink to the src with the given target name
|
||||
/// in this directory.
|
||||
#[cfg(not(windows))]
|
||||
pub fn link_file<S: AsRef<Path>, T: AsRef<Path>>(
|
||||
&self,
|
||||
src: S,
|
||||
target: T,
|
||||
) {
|
||||
self.link_dir(src, target);
|
||||
}
|
||||
|
||||
/// Creates a file symlink to the src with the given target name
|
||||
/// in this directory.
|
||||
#[cfg(windows)]
|
||||
pub fn link_file<S: AsRef<Path>, T: AsRef<Path>>(
|
||||
&self,
|
||||
src: S,
|
||||
target: T,
|
||||
) {
|
||||
use std::os::windows::fs::symlink_file;
|
||||
let src = self.dir.join(src);
|
||||
let target = self.dir.join(target);
|
||||
let _ = fs::remove_file(&target);
|
||||
nice_err(&target, symlink_file(&src, &target));
|
||||
}
|
||||
|
||||
/// Runs and captures the stdout of the given command.
|
||||
///
|
||||
/// If the return type could not be created from a string, then this
|
||||
|
Loading…
Reference in New Issue
Block a user