Ruby, watchr gem
, , , fire/directory script, , , .
autotest.rb:
watch("<PROJECT_DIR_PATH>/(.*).<FILE_EXTENSION_PHP>") do |match|
run_test %{<PROJECT_DIR_PATH>/Tests/#{match[1]}Test.php}
end
watch("<PROJECT_DIR_PATH>/Tests/.*Test.php") do |match|
run_test match[0]
end
def run_test(file)
unless File.exist?(file)
puts "#{file} does not exist"
return
end
puts "Running #{file}"
result = `phpunit #{file}`
puts result
end
Thus, this wil matches all PHP or any other extension files and runs RegEx against the file name, and if there is a match, for example /Project/Tests/ClassNameTest.php, it will run the test, otherwise it just ends with massage. For convenience, you can configure this to send error messages to predefined emails.
source
share