xsv icon indicating copy to clipboard operation
xsv copied to clipboard

prop_cat_cols fails with BOM

Open Manishearth opened this issue 4 years ago • 3 comments

Caught by rustc CI

The test fails when it tries to compare [[""]] with [["\u{feff}"]]. Presumably the BOM is being stripped somewhere.

#[test]
fn prop_cat_cols() {
    fn p(rows1: CsvData, rows2: CsvData) -> bool {
        let got: Vec<Vec<String>> = run_cat(
            "cat_cols", "columns", rows1.clone(), rows2.clone(), no_headers);

        let mut expected: Vec<Vec<String>> = vec![];
        let (rows1, rows2) = (rows1.to_vecs().into_iter(),
                              rows2.to_vecs().into_iter());
        for (mut r1, r2) in rows1.zip(rows2) {
            r1.extend(r2.into_iter());
            expected.push(r1);
        }
        rassert_eq!(got, expected)
    }
     assert!(p(CsvData { data: vec![CsvRecord(vec!["".into()])] },  CsvData { data: vec![CsvRecord(vec!["\u{feff}".into()])] }));
 }

Manishearth avatar Jun 19 '20 19:06 Manishearth

It looks like this also hits the prop_reverse_no_headers test as well. I'm not sure if a1165e0fe58e6e39f6ed8b1a67ca87dd966c0df3 fixes that as well. Seen on rust-lang/rust CI:

  • https://github.com/rust-lang/rust/pull/82877#issuecomment-792971569
  • https://github.com/rust-lang/rust/pull/80891#issuecomment-783045918
thread 'test_reverse::prop_reverse_no_headers' panicked at '[quickcheck] TEST FAILED (runtime error). Arguments: (CsvData { data: [[[239, 187, 191]]] })
Error: "assertion failed: `(left == right)`\n  left: `[]`,\n right: `[[\"\\u{feff}\"]]`"', /cargo/registry/src/github.com-1ecc6299db9ec823/quickcheck-0.7.1/src/tester.rs:176:28

ehuss avatar Mar 08 '21 19:03 ehuss

test_frequency::prop_frequency_indexed can also fail randomly: https://github.com/rust-lang/rust/issues/99601.

RalfJung avatar Jul 22 '22 13:07 RalfJung

https://github.com/BurntSushi/xsv/commit/a1165e0fe58e6e39f6ed8b1a67ca87dd966c0df3 says it fixes this issue, but only exists on a branch, not in master.

RalfJung avatar Jul 22 '22 13:07 RalfJung