summaryrefslogtreecommitdiffstats
path: root/tasks/test.rake
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-04-08 17:59:24 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-04-08 17:59:24 +0200
commitd62833580889816914eebb61ffcfcb26496ea883 (patch)
treeb638b8d17b9d204a8bbb15eb88089f0b68a29c68 /tasks/test.rake
downloadffi-efl-d62833580889816914eebb61ffcfcb26496ea883.zip
ffi-efl-d62833580889816914eebb61ffcfcb26496ea883.tar.gz
initial commit
Diffstat (limited to 'tasks/test.rake')
-rw-r--r--tasks/test.rake41
1 files changed, 41 insertions, 0 deletions
diff --git a/tasks/test.rake b/tasks/test.rake
new file mode 100644
index 0000000..8257613
--- /dev/null
+++ b/tasks/test.rake
@@ -0,0 +1,41 @@
+# -*- coding: UTF-8 -*-
+#
+if test(?e, PROJ.test.file) or not PROJ.test.files.to_a.empty?
+require 'rake/testtask'
+
+namespace :test do
+
+ Rake::TestTask.new(:run) do |t|
+ t.libs = PROJ.libs
+ t.test_files = if test(?f, PROJ.test.file) then [PROJ.test.file]
+ else PROJ.test.files end
+ t.ruby_opts += PROJ.ruby_opts
+ t.ruby_opts += PROJ.test.opts
+ end
+
+ if HAVE_RCOV
+ desc 'Run rcov on the unit tests'
+ task :rcov => :clobber_rcov do
+ opts = PROJ.rcov.opts.dup << '-o' << PROJ.rcov.dir
+ opts = opts.join(' ')
+ files = if test(?f, PROJ.test.file) then [PROJ.test.file]
+ else PROJ.test.files end
+ files = files.join(' ')
+ sh "#{RCOV} #{files} #{opts}"
+ end
+
+ task :clobber_rcov do
+ rm_r 'coverage' rescue nil
+ end
+ end
+
+end # namespace :test
+
+desc 'Alias to test:run'
+task :test => 'test:run'
+
+task :clobber => 'test:clobber_rcov' if HAVE_RCOV
+
+end
+
+# EOF