summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/file_watcher.rs4
-rw-r--r--cli/fs_util.rs6
-rw-r--r--cli/tests/integration/watcher_tests.rs20
3 files changed, 16 insertions, 14 deletions
diff --git a/cli/file_watcher.rs b/cli/file_watcher.rs
index 4a3471f22..c7fff4632 100644
--- a/cli/file_watcher.rs
+++ b/cli/file_watcher.rs
@@ -1,6 +1,8 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
use crate::colors;
+use crate::fs_util::canonicalize_path;
+
use deno_core::error::AnyError;
use deno_core::futures::stream::{Stream, StreamExt};
use deno_core::futures::Future;
@@ -231,7 +233,7 @@ fn new_watcher(
let paths = event
.paths
.iter()
- .filter_map(|path| path.canonicalize().ok());
+ .filter_map(|path| canonicalize_path(path).ok());
let mut changed_paths = changed_paths.lock();
changed_paths.extend(paths);
}
diff --git a/cli/fs_util.rs b/cli/fs_util.rs
index 88855b0e8..21a9a6aad 100644
--- a/cli/fs_util.rs
+++ b/cli/fs_util.rs
@@ -233,14 +233,14 @@ where
// retain only the paths which exist and ignore the rest
let canonicalized_ignore: Vec<PathBuf> = ignore
.iter()
- .filter_map(|i| i.canonicalize().ok())
+ .filter_map(|i| canonicalize_path(i).ok())
.collect();
for file in files {
for entry in WalkDir::new(file)
.into_iter()
.filter_entry(|e| {
- e.path().canonicalize().map_or(false, |c| {
+ canonicalize_path(e.path()).map_or(false, |c| {
!canonicalized_ignore.iter().any(|i| c.starts_with(i))
})
})
@@ -249,7 +249,7 @@ where
_ => None,
})
{
- target_files.push(entry.into_path().canonicalize()?)
+ target_files.push(canonicalize_path(entry.path())?)
}
}
diff --git a/cli/tests/integration/watcher_tests.rs b/cli/tests/integration/watcher_tests.rs
index a71d6bd51..42ca4b520 100644
--- a/cli/tests/integration/watcher_tests.rs
+++ b/cli/tests/integration/watcher_tests.rs
@@ -116,7 +116,7 @@ fn lint_watch_test() {
let mut output = read_all_lints(&mut stderr_lines);
let expected = std::fs::read_to_string(badly_linted_output).unwrap();
- assert_eq!(expected, output);
+ assert_eq!(output, expected);
// Change content of the file again to be badly-linted1
std::fs::copy(&badly_linted_fixed1, &badly_linted)
@@ -125,7 +125,7 @@ fn lint_watch_test() {
output = read_all_lints(&mut stderr_lines);
let expected = std::fs::read_to_string(badly_linted_fixed1_output).unwrap();
- assert_eq!(expected, output);
+ assert_eq!(output, expected);
// Change content of the file again to be badly-linted1
std::fs::copy(&badly_linted_fixed2, &badly_linted)
@@ -134,7 +134,7 @@ fn lint_watch_test() {
output = read_all_lints(&mut stderr_lines);
let expected = std::fs::read_to_string(badly_linted_fixed2_output).unwrap();
- assert_eq!(expected, output);
+ assert_eq!(output, expected);
// the watcher process is still alive
assert!(child.try_wait().unwrap().is_none());
@@ -182,7 +182,7 @@ fn lint_watch_without_args_test() {
let mut output = read_all_lints(&mut stderr_lines);
let expected = std::fs::read_to_string(badly_linted_output).unwrap();
- assert_eq!(expected, output);
+ assert_eq!(output, expected);
// Change content of the file again to be badly-linted1
std::fs::copy(&badly_linted_fixed1, &badly_linted)
@@ -191,7 +191,7 @@ fn lint_watch_without_args_test() {
output = read_all_lints(&mut stderr_lines);
let expected = std::fs::read_to_string(badly_linted_fixed1_output).unwrap();
- assert_eq!(expected, output);
+ assert_eq!(output, expected);
// Change content of the file again to be badly-linted1
std::fs::copy(&badly_linted_fixed2, &badly_linted)
@@ -200,7 +200,7 @@ fn lint_watch_without_args_test() {
output = read_all_lints(&mut stderr_lines);
let expected = std::fs::read_to_string(badly_linted_fixed2_output).unwrap();
- assert_eq!(expected, output);
+ assert_eq!(output, expected);
// the watcher process is still alive
assert!(child.try_wait().unwrap().is_none());
@@ -285,7 +285,7 @@ fn fmt_watch_test() {
let expected = std::fs::read_to_string(fixed.clone()).unwrap();
let actual = std::fs::read_to_string(badly_formatted.clone()).unwrap();
- assert_eq!(expected, actual);
+ assert_eq!(actual, expected);
// Change content of the file again to be badly formatted
std::fs::copy(&badly_formatted_original, &badly_formatted).unwrap();
@@ -294,7 +294,7 @@ fn fmt_watch_test() {
// Check if file has been automatically formatted by watcher
let expected = std::fs::read_to_string(fixed).unwrap();
let actual = std::fs::read_to_string(badly_formatted).unwrap();
- assert_eq!(expected, actual);
+ assert_eq!(actual, expected);
check_alive_then_kill(child);
}
@@ -325,7 +325,7 @@ fn fmt_watch_without_args_test() {
let expected = std::fs::read_to_string(fixed.clone()).unwrap();
let actual = std::fs::read_to_string(badly_formatted.clone()).unwrap();
- assert_eq!(expected, actual);
+ assert_eq!(actual, expected);
// Change content of the file again to be badly formatted
std::fs::copy(&badly_formatted_original, &badly_formatted).unwrap();
@@ -334,7 +334,7 @@ fn fmt_watch_without_args_test() {
// Check if file has been automatically formatted by watcher
let expected = std::fs::read_to_string(fixed).unwrap();
let actual = std::fs::read_to_string(badly_formatted).unwrap();
- assert_eq!(expected, actual);
+ assert_eq!(actual, expected);
check_alive_then_kill(child);
}