forked from ai/autoprefixer-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
55 lines (48 loc) · 1.29 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
# frozen_string_literal: true
require "rubygems"
require "bundler/setup"
Bundler::GemHelper.install_tasks
require "standard/rake"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new
task default: [:spec, "standard:fix"]
task :clobber_package do
begin
rm_r "pkg"
rescue StandardError
nil
end
end
desc "Delete all generated files"
task clobber: [:clobber_package]
desc "Test all Gemfiles from spec/*.gemfile"
task :test_all do
require "pty"
require "shellwords"
cmd = "bundle update && bundle exec rake --trace"
statuses = Dir.glob("./sprockets*.gemfile").map do |gemfile|
Bundler.with_clean_env do
env = { "BUNDLE_GEMFILE" => gemfile }
warn "Testing #{File.basename(gemfile)}:"
warn " export BUNDLE_GEMFILE=#{gemfile}"
warn " #{cmd}"
PTY.spawn(env, cmd) do |r, _w, pid|
begin
r.each_line { |l| puts l }
rescue Errno::EIO
# Errno:EIO error means that the process has finished giving output.
ensure
::Process.wait pid
end
end
[$CHILD_STATUS&.exitstatus&.zero?, gemfile]
end
end
failed = statuses.reject(&:first).map(&:last)
if failed.empty?
warn "✓ Tests pass with all #{statuses.size} gemfiles"
else
warn "❌ FAILING #{failed * "\n"}"
exit 1
end
end