deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [28/50] [abbrv] git commit: Core: Reorganized unit tests and coverage generation
Date Mon, 30 Jul 2012 14:29:17 GMT
Core: Reorganized unit tests and coverage generation

Since each driver test use it's own VCR settings, it is not
longer possible to load all tests at once with rake test.

For this this patch will split different test tasks so drivers
do no overide their VCR configurations


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/4c6dddc9
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/4c6dddc9
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/4c6dddc9

Branch: refs/heads/master
Commit: 4c6dddc93899b401fad819292d8f542ab8e8ac3f
Parents: 4cafebd
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Wed Jul 25 15:21:48 2012 +0200
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Thu Jul 26 13:25:28 2012 +0200

----------------------------------------------------------------------
 server/.simplecov           |   11 ++++++
 server/Rakefile             |   65 ++++++++++++++++++++++++++++++-------
 server/tests/test_helper.rb |   13 -------
 3 files changed, 63 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4c6dddc9/server/.simplecov
----------------------------------------------------------------------
diff --git a/server/.simplecov b/server/.simplecov
new file mode 100644
index 0000000..5feea29
--- /dev/null
+++ b/server/.simplecov
@@ -0,0 +1,11 @@
+SimpleCov.start do
+  command_name 'Minitest tests'
+  project_name 'Deltacloud API'
+  add_filter "tests/"
+  add_group 'Drivers', 'lib/deltacloud/drivers'
+  add_group 'Collections', 'lib/deltacloud/collections'
+  add_group 'Models', 'lib/deltacloud/models'
+  add_group 'Helpers', 'lib/deltacloud/helpers'
+  add_group 'Extensions', 'lib/deltacloud/core_ext'
+  add_group 'Sinatra', 'lib/sinatra'
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4c6dddc9/server/Rakefile
----------------------------------------------------------------------
diff --git a/server/Rakefile b/server/Rakefile
index 41eb7fa..c42ea4b 100644
--- a/server/Rakefile
+++ b/server/Rakefile
@@ -108,18 +108,57 @@ task :routes do
   end
 end
 
-Rake::TestTask.new do |t|
-  t.ruby_opts << '-r./tests/test_helper.rb'   # Load SimpleCov when COVERAGE=1 is set
-  unless RUBY_VERSION < '1.9.0'
-    t.loader = :testrb
+DRIVERS = [:mock, :ec2, :rhevm]
+
+desc 'Run all tests'
+task :test do
+
+  Rake::Task["mock:fixtures:reset"].invoke
+  puts "\n[ \033[1;37;mrake test:base\33[0m ]\n"
+  Rake::Task["test:base"].invoke
+  DRIVERS.each do |driver|
+    puts "\n[ \033[1;37;mrake drivers:#{driver}\33[0m ]\n"
+    Rake::Task["test:drivers:#{driver}"].invoke
   end
-  t.test_files = FileList[
-    'tests/helpers/**/*test.rb',              # Deltacloud extensions (core_ext) and other
helpers
-    'tests/drivers/base/*test.rb',            # Deltacloud drivers API tests
-    'tests/drivers/models/*test.rb',          # Deltacloud models tests
-    'tests/deltacloud/*test.rb',              # Deltacloud internal API tests
-    'tests/deltacloud/collections/*test.rb',  # Deltacloud collections
-    'tests/drivers/mock/*test.rb',            # Deltacloud Mock driver specific unit tests
-    'tests/drivers/ec2/*test.rb'              # Deltacloud EC2 driver specific unit tests
-  ]
 end
+
+namespace :test do
+
+  desc "Run all tests and generate code coverage report"
+  task :coverage do
+    ENV['COVERAGE'] = '1'
+    puts "[ \033[1;37;mCoverage report will be generated to server/coverage\33[0m ]\n\n"
+    Rake::Task["test"].invoke
+  end
+
+  namespace :drivers do
+
+    DRIVERS.each do |driver|
+      Rake::TestTask.new(driver) do |t|
+        t.ruby_opts << '-r./tests/test_helper.rb'   # Load SimpleCov when COVERAGE=1
is set
+        unless RUBY_VERSION < '1.9.0'
+          t.loader = :testrb
+        end
+        t.test_files = FileList["tests/drivers/#{driver}/*test.rb"]
+      end
+    end
+
+  end
+
+  Rake::TestTask.new(:base) do |t|
+    t.ruby_opts << '-r./tests/test_helper.rb'   # Load SimpleCov when COVERAGE=1 is
set
+    unless RUBY_VERSION < '1.9.0'
+      t.loader = :testrb
+    end
+    t.test_files = FileList[
+      'tests/helpers/core_ext/*test.rb',        # Deltacloud extensions (core_ext) and other
helpers
+      'tests/drivers/base/*test.rb',            # Deltacloud drivers API tests
+      'tests/drivers/models/*test.rb',          # Deltacloud models tests
+      'tests/deltacloud/*test.rb',              # Deltacloud internal API tests
+      'tests/deltacloud/collections/*test.rb',  # Deltacloud collections
+    ]
+  end
+
+end
+
+

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4c6dddc9/server/tests/test_helper.rb
----------------------------------------------------------------------
diff --git a/server/tests/test_helper.rb b/server/tests/test_helper.rb
index 5aed571..0b40610 100644
--- a/server/tests/test_helper.rb
+++ b/server/tests/test_helper.rb
@@ -2,22 +2,9 @@ require 'pp'
 
 ENV['RACK_ENV'] = 'test'
 
-%x[rake mock:fixtures:reset]
-
 if ENV['COVERAGE']
   begin
     require 'simplecov'
-    SimpleCov.start do
-      command_name 'Minitest tests'
-      project_name 'Deltacloud API'
-      add_filter "tests/"
-      add_group 'Drivers', 'lib/deltacloud/drivers'
-      add_group 'Collections', 'lib/deltacloud/collections'
-      add_group 'Models', 'lib/deltacloud/models'
-      add_group 'Helpers', 'lib/deltacloud/helpers'
-      add_group 'Extensions', 'lib/deltacloud/core_ext'
-      add_group 'Sinatra', 'lib/sinatra'
-    end
   rescue LoadError
     warn "To generate code coverage you need to install 'simplecov' (gem install simplecov
OR bundle)"
   end


Mime
View raw message