diff --git a/Rakefile b/Rakefile index f106c8055..92c02f50f 100755 --- a/Rakefile +++ b/Rakefile @@ -33,6 +33,7 @@ require_relative "rake.d/extensions" $build_system_modules = {} $have_gtest = Dir.exists? 'lib/gtest' +$gtest_apps = [] require_relative "rake.d/config" require_relative "rake.d/helpers" @@ -544,12 +545,8 @@ task :clean do po/*.mo doc/guide/**/*.hhk } patterns += $applications + $tools.collect { |name| "src/tools/#{name}" } - verbose = ENV['V'].to_bool - patterns.collect { |pattern| FileList[pattern].to_a }.flatten.uniq.select { |file_name| File.exists? file_name }.each do |file_name| - puts " rm #{file_name}" if verbose - File.unlink file_name - end + remove_files_by_patters patterns if Dir.exists? $dependency_dir puts " rm -rf #{$dependency_dir}" if verbose @@ -585,6 +582,13 @@ namespace :clean do run "rm -f doc/man/*.html doc/man/*/*.html" end end + + desc "Remove compiled objects and programs in the unit test suite" + task :unittests do + patterns = %w{tests/unit/*.o tests/unit/*/*.o tests/unit/*.a tests/unit/*/*.a} + patterns += $gtest_apps.collect { |app| "tests/unit/#{app}/#{app}" } + remove_files_by_patters patterns + end end # Tests diff --git a/rake.d/gtest.rb b/rake.d/gtest.rb old mode 100644 new mode 100755 index 608115109..52aaefcfc --- a/rake.d/gtest.rb +++ b/rake.d/gtest.rb @@ -1,14 +1,14 @@ #!/usr/bin/env ruby -gtest_apps = %w{common propedit} +$gtest_apps = %w{common propedit} namespace :tests do desc "Build the unit tests" - task :unit => gtest_apps.collect { |app| "tests/unit/#{app}/#{app}" } + task :unit => $gtest_apps.collect { |app| "tests/unit/#{app}/#{app}" } desc "Build and run the unit tests" task :run_unit => 'tests:unit' do - gtest_apps.each { |app| run "./tests/unit/#{app}/#{app}" } + $gtest_apps.each { |app| run "./tests/unit/#{app}/#{app}" } end end @@ -37,7 +37,7 @@ $build_system_modules[:gtest] = { sources('tests/unit', :type => :dir). create - gtest_apps.each do |app| + $gtest_apps.each do |app| Application. new("tests/unit/#{app}/#{app}"). description("Build the unit tests executable for '#{app}'"). diff --git a/rake.d/helpers.rb b/rake.d/helpers.rb index 0747dc6fb..f1e44db5c 100644 --- a/rake.d/helpers.rb +++ b/rake.d/helpers.rb @@ -180,3 +180,12 @@ def adjust_to_poedit_style(in_name, out_name) File.unlink in_name end + +def remove_files_by_patters patterns + verbose = ENV['V'].to_bool + + patterns.collect { |pattern| FileList[pattern].to_a }.flatten.uniq.select { |file_name| File.exists? file_name }.each do |file_name| + puts " rm #{file_name}" if verbose + File.unlink file_name + end +end