Skip to content

Instantly share code, notes, and snippets.

@lbrito1
Created February 19, 2019 19:42
Show Gist options
  • Save lbrito1/857b62ea79d4cb4a61a3511df21ee304 to your computer and use it in GitHub Desktop.
Save lbrito1/857b62ea79d4cb4a61a3511df21ee304 to your computer and use it in GitHub Desktop.
RSpec failing seed finder
#!/bin/bash
# Finds the first seed that breaks the spec suite. Outputs to stdout and a file (rspec_output).
found=0
while [ $found == 0 ]
do
rspec --order random 2>&1 | tee -a ./rspec_output
found=$(more rspec_output | grep Failed | wc -l)
if [ $found == 0 ]
then
> rspec_output # empty results if not found
fi
done
echo "Found failing seed."
@ixti
Copy link

ixti commented Jul 15, 2019

FWIW --order random is redundant and I don't think it worth to append to the output:

while bundle exec rspec --format json --output ./rspec_output; do
  echo "All good, keep trying..."
done

seed="$(cat ./rspec_output | jq '.seed')"
echo "Found failing seed: ${seed}; Running rspec bisect to nail it down..."

bundle exec rspec --bisect=verbose --order "random:${seed}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment