mirror of
https://github.com/uutils/findutils.git
synced 2026-06-10 15:48:30 -07:00
Revert "Fixed windows compatability. This required"
This reverts commit 0e2c385237.
This commit is contained in:
@@ -375,7 +375,6 @@ fn build_matcher_tree(args: &[&str],
|
||||
mod tests {
|
||||
use walkdir::{DirEntry, WalkDir};
|
||||
use find::Config;
|
||||
use find::tests::fix_up_slashes;
|
||||
use find::tests::FakeDependencies;
|
||||
use super::*;
|
||||
|
||||
@@ -385,7 +384,7 @@ mod tests {
|
||||
/// probably be a string starting with "test_data/" (cargo's tests run with
|
||||
/// a working directory set to the root findutils folder).
|
||||
pub fn get_dir_entry_for(directory: &str, filename: &str) -> DirEntry {
|
||||
for wrapped_dir_entry in WalkDir::new(fix_up_slashes(directory)) {
|
||||
for wrapped_dir_entry in WalkDir::new(directory) {
|
||||
let dir_entry = wrapped_dir_entry.unwrap();
|
||||
if dir_entry.file_name().to_string_lossy() == filename {
|
||||
return dir_entry;
|
||||
@@ -405,8 +404,7 @@ mod tests {
|
||||
|
||||
assert!(matcher.matches(&abbbc_lower, &mut deps.new_matcher_io()));
|
||||
assert!(!matcher.matches(&abbbc_upper, &mut deps.new_matcher_io()));
|
||||
assert_eq!(deps.get_output_as_string(),
|
||||
fix_up_slashes("./test_data/simple/abbbc\n"));
|
||||
assert_eq!(deps.get_output_as_string(), "./test_data/simple/abbbc\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -421,7 +419,7 @@ mod tests {
|
||||
assert!(matcher.matches(&abbbc_lower, &mut deps.new_matcher_io()));
|
||||
assert!(matcher.matches(&abbbc_upper, &mut deps.new_matcher_io()));
|
||||
assert_eq!(deps.get_output_as_string(),
|
||||
fix_up_slashes("./test_data/simple/abbbc\n./test_data/simple/subdir/ABBBC\n"));
|
||||
"./test_data/simple/abbbc\n./test_data/simple/subdir/ABBBC\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -435,8 +433,7 @@ mod tests {
|
||||
.unwrap();
|
||||
|
||||
assert!(matcher.matches(&abbbc_lower, &mut deps.new_matcher_io()));
|
||||
assert_eq!(deps.get_output_as_string(),
|
||||
fix_up_slashes("./test_data/simple/abbbc\n"));
|
||||
assert_eq!(deps.get_output_as_string(), "./test_data/simple/abbbc\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -524,8 +521,7 @@ mod tests {
|
||||
// build a matcher using an explicit -a argument
|
||||
let matcher = build_top_level_matcher(&["-true", "-a", "-true"], &mut config).unwrap();
|
||||
assert!(matcher.matches(&abbbc, &mut deps.new_matcher_io()));
|
||||
assert_eq!(deps.get_output_as_string(),
|
||||
fix_up_slashes("./test_data/simple/abbbc\n"));
|
||||
assert_eq!(deps.get_output_as_string(), "./test_data/simple/abbbc\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -540,8 +536,7 @@ mod tests {
|
||||
let matcher = build_top_level_matcher(args, &mut config).unwrap();
|
||||
|
||||
assert!(matcher.matches(&abbbc, &mut deps.new_matcher_io()));
|
||||
assert_eq!(deps.get_output_as_string(),
|
||||
fix_up_slashes("./test_data/simple/abbbc\n"));
|
||||
assert_eq!(deps.get_output_as_string(), "./test_data/simple/abbbc\n");
|
||||
}
|
||||
|
||||
let mut config = Config::default();
|
||||
@@ -572,8 +567,7 @@ mod tests {
|
||||
let matcher = build_top_level_matcher(&["-true", "-true"], &mut config).unwrap();
|
||||
|
||||
assert!(matcher.matches(&abbbc, &mut deps.new_matcher_io()));
|
||||
assert_eq!(deps.get_output_as_string(),
|
||||
fix_up_slashes("./test_data/simple/abbbc\n"));
|
||||
assert_eq!(deps.get_output_as_string(), "./test_data/simple/abbbc\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -589,7 +583,7 @@ mod tests {
|
||||
assert!(!matcher.matches(&abbbc, &mut deps.new_matcher_io()));
|
||||
// two print matchers means doubled output
|
||||
assert_eq!(deps.get_output_as_string(),
|
||||
fix_up_slashes("./test_data/simple/abbbc\n./test_data/simple/abbbc\n"));
|
||||
"./test_data/simple/abbbc\n./test_data/simple/abbbc\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
use std::error::Error;
|
||||
use std::io::{stderr, Write};
|
||||
#[cfg(unix)]
|
||||
use std::str::FromStr;
|
||||
use walkdir::DirEntry;
|
||||
|
||||
@@ -18,7 +17,6 @@ use find::matchers::{Matcher, MatcherIO};
|
||||
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
#[cfg(unix)]
|
||||
pub enum ComparisonType {
|
||||
/// mode bits have to match exactly
|
||||
Exact,
|
||||
@@ -29,7 +27,6 @@ pub enum ComparisonType {
|
||||
AnyOf,
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl FromStr for ComparisonType {
|
||||
type Err = Box<Error>;
|
||||
fn from_str(s: &str) -> Result<ComparisonType, Box<Error>> {
|
||||
@@ -46,7 +43,6 @@ impl FromStr for ComparisonType {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl ComparisonType {
|
||||
fn mode_bits_match(&self, pattern: u32, value: u32) -> bool {
|
||||
match *self {
|
||||
@@ -57,7 +53,6 @@ impl ComparisonType {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
mod parsing {
|
||||
use regex::Regex;
|
||||
use std::error::Error;
|
||||
@@ -260,15 +255,11 @@ mod parsing {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
pub struct PermMatcher {
|
||||
pattern: u32,
|
||||
comparison_type: ComparisonType,
|
||||
}
|
||||
|
||||
#[cfg(not(unix))]
|
||||
pub struct PermMatcher {}
|
||||
|
||||
impl PermMatcher {
|
||||
#[cfg(unix)]
|
||||
pub fn new(pattern: &str) -> Result<PermMatcher, Box<Error>> {
|
||||
@@ -280,8 +271,8 @@ impl PermMatcher {
|
||||
}
|
||||
|
||||
#[cfg(not(unix))]
|
||||
pub fn new(_dummy_pattern: &str) -> Result<PermMatcher, Box<Error>> {
|
||||
Err(From::from("Permission matching is not available on this platform"))
|
||||
pub fn new(pattern: &str) -> Result<PermMatcher, Box<Error>> {
|
||||
Err(From("Permission matching is not available on this platform"))
|
||||
}
|
||||
|
||||
pub fn new_box(pattern: &str) -> Result<Box<Matcher>, Box<Error>> {
|
||||
@@ -309,17 +300,14 @@ impl Matcher for PermMatcher {
|
||||
}
|
||||
|
||||
#[cfg(not(unix))]
|
||||
fn matches(&self, _dummy_file_info: &DirEntry, _: &mut MatcherIO) -> bool {
|
||||
writeln!(&mut stderr(),
|
||||
"Permission matching not available on this platform!")
|
||||
.unwrap();
|
||||
fn matches(&self, file_info: &DirEntry, _: &mut MatcherIO) -> bool {
|
||||
stderr().write("Permission matching not available on this platform!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg(unix)]
|
||||
mod tests {
|
||||
use find::matchers::Matcher;
|
||||
use find::matchers::tests::get_dir_entry_for;
|
||||
@@ -487,6 +475,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn perm_matches() {
|
||||
let file_info = get_dir_entry_for("test_data/simple", "abbbc");
|
||||
let deps = FakeDependencies::new();
|
||||
|
||||
@@ -41,7 +41,6 @@ mod tests {
|
||||
use find::matchers::tests::get_dir_entry_for;
|
||||
use find::matchers::Matcher;
|
||||
use find::tests::FakeDependencies;
|
||||
use find::tests::fix_up_slashes;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
@@ -51,7 +50,6 @@ mod tests {
|
||||
let matcher = Printer::new();
|
||||
let deps = FakeDependencies::new();
|
||||
assert!(matcher.matches(&abbbc, &mut deps.new_matcher_io()));
|
||||
assert_eq!(fix_up_slashes("./test_data/simple/abbbc\n"),
|
||||
deps.get_output_as_string());
|
||||
assert_eq!("./test_data/simple/abbbc\n", deps.get_output_as_string());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
use std;
|
||||
use std::error::Error;
|
||||
use std::fs::{self, Metadata};
|
||||
use std::fs::{File, Metadata};
|
||||
use std::io::{stderr, Write};
|
||||
use std::time::SystemTime;
|
||||
use walkdir::DirEntry;
|
||||
@@ -22,7 +22,8 @@ pub struct NewerMatcher {
|
||||
|
||||
impl NewerMatcher {
|
||||
pub fn new(path_to_file: &str) -> Result<NewerMatcher, Box<Error>> {
|
||||
let metadata = fs::metadata(path_to_file)?;
|
||||
let f = File::open(path_to_file)?;
|
||||
let metadata = f.metadata()?;
|
||||
Ok(NewerMatcher { given_modification_time: metadata.modified()? })
|
||||
}
|
||||
|
||||
|
||||
+35
-72
@@ -219,18 +219,6 @@ mod tests {
|
||||
|
||||
use super::*;
|
||||
|
||||
#[cfg(windows)]
|
||||
/// Windows-only bodge for converting between path separators.
|
||||
pub fn fix_up_slashes(path: &str) -> String {
|
||||
path.replace("/", "\\")
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
/// Do nothing equivalent of the above for non-windows systems.
|
||||
pub fn fix_up_slashes(path: &str) -> String {
|
||||
path.to_string()
|
||||
}
|
||||
|
||||
/// A struct that implements Dependencies, but uses faked implementations,
|
||||
/// allowing us to check output, set the time returned by clocks etc.
|
||||
pub struct FakeDependencies {
|
||||
@@ -279,15 +267,14 @@ mod tests {
|
||||
let deps = FakeDependencies::new();
|
||||
|
||||
|
||||
let rc = find_main(&["find", &fix_up_slashes("./test_data/simple"), "-sorted"],
|
||||
&deps);
|
||||
let rc = find_main(&["find", "./test_data/simple", "-sorted"], &deps);
|
||||
|
||||
assert_eq!(rc, 0);
|
||||
assert_eq!(deps.get_output_as_string(),
|
||||
fix_up_slashes("./test_data/simple\n\
|
||||
"./test_data/simple\n\
|
||||
./test_data/simple/abbbc\n\
|
||||
./test_data/simple/subdir\n\
|
||||
./test_data/simple/subdir/ABBBC\n"));
|
||||
./test_data/simple/subdir/ABBBC\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -295,53 +282,46 @@ mod tests {
|
||||
let deps = FakeDependencies::new();
|
||||
|
||||
|
||||
let rc = find_main(&["find", &fix_up_slashes("./test_data/simple"), "-sorted", "-depth"],
|
||||
&deps);
|
||||
let rc = find_main(&["find", "./test_data/simple", "-sorted", "-depth"], &deps);
|
||||
|
||||
assert_eq!(rc, 0);
|
||||
assert_eq!(deps.get_output_as_string(),
|
||||
fix_up_slashes("./test_data/simple/abbbc\n\
|
||||
"./test_data/simple/abbbc\n\
|
||||
./test_data/simple/subdir/ABBBC\n\
|
||||
./test_data/simple/subdir\n\
|
||||
./test_data/simple\n"));
|
||||
./test_data/simple\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_maxdepth() {
|
||||
let deps = FakeDependencies::new();
|
||||
|
||||
let rc =
|
||||
find_main(&["find", &fix_up_slashes("./test_data/depth"), "-sorted", "-maxdepth", "2"],
|
||||
&deps);
|
||||
let rc = find_main(&["find", "./test_data/depth", "-sorted", "-maxdepth", "2"],
|
||||
&deps);
|
||||
|
||||
assert_eq!(rc, 0);
|
||||
assert_eq!(deps.get_output_as_string(),
|
||||
fix_up_slashes("./test_data/depth\n\
|
||||
"./test_data/depth\n\
|
||||
./test_data/depth/1\n\
|
||||
./test_data/depth/1/2\n\
|
||||
./test_data/depth/1/f1\n\
|
||||
./test_data/depth/f0\n"));
|
||||
./test_data/depth/f0\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_maxdepth_depth_first() {
|
||||
let deps = FakeDependencies::new();
|
||||
|
||||
let rc = find_main(&["find",
|
||||
&fix_up_slashes("./test_data/depth"),
|
||||
"-sorted",
|
||||
"-maxdepth",
|
||||
"2",
|
||||
"-depth"],
|
||||
let rc = find_main(&["find", "./test_data/depth", "-sorted", "-maxdepth", "2", "-depth"],
|
||||
&deps);
|
||||
|
||||
assert_eq!(rc, 0);
|
||||
assert_eq!(deps.get_output_as_string(),
|
||||
fix_up_slashes("./test_data/depth/1/2\n\
|
||||
"./test_data/depth/1/2\n\
|
||||
./test_data/depth/1/f1\n\
|
||||
./test_data/depth/1\n\
|
||||
./test_data/depth/f0\n\
|
||||
./test_data/depth\n"));
|
||||
./test_data/depth\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -349,7 +329,7 @@ mod tests {
|
||||
let deps = FakeDependencies::new();
|
||||
|
||||
let rc = find_main(&["find",
|
||||
&fix_up_slashes("./test_data/depth"),
|
||||
"./test_data/depth",
|
||||
"-sorted",
|
||||
"-print",
|
||||
",",
|
||||
@@ -360,64 +340,54 @@ mod tests {
|
||||
|
||||
assert_eq!(rc, 0);
|
||||
assert_eq!(deps.get_output_as_string(),
|
||||
fix_up_slashes("./test_data/depth\n\
|
||||
"./test_data/depth\n\
|
||||
./test_data/depth/1\n\
|
||||
./test_data/depth/f0\n"));
|
||||
./test_data/depth/f0\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_zero_maxdepth() {
|
||||
let deps = FakeDependencies::new();
|
||||
let rc = find_main(&["find", &fix_up_slashes("./test_data/depth"), "-maxdepth", "0"],
|
||||
&deps);
|
||||
let rc = find_main(&["find", "./test_data/depth", "-maxdepth", "0"], &deps);
|
||||
|
||||
assert_eq!(rc, 0);
|
||||
assert_eq!(deps.get_output_as_string(),
|
||||
fix_up_slashes("./test_data/depth\n"));
|
||||
assert_eq!(deps.get_output_as_string(), "./test_data/depth\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_zero_maxdepth_depth_first() {
|
||||
let deps = FakeDependencies::new();
|
||||
let rc =
|
||||
find_main(&["find", &fix_up_slashes("./test_data/depth"), "-maxdepth", "0", "-depth"],
|
||||
&deps);
|
||||
let rc = find_main(&["find", "./test_data/depth", "-maxdepth", "0", "-depth"],
|
||||
&deps);
|
||||
|
||||
assert_eq!(rc, 0);
|
||||
assert_eq!(deps.get_output_as_string(),
|
||||
fix_up_slashes("./test_data/depth\n"));
|
||||
assert_eq!(deps.get_output_as_string(), "./test_data/depth\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_mindepth() {
|
||||
let deps = FakeDependencies::new();
|
||||
let rc =
|
||||
find_main(&["find", &fix_up_slashes("./test_data/depth"), "-sorted", "-mindepth", "3"],
|
||||
&deps);
|
||||
let rc = find_main(&["find", "./test_data/depth", "-sorted", "-mindepth", "3"],
|
||||
&deps);
|
||||
|
||||
assert_eq!(rc, 0);
|
||||
assert_eq!(deps.get_output_as_string(),
|
||||
fix_up_slashes("./test_data/depth/1/2/3\n\
|
||||
"./test_data/depth/1/2/3\n\
|
||||
./test_data/depth/1/2/3/f3\n\
|
||||
./test_data/depth/1/2/f2\n"));
|
||||
./test_data/depth/1/2/f2\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_mindepth_depth_first() {
|
||||
let deps = FakeDependencies::new();
|
||||
let rc = find_main(&["find",
|
||||
&fix_up_slashes("./test_data/depth"),
|
||||
"-sorted",
|
||||
"-mindepth",
|
||||
"3",
|
||||
"-depth"],
|
||||
let rc = find_main(&["find", "./test_data/depth", "-sorted", "-mindepth", "3", "-depth"],
|
||||
&deps);
|
||||
|
||||
assert_eq!(rc, 0);
|
||||
assert_eq!(deps.get_output_as_string(),
|
||||
fix_up_slashes("./test_data/depth/1/2/3/f3\n\
|
||||
"./test_data/depth/1/2/3/f3\n\
|
||||
./test_data/depth/1/2/3\n\
|
||||
./test_data/depth/1/2/f2\n"));
|
||||
./test_data/depth/1/2/f2\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -432,7 +402,7 @@ mod tests {
|
||||
let rc = find_main(&["find",
|
||||
&new_dir.path().to_string_lossy(),
|
||||
"-newer",
|
||||
&fix_up_slashes("./test_data/simple/abbbc")],
|
||||
"./test_data/simple/abbbc"],
|
||||
&deps);
|
||||
|
||||
assert_eq!(rc, 0);
|
||||
@@ -442,7 +412,7 @@ mod tests {
|
||||
// now do it the other way around, and nothing should be output
|
||||
let deps = FakeDependencies::new();
|
||||
let rc = find_main(&["find",
|
||||
&fix_up_slashes("./test_data/simple/abbbc"),
|
||||
"./test_data/simple/abbbc",
|
||||
"-newer",
|
||||
&new_dir.path().to_string_lossy()],
|
||||
&deps);
|
||||
@@ -491,17 +461,12 @@ mod tests {
|
||||
let mut deps = FakeDependencies::new();
|
||||
deps.set_time(file_time);
|
||||
|
||||
let rc = find_main(&["find",
|
||||
&fix_up_slashes("./test_data/simple/subdir"),
|
||||
"-type",
|
||||
"f",
|
||||
arg,
|
||||
"0"],
|
||||
let rc = find_main(&["find", "./test_data/simple/subdir", "-type", "f", arg, "0"],
|
||||
&deps);
|
||||
|
||||
assert_eq!(rc, 0);
|
||||
assert_eq!(deps.get_output_as_string(),
|
||||
fix_up_slashes("./test_data/simple/subdir/ABBBC\n"));
|
||||
"./test_data/simple/subdir/ABBBC\n");
|
||||
}
|
||||
|
||||
// now Check file time doesn't match a file that's too new
|
||||
@@ -522,13 +487,11 @@ mod tests {
|
||||
let deps = FakeDependencies::new();
|
||||
// only look at files because the "size" of a directory is a system (and filesystem)
|
||||
// dependent thing and we want these tests to be universal.
|
||||
let rc =
|
||||
find_main(&["find", &fix_up_slashes("./test_data/size"), "-type", "f", "-size", "1b"],
|
||||
&deps);
|
||||
let rc = find_main(&["find", "./test_data/size", "-type", "f", "-size", "1b"],
|
||||
&deps);
|
||||
|
||||
assert_eq!(rc, 0);
|
||||
assert_eq!(deps.get_output_as_string(),
|
||||
fix_up_slashes("./test_data/size/512bytes\n"));
|
||||
assert_eq!(deps.get_output_as_string(), "./test_data/size/512bytes\n");
|
||||
|
||||
let deps = FakeDependencies::new();
|
||||
let rc = find_main(&["find", "./test_data/size", "-type", "f", "-size", "+1b"],
|
||||
|
||||
@@ -62,13 +62,10 @@ fn main() {
|
||||
// first two args are going to be the path to this executable and
|
||||
// the destination_dir we want to write to. Don't write either of those
|
||||
// as they'll be non-deterministic.
|
||||
f.write_fmt(format_args!("cwd={}\nargs=\n",
|
||||
env::current_dir().unwrap().to_string_lossy()))
|
||||
f.write_fmt(format_args!("cwd={}\nargs={:?}\n",
|
||||
env::current_dir().unwrap().to_string_lossy(),
|
||||
&args[2..]))
|
||||
.expect("failed to write to file");
|
||||
for arg in &args[2..] {
|
||||
f.write_fmt(format_args!("{}\n", arg)).expect("failed to write to file");
|
||||
}
|
||||
|
||||
}
|
||||
std::process::exit(if config.exit_with_failure { 2 } else { 0 });
|
||||
}
|
||||
|
||||
@@ -71,24 +71,12 @@ pub fn path_to_testing_commandline() -> String {
|
||||
.to_string()
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
/// A copy of find::tests::fix_up_slashes.
|
||||
/// TODO: find out how to share #[cfg(test)] functions/structs between unit
|
||||
/// and integration tests.
|
||||
pub fn fix_up_slashes(path: &str) -> String {
|
||||
path.replace("/", "\\")
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub fn fix_up_slashes(path: &str) -> String {
|
||||
path.to_string()
|
||||
}
|
||||
|
||||
/// A copy of find::tests::FakeDependencies.
|
||||
/// TODO: find out how to share #[cfg(test)] functions/structs between unit
|
||||
/// and integration tests.
|
||||
pub fn get_dir_entry_for(directory: &str, filename: &str) -> DirEntry {
|
||||
for wrapped_dir_entry in WalkDir::new(fix_up_slashes(directory)) {
|
||||
for wrapped_dir_entry in WalkDir::new(directory) {
|
||||
let dir_entry = wrapped_dir_entry.unwrap();
|
||||
if dir_entry.file_name().to_string_lossy() == filename {
|
||||
return dir_entry;
|
||||
|
||||
@@ -44,8 +44,8 @@ fn matching_executes_code() {
|
||||
let mut s = String::new();
|
||||
f.read_to_string(&mut s).expect("failed to read output file");
|
||||
assert_eq!(s,
|
||||
fix_up_slashes(&format!("cwd={}\nargs=\nabc\ntest_data/simple/abbbc\nxyz\n",
|
||||
env::current_dir().unwrap().to_string_lossy())));
|
||||
format!("cwd={}\nargs=[\"abc\", \"test_data/simple/abbbc\", \"xyz\"]\n",
|
||||
env::current_dir().unwrap().to_string_lossy()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -66,8 +66,8 @@ fn matching_executes_code_in_files_directory() {
|
||||
let mut s = String::new();
|
||||
f.read_to_string(&mut s).expect("failed to read output file");
|
||||
assert_eq!(s,
|
||||
fix_up_slashes(&format!("cwd={}/test_data/simple\nargs=\nabc\n./abbbc\nxyz\n",
|
||||
env::current_dir().unwrap().to_string_lossy())));
|
||||
format!("cwd={}/test_data/simple\nargs=[\"abc\", \"./abbbc\", \"xyz\"]\n",
|
||||
env::current_dir().unwrap().to_string_lossy()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -92,7 +92,7 @@ fn matching_fails_if_executable_fails() {
|
||||
let mut s = String::new();
|
||||
f.read_to_string(&mut s).expect("failed to read output file");
|
||||
assert_eq!(s,
|
||||
fix_up_slashes(&format!("cwd={}/test_data/simple\nargs=\n--exit_with_failure\nabc\n.\
|
||||
/abbbc\nxyz\n",
|
||||
env::current_dir().unwrap().to_string_lossy())));
|
||||
format!("cwd={}/test_data/simple\nargs=[\"--exit_with_failure\", \"abc\", \
|
||||
\"./abbbc\", \"xyz\"]\n",
|
||||
env::current_dir().unwrap().to_string_lossy()));
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ fn find_exec() {
|
||||
let deps = FakeDependencies::new();
|
||||
|
||||
let rc = find_main(&["find",
|
||||
&fix_up_slashes("./test_data/simple/subdir"),
|
||||
"./test_data/simple/subdir",
|
||||
"-type",
|
||||
"f",
|
||||
"-exec",
|
||||
@@ -53,8 +53,8 @@ fn find_exec() {
|
||||
let mut s = String::new();
|
||||
f.read_to_string(&mut s).expect("failed to read output file");
|
||||
assert_eq!(s,
|
||||
fix_up_slashes(&format!("cwd={}\nargs=\n(\n./test_data/simple/subdir/ABBBC\n-o\n",
|
||||
env::current_dir().unwrap().to_string_lossy())));
|
||||
format!("cwd={}\nargs=[\"(\", \"./test_data/simple/subdir/ABBBC\", \"-o\"]\n",
|
||||
env::current_dir().unwrap().to_string_lossy()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -65,7 +65,7 @@ fn find_execdir() {
|
||||
// only look at files because the "size" of a directory is a system (and filesystem)
|
||||
// dependent thing and we want these tests to be universal.
|
||||
let rc = find_main(&["find",
|
||||
&fix_up_slashes("./test_data/simple/subdir"),
|
||||
"./test_data/simple/subdir",
|
||||
"-type",
|
||||
"f",
|
||||
"-execdir",
|
||||
@@ -87,7 +87,7 @@ fn find_execdir() {
|
||||
let mut s = String::new();
|
||||
f.read_to_string(&mut s).expect("failed to read output file");
|
||||
assert_eq!(s,
|
||||
fix_up_slashes(&format!("cwd={}/test_data/simple/subdir\nargs=\n)\n./ABBBC\n,\n",
|
||||
env::current_dir().unwrap().to_string_lossy())));
|
||||
format!("cwd={}/test_data/simple/subdir\nargs=[\")\", \"./ABBBC\", \",\"]\n",
|
||||
env::current_dir().unwrap().to_string_lossy()));
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user