This repository has been archived by the owner on Jun 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Rakefile
63 lines (55 loc) · 2.22 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#------------------------------------------------------------------#
# Gem Packaging Tasks
#------------------------------------------------------------------#
begin
require "bundler"
Bundler::GemHelper.install_tasks
rescue LoadError
# no bundler available
end
#------------------------------------------------------------------#
# Linter Tasks
#------------------------------------------------------------------#
begin
require "chefstyle"
require "rubocop/rake_task"
RuboCop::RakeTask.new(:lint) do |task|
task.options += ["--display-cop-names", "--no-color", "--parallel"]
end
rescue LoadError
puts "rubocop is not available. Install the rubocop gem to run the lint tests."
end
#------------------------------------------------------------------#
# Test Runner Tasks
#------------------------------------------------------------------#
require "rake/testtask"
namespace(:test) do
# This task template will make a task named 'test', and run
# the tests that it finds.
# Here, we split up the tests a bit, for the convenience
# of the developer.
desc "Run unit tests, to probe internal correctness"
Rake::TestTask.new(:unit) do |task|
task.libs << "test"
task.pattern = "test/unit/*_spec.rb"
task.warning = false
end
require "tmpdir"
desc "Run InSpec integration tests for check for interface changes"
Rake::TestTask.new(:inspec) do |task|
task.libs << "test"
tmp_dir = Dir.mktmpdir
sh("bundle exec gem build inspec-iggy.gemspec")
sh("bundle exec inspec plugin install inspec-iggy-*.gem --chef-license=accept")
sh("wget -O #{tmp_dir}/inspec-aws.tar.gz -nc --tries=10 https://github.com/inspec/inspec-aws/archive/v1.5.1.tar.gz")
sh("tar -C #{tmp_dir} -xzf #{tmp_dir}/inspec-aws.tar.gz")
sh("bundle exec inspec exec test/inspec --reporter=progress --input tmp_dir='#{tmp_dir}' resource_dir='#{tmp_dir}/inspec-aws-1.5.1'")
FileUtils.remove_dir(tmp_dir)
task.warning = false
end
end
# Define a 'run all the tests' task.
# You might think you'd want to depend on test:unit and test:functional,
# but if you do that and either has a failure, the latter won't execute.
desc "Run all tests"
task test: %i{test:unit test:inspec}