Skip to content

Instantly share code, notes, and snippets.

@petRUShka
Created November 23, 2011 16:24
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 petRUShka/8f84f0361cfb3b216f83 to your computer and use it in GitHub Desktop.
Save petRUShka/8f84f0361cfb3b216f83 to your computer and use it in GitHub Desktop.
watchr for c\ccp files and unit testing with Google Test Frameforwk
ENV["WATCHR"] = "1"
system 'clear'
def run(cmd)
puts(cmd)
system(cmd)
end
def growl(result)
message = result ? "OK" : "FAILED"
growlnotify = `which notify-send`.chomp
title = "Watchr Test Results"
image = (result) ? ".watchr_images/passed.png" : ".watchr_images/failed.png"
options = %("#{title}" "#{message}" -i #{File.expand_path(image)})
system %(#{growlnotify} #{options} &)
end
watch( '(.+)(\.c|_test\.cpp|\.h)$' ) do |md|
result = run("g++ #{md[1]}_test.cpp #{md[1]}.c -lgtest_main -lgtest -pthread -o #{md[1]}_test && ./#{md[1]}_test")
growl result
puts ("\n\n")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment