Project

General

Profile

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

runcible / Rakefile @ 4376f477

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

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

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

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

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

    
34
        test_runner = PulpMiniTestRunner.new
35

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

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

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

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

    
63
desc "Clears out all cassette files"
64
task :clear_cassettes do
65
  clear_cassettes
66
end
67

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