sstephenson / bats

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

No check-marks and X in a bats script test run O/P #127

Open vkhetrapal opened 9 years ago

vkhetrapal commented 9 years ago

I have created below script for testing installation of git.

!/usr/bin/env bats

@test "verify git installation" { run bash -c "rpm -qa|grep git" [ "$status" -eq 0 ] }

@test "Verifying whether git binary is available" { run which git [ "$status" -eq 0 ]

Due to some reason, my "kitchen verify" produces weird O/P. Am I doing something wrong ? I am using docker (centos7 -- base image) as kitchen driver.

kitchen verify

-----> Starting Kitchen (v1.4.2) -----> Verifying ... $$$$$$ Running legacy verify for 'Docker' Driver Preparing files for transfer Removing /tmp/verifier/suites/bats Transferring files to -----> Running bats test suite verify git installation1/2 ✓ verify git installation ✓ Verifying whether git binary is available

   2 tests, 0 failures
   Finished verifying <git-centos> (0m0.90s).

-----> Kitchen is finished. (0m0.98s)

vkhetrapal commented 9 years ago

These lines are the issue :

verify git installation1/2 ✓ verify git installation ✓ Verifying whether git binary is available

X1011 commented 9 years ago

Somewhere along the way, the UTF-8-encoded ✓ is incorrectly being interpreted with Windows-1252 encoding. You will have to narrow down where. You could start by opening libexec/bats-format-tap-stream in a text editor to see if it's encoded correctly on-disk. If so, I'd guess your terminal does not support UTF-8.

leahcim commented 9 years ago

It could also be your font not having the characters in question. Take a look at libexec/bats-format-tap-stream in #128. You might e.g. view it like this:

head -46 libexec/bats-format-tap-stream | tail -7

This should show you:

if [[ $OSTYPE != *msys* ]]; then
  PASS_SYMBOL='✓'
  FAIL_SYMBOL='✗'
else
  PASS_SYMBOL='√'
  FAIL_SYMBOL='×'
fi

Can you see any of the characters correctly in your terminal?

vkhetrapal commented 9 years ago

I am actually using busser-bats gem and a look at /root/.chefdk/gem/ruby/2.1.0/gems/busser-bats-0.3.0/vendor/bats/libexec/bats-format-tap-stream shows this :

pass() { go_to_column 0 printf " ✓ %s" "$name" advance

fail() { go_to_column 0 set_color 1 bold printf " ✗ %s" "$name" advance

X1011 commented 9 years ago

maybe you need to change your system locale to UTF-8: https://google.com/search?q=CentOS+utf-8