Don't create command until we know we can test it

For regression 210 we may not actually need to test anything if the file
system doesn't support creating files with invalid UTF-8 bytes. Don't
create the command until we know there will be an assertion.
This commit is contained in:
Sebastian Nowicki 2017-10-16 14:35:26 +02:00 committed by Andrew Gallant
parent 0d2354aca6
commit 712311fdc6

View File

@ -1014,10 +1014,10 @@ fn regression_210() {
let badutf8 = OsStr::from_bytes(&b"foo\xffbar"[..]);
let wd = WorkDir::new("regression_210");
let mut cmd = wd.command();
// APFS does not support creating files with invalid UTF-8 bytes.
// https://github.com/BurntSushi/ripgrep/issues/559
if wd.try_create(badutf8, "test").is_ok() {
let mut cmd = wd.command();
cmd.arg("-H").arg("test").arg(badutf8);
let out = wd.output(&mut cmd);