Project

General

Profile

Download (2.15 KB) Statistics
| Branch: | Tag: | Revision:

runcible / Rakefile @ bf01400f

1
#!/usr/bin/env rake
2
require 'bundler/gem_tasks'
3
require 'rake/testtask'
4

    
5
def clear_cassettes
6
  `rm -rf test/fixtures/vcr_cassettes/*.yml`
7
  `rm -rf test/fixtures/vcr_cassettes/extensions/*.yml`
8
  `rm -rf test/fixtures/vcr_cassettes/support/*.yml`
9
  print "Cassettes cleared\n"
10
end
11

    
12
namespace :test do
13
  desc 'Runs the unit tests'
14
  Rake::TestTask.new :unit do |t|
15
    t.pattern = 'test/unit/test_*.rb'
16
  end
17

    
18
  [:resources, :extensions, :unit, :models].each do |task_name|
19
    desc "Runs the #{task_name} tests"
20
    task task_name do
21
      options = {}
22

    
23
      options[:mode]      = ENV['mode'] || 'none'
24
      options[:test_name] = ENV['test']
25
      options[:auth_type] = ENV['auth_type']
26
      options[:logging]   = ENV['logging']
27

    
28
      if !['new_episodes', 'all', 'none', 'once'].include?(options[:mode])
29
        puts 'Invalid test mode'
30
      else
31
        require './test/test_runner'
32

    
33
        test_runner = PulpMiniTestRunner.new
34

    
35
        if options[:test_name]
36
          puts "Running tests for: #{options[:test_name]}"
37
        else
38
          puts "Running tests for: #{task_name}"
39
        end
40

    
41
        clear_cassettes if options[:mode] == 'all' && options[:test_name].nil? && ENV['record'] != 'false'
42
        test_runner.run_tests(task_name, options)
43
        Rake::Task[:update_test_version].invoke if options[:mode] == 'all' && ENV['record'] != 'false'
44
      end
45
    end
46
  end
47
end
48

    
49
desc 'Updats the version of Pulp tested against in README'
50
task :update_test_version do
51
  text = File.open('README.md').read
52

    
53
  File.open('README.md', 'w+') do |file|
54
    original_regex = /Latest Live Tested Version: *.*/
55
    pulp_version = `rpm -q pulp-server`.strip
56
    replacement_string = "Latest Live Tested Version: **#{pulp_version}**"
57
    replace = text.gsub!(original_regex, replacement_string)
58
    file.puts replace
59
  end
60
end
61

    
62
desc 'Clears out all cassette files'
63
task :clear_cassettes do
64
  clear_cassettes
65
end
66

    
67
desc 'Runs all tests'
68
task :test do
69
  Rake::Task['test:unit'].invoke
70
  Rake::Task['test:models'].invoke
71
  Rake::Task['test:resources'].invoke
72
  Rake::Task['test:extensions'].invoke
73
end
74

    
75
begin
76
  require 'rubocop/rake_task'
77
  RuboCop::RakeTask.new
78
rescue
79
  puts "Rubocop not loaded"
80
end