sstephenson / bats

Bash Automated Testing System
MIT License
7.12k stars 519 forks source link

Output tests ignore multiline whitespace differences #170

Open ZoomyCat opened 8 years ago

ZoomyCat commented 8 years ago

I'm testing 3 seperate text display algorithms using bats. I found that the reporting was very accurate when one of my algorithms was providing extra spacing.

When I put my data into an array and I output it two of the three give expected output. The third one does not and I can clearly see that it does not. Here is a small snipped of the approrpiate output:

$ printf '%s\n' "${ManArray[@]}" | head -n 5
WC(1)                             User Commands                            WC(1)

NAME
       wc - print newline, word, and byte counts for each file

Here is when I run the display through the text library:

$ ManArray=$( man wc ); msg "${ManArray[@]}" | head -n 5
WC(1) User Commands WC(1)

NAME
 wc - print newline, word, and byte counts for each file

Here is the bats file used in this test:

#!/usr/bin/env bats

setup() {
  . "$HOME"/gitlab/dev-tools/lib/lib-text
  msgspd fast
  commaspeed="0"
  periodspeed="0"
  speed="0"
  linespeed="0"
  ManArray=$( man wc )
}
@test "fastmsg - man page output msg accuracy test." {
 run msg "${ManArray[@]}"
 [ "$output" = "${ManArray[@]}" ]
}
teardown() {
  cleanup_libtext
  cleanup_libtextconf
}

Result:

$ bats fastmsgshouldfail.bats 
   fastmsg - man page output msg accuracy test.                                1/1
1 test, 0 failures

Am I doing something wrong or am I right to think that this test should fail?