0

We have a script that looks something like this:

#!/bin/bash
for cookbook in $cookbooks; do
    cd /path/to/$cookbook
    kitchen test;
    # Log whether the test failed or passed
done;

# Print number of tests passed and number of tests failed

How can I determine if my kitchen test passed or failed?

Jacklynn
  • 1,503
  • 1
  • 13
  • 23

1 Answers1

1

You can check exit status of kitchen test command, and increment counter like:

#!/bin/bash
let failed=0
let passed=0

for cookbook in $cookbooks; do
  cd /path/to/$cookbook
  kitchen test;

  if [ $? -ne 0 ]
  then
     failed=$((failed + 1))
  else
    passed=$((passed + 1))
  fi
done;

echo "There was $passed passed and $failed failed tests."
rastasheep
  • 10,416
  • 3
  • 27
  • 37