-
Notifications
You must be signed in to change notification settings - Fork 30
/
Rakefile
executable file
·83 lines (69 loc) · 2.21 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env rake
require 'bundler/gem_tasks'
begin
require 'gemika/tasks'
rescue LoadError
puts 'Run `gem install gemika` for additional tasks'
end
task :default => 'matrix:tests'
namespace :matrix do
desc 'Run tests for a single row of the matrix'
task :single_test, [:gemfile, :ruby] do |_t, args|
gemfile = args[:gemfile]
ruby = args[:ruby]
if gemfile.nil? || ruby.nil?
warn 'Please state the Gemfile and Ruby version to be used for the Testrun!'
exit 1
else
success = run_tests(gemfile, ruby)
exit success ? 0 : 1
end
end
desc "Run all tests which are available for current Ruby (#{RUBY_VERSION})"
task :tests do
Gemika::Matrix.from_ci_config.each do |row|
run_tests(row.gemfile, row.ruby)
end
end
end
desc 'Update the "Steps" section of the README'
task :update_readme do
readme_path = 'README.md'
if Kernel.respond_to? :require_relative
require_relative './support/step_manager'
else
require 'support/step_manager'
end
readme = File.read(readme_path)
File.open(readme_path, 'w') do |file|
start_of_steps_section = readme =~ /^## Steps/
length_of_steps_section = readme[(start_of_steps_section+1)..-1] =~ /^##[^#]/
length_of_steps_section ||= readme.size - start_of_steps_section
step_documentation = StepManager.new('lib/spreewald').to_markdown
readme[start_of_steps_section, length_of_steps_section] = "## Steps\n\n#{step_documentation}"
file.write(readme)
end
system "git diff #{readme_path}"
puts '', '> Done (diff applied).'
end
def run_tests(gemfile, ruby)
directory = File.dirname(gemfile)
if directory.start_with?('tests')
# Run integration tests (uses embedded projects)
system(cucumber_command(directory, ruby))
else
# Run specs and integration tests for Spreewald binary
[
system("BUNDLE_GEMFILE=#{gemfile} bundle exec rspec"),
system("BUNDLE_GEMFILE=#{gemfile} bundle exec cucumber --publish-quiet"),
].all?
end
end
def cucumber_command(directory, ruby_version)
command = "cd #{directory} && BUNDLE_GEMFILE=Gemfile bundle exec cucumber --publish-quiet"
command << ' --no-strict-pending'
command
end
def warn(text)
puts "\e[31m#{text}\e[0m" # red text
end