Skip to content

Unit tests should normalize whitespace before sorting lines, rather than after #21

@helloworld12321

Description

@helloworld12321

Right now, process_client_logs.bats and process_logs.bats each take the actual result, sort it, and diff it with the expected result ignoring whitespace.

  # process_client_logs.bats
  sort data/discovery/failed_login_data.txt > data/discovery_sorted.txt
  sort tests/discovery_failed_login_data.txt > data/target_sorted.txt
  run diff -wbB data/target_sorted.txt data/discovery_sorted.txt
  assert_success
  # process_logs.bats
  sort tests/summary_plots.html > targets/target.txt
  sort failed_login_summary.html > targets/sorted.txt
  run diff -wbB targets/target.txt targets/sorted.txt
  assert_success

There's a problem, though—if a line has extra whitespace, it might get sorted differently than the canonical, whitespace-normalized version!

Screen Shot 2021-09-17 at 5 44 02 PM

So, to compare two files in a whitespace-insensitive way, we need to normalize whitespace and then sort :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions