Project

General

Profile

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

runcible / Rakefile @ master

1 243b30b6 Eric D Helms
#!/usr/bin/env rake
2 3e3ad61c Partha Aji
require 'bundler/gem_tasks'
3
require 'rake/testtask'
4 243b30b6 Eric D Helms
5 1c08f783 Justin Sherrill
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 8db5edf8 Eric D Helms
namespace :test do
13 3e3ad61c Partha Aji
  desc 'Runs the unit tests'
14 24595c26 Eric D. Helms
  Rake::TestTask.new :unit do |t|
15
    t.pattern = 'test/unit/test_*.rb'
16
  end
17
18 f9325ee8 Mike McCune
  [:resources, :extensions, :unit, :models].each do |task_name|
19 4f2ec2b8 Eric D. Helms
    desc "Runs the #{task_name} tests"
20
    task task_name do
21
      options = {}
22 24595c26 Eric D. Helms
23 4f2ec2b8 Eric D. Helms
      options[:mode]      = ENV['mode'] || 'none'
24
      options[:test_name] = ENV['test']
25
      options[:auth_type] = ENV['auth_type']
26
      options[:logging]   = ENV['logging']
27 24595c26 Eric D. Helms
28 4f2ec2b8 Eric D. Helms
      if !['new_episodes', 'all', 'none', 'once'].include?(options[:mode])
29 3e3ad61c Partha Aji
        puts 'Invalid test mode'
30 4f2ec2b8 Eric D. Helms
      else
31 3e3ad61c Partha Aji
        require './test/test_runner'
32 8db5edf8 Eric D Helms
33 4f2ec2b8 Eric D. Helms
        test_runner = PulpMiniTestRunner.new
34 24595c26 Eric D. Helms
35 4f2ec2b8 Eric D. Helms
        if options[:test_name]
36
          puts "Running tests for: #{options[:test_name]}"
37
        else
38 414f0ec7 Eric D. Helms
          puts "Running tests for: #{task_name}"
39 4f2ec2b8 Eric D. Helms
        end
40 db369a17 Eric D. Helms
41 d81cde6b David Davis
        clear_cassettes if options[:mode] == 'all' && options[:test_name].nil? && ENV['record'] != 'false'
42 4f2ec2b8 Eric D. Helms
        test_runner.run_tests(task_name, options)
43 3e3ad61c Partha Aji
        Rake::Task[:update_test_version].invoke if options[:mode] == 'all' && ENV['record'] != 'false'
44 4f2ec2b8 Eric D. Helms
      end
45 8db5edf8 Eric D Helms
    end
46
  end
47 243b30b6 Eric D Helms
end
48 db369a17 Eric D. Helms
49 3e3ad61c Partha Aji
desc 'Updats the version of Pulp tested against in README'
50 db369a17 Eric D. Helms
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 da1cf7ef Eric D. Helms
    replacement_string = "Latest Live Tested Version: **#{pulp_version}**"
57 db369a17 Eric D. Helms
    replace = text.gsub!(original_regex, replacement_string)
58
    file.puts replace
59
  end
60
end
61 c5817ea3 Eric D. Helms
62 3e3ad61c Partha Aji
desc 'Clears out all cassette files'
63 b43ba6f2 Eric D. Helms
task :clear_cassettes do
64 1c08f783 Justin Sherrill
  clear_cassettes
65 b43ba6f2 Eric D. Helms
end
66
67 3e3ad61c Partha Aji
desc 'Runs all tests'
68 b43ba6f2 Eric D. Helms
task :test do
69 414f0ec7 Eric D. Helms
  Rake::Task['test:unit'].invoke
70 f9325ee8 Mike McCune
  Rake::Task['test:models'].invoke
71 4f2ec2b8 Eric D. Helms
  Rake::Task['test:resources'].invoke
72
  Rake::Task['test:extensions'].invoke
73 b43ba6f2 Eric D. Helms
end
74 c4c2e79f David Davis
75
begin
76
  require 'rubocop/rake_task'
77
  RuboCop::RakeTask.new
78
rescue
79 3e3ad61c Partha Aji
  puts "Rubocop not loaded"
80 c4c2e79f David Davis
end