Skip to content

Instantly share code, notes, and snippets.

@marcioAlmada
Forked from erithmetic/autounit
Last active December 12, 2015 09:59
Show Gist options
  • Save marcioAlmada/4755572 to your computer and use it in GitHub Desktop.
Save marcioAlmada/4755572 to your computer and use it in GitHub Desktop.
# Prereqs:
# * Ruby
# * gem install watchr
# * gem install rb-inotify
# * pecl install xdebug // in case you want to generate coverage reports
# Usage:
# copy autotest to php project directory
# run watchr autotest
def phpunit testpath
puts "\e[H\e[2J" #clear console
system "phpunit #{testpath}"
#system "phpunit --coverage-html /tmp/coverage/" # generates html coverage report at `/tmp/coverage`
#system "phpunit --coverage-text" # shows coverage report at terminal
end
def notify status, msg
if status
title = 'PASS'
image = 'user-available'
else
title = "FAIL"
image = 'user-busy'
end
system "notify-send #{title} #{msg} -i #{image}"
end
watch('Test/.*Test\.php') do |md|
puts "\e[H\e[2J" #clear console
status = phpunit "#{md[0]}"
notify status, md[0]
end
watch('src/(.*)\.php') do |md|
puts "\e[H\e[2J" #clear console
testpath = md[1] + "Test.php"
status = phpunit "Test/#{testpath}"
notify status, testpath
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment