Skip to content

Commit

Permalink
tests: skip format check with cat property tests
Browse files Browse the repository at this point in the history
as property tests sometimes produce random input that file-format sometimes incorrectly infers as an invalid mime type
  • Loading branch information
jqnatividad committed Nov 21, 2024
1 parent 15d00aa commit e788aff
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/test_cat.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#![cfg(not(feature = "datapusher_plus"))]
use std::process;

use serial_test::serial;

use crate::{qcheck, quickcheck::TestResult, workdir::Workdir, Csv, CsvData};

fn no_headers(cmd: &mut process::Command) {
Expand All @@ -24,11 +26,11 @@ where

let mut cmd = wrk.command("cat");
modify_cmd(cmd.arg(which).arg("in1.csv").arg("in2.csv"));
wrk.assert_success(&mut cmd);
wrk.read_stdout(&mut cmd)
}

#[test]
#[serial]
fn prop_cat_rows() {
fn p(rows: CsvData) -> bool {
let expected = rows.clone();
Expand All @@ -38,7 +40,9 @@ fn prop_cat_rows() {
let (rows1, rows2) = rows.split_at(rows.len() / 2);
(rows1.to_vec(), rows2.to_vec())
};
std::env::set_var("QSV_SKIP_FORMAT_CHECK", "1");
let got: CsvData = run_cat("cat_rows", "rows", rows1, rows2, no_headers);
std::env::remove_var("QSV_SKIP_FORMAT_CHECK");
rassert_eq!(got, expected)
}
qcheck(p as fn(CsvData) -> bool);
Expand Down Expand Up @@ -735,15 +739,18 @@ fn cat_rowskey_insertion_order_noheader() {
}

#[test]
#[serial]
fn prop_cat_cols() {
fn p(rows1: CsvData, rows2: CsvData) -> TestResult {
std::env::set_var("QSV_SKIP_FORMAT_CHECK", "1");
let got: Vec<Vec<String>> = run_cat(
"cat_cols",
"columns",
rows1.clone(),
rows2.clone(),
no_headers,
);
std::env::remove_var("QSV_SKIP_FORMAT_CHECK");

let mut expected: Vec<Vec<String>> = vec![];
let (rows1, rows2) = (rows1.to_vecs().into_iter(), rows2.to_vecs().into_iter());
Expand Down

0 comments on commit e788aff

Please sign in to comment.