-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from jprochazk/master
Add option to filter files using glob patterns
- Loading branch information
Showing
10 changed files
with
232 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
asdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bvcx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# File |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Nested file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
use indoc::indoc; | ||
use std::process::Command; | ||
use std::process::Stdio; | ||
use strip_ansi_escapes::strip as strip_ansi_escapes; | ||
|
||
fn run_cmd(args: &[&str]) -> String { | ||
let mut cmd = Command::new("cargo"); | ||
cmd.arg("run") | ||
.arg("--") | ||
.arg("tests/data") | ||
.arg("--num-threads") | ||
.arg("1") | ||
.arg("--order") | ||
.arg("filename"); | ||
|
||
for arg in args { | ||
cmd.arg(arg); | ||
} | ||
|
||
let output = cmd | ||
.stdout(Stdio::piped()) | ||
.stderr(Stdio::piped()) | ||
.spawn() | ||
.unwrap() | ||
.wait_with_output() | ||
.unwrap(); | ||
assert!(output.status.success()); | ||
|
||
String::from_utf8(strip_ansi_escapes(output.stdout).unwrap()) | ||
.unwrap() | ||
.trim() | ||
.to_string() | ||
} | ||
|
||
#[test] | ||
fn glob() { | ||
assert_eq!( | ||
run_cmd(&["--glob", "*.txt"]), | ||
indoc!( | ||
" | ||
data (10.00 B) | ||
├─ a.txt (5.00 B) | ||
├─ b.txt (5.00 B) | ||
└─ nested" | ||
) | ||
) | ||
} | ||
|
||
#[test] | ||
fn glob_negative() { | ||
assert_eq!( | ||
run_cmd(&["--glob", "!*.txt"]), | ||
indoc!( | ||
" | ||
data (21.00 B) | ||
├─ c.md (7.00 B) | ||
└─ nested (14.00 B) | ||
└─ other.md (14.00 B)" | ||
) | ||
) | ||
} | ||
|
||
#[test] | ||
fn glob_case_insensitive() { | ||
assert_eq!( | ||
run_cmd(&["--glob", "*.TXT", "--glob-case-insensitive"]), | ||
indoc!( | ||
" | ||
data (10.00 B) | ||
├─ a.txt (5.00 B) | ||
├─ b.txt (5.00 B) | ||
└─ nested" | ||
) | ||
) | ||
} | ||
|
||
#[test] | ||
fn iglob() { | ||
assert_eq!( | ||
run_cmd(&["--iglob", "*.TXT"]), | ||
indoc!( | ||
" | ||
data (10.00 B) | ||
├─ a.txt (5.00 B) | ||
├─ b.txt (5.00 B) | ||
└─ nested" | ||
) | ||
) | ||
} |