forked from viniciusluiz/brasil-endereco
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autotest
executable file
·48 lines (42 loc) · 1003 Bytes
/
autotest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Prereqs:
# * Ruby
# * gem install watchr
# * gem install rb-inotify
# * pecl install xdebug // in case you want to generate coverage reports
# User:
# * watchr autotest
# Usage:
# copy autotest to php project directory
# run watchr autotest
def clear
puts "\e[H\e[2J" #clear console
end
def phpunit testpath=''
clear
# system "phpunit"
system "phpunit #{testpath}"
# system "phpunit --coverage-html /tmp/coverage/" # generates html coverage report
# system "phpunit --coverage-text" # shows coverage report at terminal
# system "phpunit --testdox"
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|
clear
status = phpunit "#{md[0]}"
notify status, md[0]
end
watch('src/(.*)\.php') do |md|
clear
testpath = md[1] + "Test.php"
status = phpunit "test/#{testpath}"
notify status, testpath
end