-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
66 lines (60 loc) · 1.58 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
64
65
66
require "pathname"
root_dir = Pathname.new(__FILE__).dirname
integration_test_dir = root_dir + "tests" + "integration"
integration_test_dirs = Pathname.new(integration_test_dir)
.children.select(&:directory?)
task default: %w[test]
desc "test kitchen test and integration test"
task test: ["kitchen:test", "integration:test"]
namespace :kitchen do
desc "run test-kitchen"
task :test do
begin
puts "running kitchen test"
sh "kitchen test"
ensure
sh "kitchen destroy"
end
end
end
# rubocop:disable Metrics/BlockLength
namespace :integration do
desc "run all tests"
task :test do
integration_test_dirs.each do |d|
rakefile = d + "Rakefile"
if rakefile.exist? && rakefile.file?
Dir.chdir(d) do
puts format("entering to %<directory>s", directory: d)
begin
puts "running rake"
sh "rake"
ensure
sh "rake clean"
end
end
else
puts "Rakefile does not exist, skipping"
end
end
end
desc "clean after test"
task :clean do
integration_test_dirs.each do |d|
rakefile = d + "Rakefile"
next unless rakefile.exist? && rakefile.file?
Dir.chdir(d) do
puts format("entering to %<directory>s", directory: d)
begin
puts "running rake clean"
sh "rake clean"
rescue StandardError => e
puts "rake clean clean failed:"
puts e.message
puts e.backtrace.inspect
end
end
end
end
end
# rubocop:enable Metrics/BlockLength