Return-Path: X-Original-To: apmail-deltacloud-dev-archive@www.apache.org Delivered-To: apmail-deltacloud-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 107A497D1 for ; Wed, 25 Jul 2012 14:21:25 +0000 (UTC) Received: (qmail 96589 invoked by uid 500); 25 Jul 2012 14:21:24 -0000 Delivered-To: apmail-deltacloud-dev-archive@deltacloud.apache.org Received: (qmail 96465 invoked by uid 500); 25 Jul 2012 14:21:24 -0000 Mailing-List: contact dev-help@deltacloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltacloud.apache.org Delivered-To: mailing list dev@deltacloud.apache.org Received: (qmail 96157 invoked by uid 99); 25 Jul 2012 14:21:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Jul 2012 14:21:18 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mfojtik@redhat.com designates 209.132.183.28 as permitted sender) Received: from [209.132.183.28] (HELO mx1.redhat.com) (209.132.183.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Jul 2012 14:21:10 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6PEKmhO000633 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 25 Jul 2012 10:20:50 -0400 Received: from dhcp-29-121.brq.redhat.com (dhcp-29-121.brq.redhat.com [10.34.29.121]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q6PDMIZ1021114 for ; Wed, 25 Jul 2012 09:22:38 -0400 From: mfojtik@redhat.com To: dev@deltacloud.apache.org Subject: [PATCH core 7/7] Core: Reorganized unit tests and coverage generation Date: Wed, 25 Jul 2012 15:23:20 +0200 Message-Id: <1343222600-52146-7-git-send-email-mfojtik@redhat.com> In-Reply-To: <1343222600-52146-1-git-send-email-mfojtik@redhat.com> References: <1343222600-52146-1-git-send-email-mfojtik@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Virus-Checked: Checked by ClamAV on apache.org From: Michal Fojtik 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 Signed-off-by: Michal fojtik --- server/.simplecov | 11 ++++++++ server/Rakefile | 65 ++++++++++++++++++++++++++++++++++--------- server/tests/test_helper.rb | 13 --------- 3 files changed, 63 insertions(+), 26 deletions(-) create mode 100644 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 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 + + 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 -- 1.7.10.2