Fixes Windows compilation#74
Conversation
This works, although I'm not sure if it's the best way to do it.
And fix some names
I couldn't get the types to play nicely.
|
Hmm, it looks like the Windows tests are failing for some reason. From looking at the test I don't see any obvious reasons why it should be failing when it does. Do you have a way to test locally? The only idea I have is that the test files have Unix line endings and not Windows. |
|
I'm seeing tests fail against 9ee96d6 and v0.1.7 on WSL. It's might be a line endings problem but it might be some other escaping problem. I've taken some swings at it but coming up short. These fail in one_per_line: aws azure random These fail in one_per_file: pem_key private_key If skip these files, it passes tests. If I run I'll bet you can reproduce it locally if you ran unix2dos on the test files. |
|
Here's my kludgy modified test: #[test]
fn no_false_negatives() {
let skip_list = vec![
/*"aws",
"azure",
//"random",
"pem_key","private_key"*/];
for maybe_entry in fs::read_dir("test/one_per_line").unwrap() {
let entry = maybe_entry.unwrap();
if skip_list.contains((&entry.path().file_name().unwrap().to_str().unwrap())) {
continue
}
//let contents = fs::read_to_string(entry.path()).unwrap();
//let actual = contents.matches(LINE_ENDING).count();
let fh = File::open(entry.path()).unwrap();
let con = BufReader::new(fh).lines();
let ac = con.count();
let res = find_secrets(
&[entry.path()],
&[],
false,
false,
BufferWriter::stdout(ColorChoice::Never),
);
assert_eq!(
res.unwrap(),
ac,
"{:?}",
entry.file_name()
);
}
for maybe_entry in fs::read_dir("test/one_per_file").unwrap() {
let entry = maybe_entry.unwrap();
if skip_list.contains((&entry.path().file_name().unwrap().to_str().unwrap())) {
continue
}
let res = find_secrets(
&[entry.path()],
&[],
false,
false,
BufferWriter::stdout(ColorChoice::Never),
);
assert_eq!(res.unwrap(), 1, "{:?}", entry.file_name());
}
} |
|
Found it. Gotta add |
This is apparently required to enable tests to pass on a native Windows clone of the source code, including in CI. Prior to this change, one could run unix2dos on the test files to replicate the failure I experienced on Windows even when tests pass on Linux for the v0.1.7 tag and fail on Windows. I don't think I've fixed a Windows specific bug in anything in a decade! This is my gaming rig, not programming, haha.
|
After some more toggling, I'm able to reproduce the failure when pem_key is CRLF but I'm out of steam for tonight. |
|
I've got myself convinced that this is a bug in how ripsecrets or grep_searcher is handling CRLF and d3197e2 has changes that should facilitate debugging. I want to refactor the |
This works, although I'm not sure if it's the best way to do it.
Fixes #70