Skip to content

Instantly share code, notes, and snippets.

@odlp
Last active May 19, 2021 14:57
Show Gist options
  • Save odlp/25a7813e7e58ae49c2b6563425c3de23 to your computer and use it in GitHub Desktop.
Save odlp/25a7813e7e58ae49c2b6563425c3de23 to your computer and use it in GitHub Desktop.
Percentage error output in tests
#!/bin/bash
# Save stdout & stderr to individual files:
bundle exec rspec > >(tee stdout.log) 2> >(tee stderr.log >&2)
# Calculate the percentage:
wc -l stderr.log stdout.log \
| ruby -e \
'err, _, total = ARGF.map(&:to_f); puts "#{(err/total*100).round}% error output"'
# => XX% error output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment