-
-
Save marcioAlmada/4755572 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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