Skip to content

Instantly share code, notes, and snippets.

@evenstensberg
Created January 6, 2018 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evenstensberg/b02c76d54dd32a999bf37f355b33a607 to your computer and use it in GitHub Desktop.
Save evenstensberg/b02c76d54dd32a999bf37f355b33a607 to your computer and use it in GitHub Desktop.
Smoketest for karma bug reproduction
# Get outer pID so we can exit it later
trap "exit 9" TERM
TOP_PID=$$
# Get pID of chrome (requires you to have pidof on your computer)
# http://brewformulas.org/Pidof
PidName=`pidof chrome`
found=false
# change your path here
cd /Volumes/KINGSTON/openmct
#readline function
function rl() {
while IFS= read -r line
do
# change this to whatever you want to capture / smoketest
substr="The Layout controller prevents event bubbling while drag is in progress"
if [[ $line == *"$substr"* ]]; then
echo "$line"
found=true
#log everything after we've found our substr, might be useful for debug..
elif [[ "$found" = true ]]; then
echo "$line"
fi
done
}
function run() {
# stop if we've found the error and don't need to run karma anymore
if [[ "$found" = true ]]; then
kill -s TERM $TOP_PID
fi
# update pid, not really needed, but is to check if we've launched a new chrome instance
# and avoid creating more instances if we're in a background job
currentPid=`pidof chrome`
if [ "$PidName" != "$currentPid" ]; then
clear
npm run test | rl && run
fi
}
npm run test | rl && run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment