-
Notifications
You must be signed in to change notification settings - Fork 9
/
Rakefile
112 lines (89 loc) · 2.78 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# frozen_string_literal: true
require 'fileutils'
require 'rake/clean'
require 'shellwords'
require 'rubocop/rake_task'
require_relative 'lib/jekyll/minibundle/version'
def run_jekyll_in_fixture_site(command)
Dir.chdir('test/fixture/site')
FileUtils.rm_rf('_site')
minifier_cmd = File.expand_path('test/fixture/site/_bin/remove_comments', File.dirname(__FILE__))
env = {
'JEKYLL_MINIBUNDLE_CMD_JS' => minifier_cmd,
'JEKYLL_MINIBUNDLE_CMD_CSS' => minifier_cmd,
'RUBYLIB' => File.expand_path('lib', File.dirname(__FILE__))
}
jekyll_cmd = "jekyll #{command}"
sh env, jekyll_cmd
end
desc <<~TEXT
Run benchmarks. Supported options from environment variables:
BM=<benchmark_suite_path>
TEXT
task :benchmark do
run_single_bm = ENV.key?('BM')
bm_sources =
if run_single_bm
[ENV.fetch('BM')]
else
Dir['benchmark/*_bm.rb']
end
bm_sources.each do |bm_source|
sh "ruby -I lib #{bm_source}"
end
end
namespace :gem do
gem_name = 'jekyll-minibundle'
CLEAN.include "#{gem_name}-*.gem"
desc 'Package the software as a gem'
task build: :default do
sh "gem build #{gem_name}.gemspec"
end
desc 'Install the software as a gem'
task :install do
sh "gem install #{gem_name}-#{Jekyll::Minibundle::VERSION}.gem"
end
desc 'Uninstall the gem'
task uninstall: :clean do
sh "gem uninstall #{gem_name}"
end
end
desc <<~TEXT
Run tests. Supported options from environment variables:
TEST=<test_suite_path>
NAME=<test_name_pattern>
DEBUG=1 Require Pry, PP, enable warnings
SEED=n Set the random seed
TEST_OPTS='-v' Enable other minitest options
TEXT
task :test do
run_selected_or_all =
if ENV.key?('TEST')
test_file = ENV['TEST']
minitest_opts = "#{ENV.key?('NAME') ? "-n #{ENV['NAME']} " : ''}#{ENV.fetch('TEST_OPTS', '')}"
"#{test_file} #{minitest_opts}"
else
eval = "-e 'ARGV.each { |f| require \"#{Dir.pwd}/test/\#{f}\" }'"
requirable_files =
Dir['test/{unit,integration}/*_test.rb']
.map { |file| %r{^test/(.+)\.rb$}.match(file)[1] }
.shelljoin
"#{eval} #{requirable_files}"
end
ruby_opts = "-I lib#{ENV['DEBUG'] ? ' -w -rpp -rpry' : ''}"
puts "Jekyll version: #{Gem::Specification.find_by_name('jekyll').version}"
sh "ruby #{ruby_opts} #{run_selected_or_all}"
end
namespace :fixture do
CLOBBER.include 'test/fixture/site/_site', 'test/fixture/site/.jekyll-cache'
desc 'Generate fixture site (tests use it, this task allows manual inspection)'
task :build do
run_jekyll_in_fixture_site('build')
end
desc 'Generate fixture site in watch mode'
task :watch do
run_jekyll_in_fixture_site('build --watch')
end
end
RuboCop::RakeTask.new
task default: %i[rubocop test]