summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2016-10-10 19:34:57 -0400
committerAndrew Gallant <jamslam@gmail.com>2016-10-10 19:34:57 -0400
commit27a980c1bc0fb424d41803714c3a9041b4a5d830 (patch)
treee67558f7ff7f21fb5ebb6398e14197de5855bf7e
parente8645dc8aee910c9ce4b181afeb4ab9ad016670b (diff)
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.
-rw-r--r--tests/tests.rs12
-rw-r--r--tests/workdir.rs32
2 files changed, 38 insertions, 6 deletions
diff --git a/tests/tests.rs b/tests/tests.rs
index 965d37a3..f78feb72 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -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");
diff --git a/tests/workdir.rs b/tests/workdir.rs
index 89b2da1d..6a79daf7 100644
--- a/tests/workdir.rs
+++ b/tests/workdir.rs
@@ -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