Commit 67eaa01aba6723c69f6cc7b2edb6c8796b3a572f
Committed by
Daniela Feitosa
1 parent
b6a3b701
Exists in
master
and in
8 other branches
Rake tasks for noosfero plugins' tests
This patch creates some tasks to run noosfero plugins' tests through rake. For further information take a look at: http://noosfero.org/Development/PluginsArchitecture#Tasks (ActionItem1996)
Showing
1 changed file
with
56 additions
and
0 deletions
Show diff stats
| @@ -0,0 +1,56 @@ | @@ -0,0 +1,56 @@ | ||
| 1 | +def define_task(test, plugins_folder='plugins', plugin = '*') | ||
| 2 | + test_files = Dir.glob(File.join(Rails.root, plugins_folder, plugin, 'test', test[:folder], '**', '*_test.rb')) | ||
| 3 | + desc 'Runs ' + (plugin != '*' ? plugin : 'plugins') + ' ' + test[:name] + ' tests' | ||
| 4 | + Rake::TestTask.new(test[:name].to_sym) do |t| | ||
| 5 | + t.test_files = test_files | ||
| 6 | + t.verbose = true | ||
| 7 | + end | ||
| 8 | +end | ||
| 9 | + | ||
| 10 | +namespace :test do | ||
| 11 | + namespace :noosfero_plugins do | ||
| 12 | + tasks = [ | ||
| 13 | + {:name => :available, :folder => 'plugins'}, | ||
| 14 | + {:name => :enabled, :folder => File.join('config', 'plugins')} | ||
| 15 | + ] | ||
| 16 | + tests = [ | ||
| 17 | + {:name => 'units', :folder => 'unit'}, | ||
| 18 | + {:name => 'functionals', :folder => 'functional'}, | ||
| 19 | + {:name => 'integration', :folder => 'integration'} | ||
| 20 | + ] | ||
| 21 | + | ||
| 22 | + tasks.each do |t| | ||
| 23 | + namespace t[:name] do | ||
| 24 | + tests.each do |test| | ||
| 25 | + define_task(test, t[:folder]) | ||
| 26 | + end | ||
| 27 | + end | ||
| 28 | + end | ||
| 29 | + | ||
| 30 | + plugins = Dir.glob(File.join(Rails.root, 'plugins', '*')).map {|path| File.basename(path)} | ||
| 31 | + | ||
| 32 | + plugins.each do |plugin_name| | ||
| 33 | + namespace plugin_name do | ||
| 34 | + tests.each do |test| | ||
| 35 | + define_task(test, 'plugins', plugin_name) | ||
| 36 | + end | ||
| 37 | + end | ||
| 38 | + | ||
| 39 | + dependencies = [] | ||
| 40 | + tests.each do |test| | ||
| 41 | + dependencies << plugin_name+':'+test[:name] | ||
| 42 | + end | ||
| 43 | + task plugin_name => dependencies | ||
| 44 | + end | ||
| 45 | + | ||
| 46 | + task :units => 'available:units' | ||
| 47 | + task :functionals => 'available:functionals' | ||
| 48 | + task :integration => 'available:integration' | ||
| 49 | + task :available => [:units, :functionals, :integration] | ||
| 50 | + task :enabled => ['enabled:units', 'enabled:functionals', 'enabled:integration'] | ||
| 51 | + | ||
| 52 | + end | ||
| 53 | + | ||
| 54 | + task :noosfero_plugins => 'noosfero_plugins:available' | ||
| 55 | + | ||
| 56 | +end |