Skip to content

Instantly share code, notes, and snippets.

@qgadrian
Created November 24, 2023 09:23
Show Gist options
  • Save qgadrian/b01d5038ea0daee75d3ce5d0baac7d05 to your computer and use it in GitHub Desktop.
Save qgadrian/b01d5038ea0daee75d3ce5d0baac7d05 to your computer and use it in GitHub Desktop.
Run Elixir mix tests several times to check which of them are failing randomly
#!/bin/bash
# Define the maximum number of test executions
MAX_EXECUTIONS=100
# Initialize a counter for test executions
executions=0
# Run the tests until one of them fails or the limit is reached
while [ $executions -lt $MAX_EXECUTIONS ]; do
mix test
# Check the exit status of the last command (mix test)
if [ $? -ne 0 ]; then
echo "A test has failed!"
exit 1
fi
# Increment the execution counter
executions=$((executions + 1))
done
# If the loop completes without a failure, print a message
echo "All tests passed $executions times."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment