Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pietroalbini committed Jun 4, 2022
1 parent e257f38 commit 8ea9598
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/tools/compiletest/src/read2/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::read2::{ProcOutput, EXCLUDED_PLACEHOLDER_LEN, HEAD_LEN, TAIL_LEN};
use crate::read2::{ProcOutput, FILTERED_PATHS_PLACEHOLDER_LEN, HEAD_LEN, TAIL_LEN};

#[test]
fn test_abbreviate_short_string() {
Expand Down Expand Up @@ -59,21 +59,21 @@ fn test_abbreviate_long_string_multiple_steps() {
}

#[test]
fn test_abbreviate_exclusions_are_detected() {
fn test_abbreviate_filterss_are_detected() {
let mut out = ProcOutput::new();
let exclusions = &["foo".to_string(), "quux".to_string()];
let filters = &["foo".to_string(), "quux".to_string()];

out.extend(b"Hello foo", exclusions);
out.extend(b"Hello foo", filters);
// Check items from a previous extension are not double-counted.
out.extend(b"! This is a qu", exclusions);
out.extend(b"! This is a qu", filters);
// Check items are detected across extensions.
out.extend(b"ux.", exclusions);
out.extend(b"ux.", filters);

match out {
ProcOutput::Full { excluded_len, .. } => assert_eq!(
excluded_len,
EXCLUDED_PLACEHOLDER_LEN * exclusions.len() as isize
- exclusions.iter().map(|i| i.len() as isize).sum::<isize>()
match &out {
ProcOutput::Full { bytes, filtered_len } => assert_eq!(
*filtered_len,
bytes.len() + FILTERED_PATHS_PLACEHOLDER_LEN * filters.len()
- filters.iter().map(|i| i.len()).sum::<usize>()
),
ProcOutput::Abbreviated { .. } => panic!("out should not be abbreviated"),
}
Expand All @@ -82,15 +82,15 @@ fn test_abbreviate_exclusions_are_detected() {
}

#[test]
fn test_abbreviate_exclusions_avoid_abbreviations() {
fn test_abbreviate_filters_avoid_abbreviations() {
let mut out = ProcOutput::new();
let exclusions = &[std::iter::repeat('a').take(64).collect::<String>()];
let filters = &[std::iter::repeat('a').take(64).collect::<String>()];

let mut expected = vec![b'.'; HEAD_LEN - EXCLUDED_PLACEHOLDER_LEN as usize];
expected.extend_from_slice(exclusions[0].as_bytes());
let mut expected = vec![b'.'; HEAD_LEN - FILTERED_PATHS_PLACEHOLDER_LEN as usize];
expected.extend_from_slice(filters[0].as_bytes());
expected.extend_from_slice(&vec![b'.'; TAIL_LEN]);

out.extend(&expected, exclusions);
out.extend(&expected, filters);

// We first check the length to avoid endless terminal output if the length differs, since
// `out` is hundreds of KBs in size.
Expand All @@ -100,20 +100,20 @@ fn test_abbreviate_exclusions_avoid_abbreviations() {
}

#[test]
fn test_abbreviate_exclusions_can_still_cause_abbreviations() {
fn test_abbreviate_filters_can_still_cause_abbreviations() {
let mut out = ProcOutput::new();
let exclusions = &[std::iter::repeat('a').take(64).collect::<String>()];
let filters = &[std::iter::repeat('a').take(64).collect::<String>()];

let mut input = vec![b'.'; HEAD_LEN];
input.extend_from_slice(&vec![b'.'; TAIL_LEN]);
input.extend_from_slice(exclusions[0].as_bytes());
input.extend_from_slice(filters[0].as_bytes());

let mut expected = vec![b'.'; HEAD_LEN];
expected.extend_from_slice(b"\n\n<<<<<< SKIPPED 64 BYTES >>>>>>\n\n");
expected.extend_from_slice(&vec![b'.'; TAIL_LEN - 64]);
expected.extend_from_slice(&vec![b'a'; 64]);

out.extend(&input, exclusions);
out.extend(&input, filters);

// We first check the length to avoid endless terminal output if the length differs, since
// `out` is hundreds of KBs in size.
Expand Down

0 comments on commit 8ea9598

Please sign in to comment.