1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2024-12-12 19:18:24 +02:00

tests: fix tests on Windows

A bug in the atty crate was previously masking a problem with the
integration tests on Windows. Namely, the bug in atty resulted in
atty::is(Stdin) returning true if we couldn't get the file name for the
stdin stream. This in turn caused tests like `rg foo` to search the CWD,
which was the intended behavior. However, once the atty bug was fixed,
atty::is(Stdin) no longer returned true, causing `rg foo` searches to
fail.

On Unix-like systems, the atty behavior has always been correct.
However, on Unix-like systems we have a decent way of detecting whether
stdin is readable or not. If it isn't---which is the case in the
integration tests---then we fall back to searching the CWD. On Windows
however, we haven't yet implemented anything to detect whether stdin is
readable or not, so we must always assume that it is. Therefore, we
never get the "go ahead" to search the CWD and the tests fail.

Most of the tests are written to search the CWD explicitly, but there
were a few stragglers that don't.

This isn't great, and we should try to figure out how to do better stdin
detection on Windows.
This commit is contained in:
Andrew Gallant 2018-04-23 20:37:59 -04:00
parent 3dc6fe6f05
commit bf51058eb2
No known key found for this signature in database
GPG Key ID: B2E3A4923F8B0D44

View File

@ -1866,6 +1866,7 @@ fn feature_411_parallel_search_stats() {
let mut cmd = wd.command();
cmd.arg("--stats");
cmd.arg("Sherlock");
cmd.arg("./");
let lines: String = wd.stdout(&mut cmd);
assert_eq!(lines.contains("4 matched lines"), true);
@ -2021,7 +2022,7 @@ fn regression_270() {
wd.create("foo", "-test");
let mut cmd = wd.command();
cmd.arg("-e").arg("-test");
cmd.arg("-e").arg("-test").arg("./");
let lines: String = wd.stdout(&mut cmd);
assert_eq!(lines, path("foo:-test\n"));
}
@ -2170,7 +2171,7 @@ fn regression_693_context_option_in_contextless_mode() {
wd.create("bar", "xyz\n");
let mut cmd = wd.command();
cmd.arg("-C1").arg("-c").arg("--sort-files").arg("xyz");
cmd.arg("-C1").arg("-c").arg("--sort-files").arg("xyz").arg("./");
let lines: String = wd.stdout(&mut cmd);
let expected = "\