Test with Rails HEAD

This commit is contained in:
Gleb Mazovetskiy 2015-09-27 13:51:03 +01:00
parent fdf1c797d4
commit ab2a21db3f
5 changed files with 60 additions and 1 deletions

View File

@ -2,6 +2,7 @@ language: ruby
rvm:
- 2.1.5
gemfile:
- test/gemfiles/rails_head.gemfile
- test/gemfiles/sass_3_3.gemfile
- test/gemfiles/sass_3_4.gemfile
- test/gemfiles/sass_head.gemfile
@ -9,6 +10,7 @@ before_install:
- "npm install"
matrix:
allow_failures:
- gemfile: test/gemfiles/rails_head.gemfile
- gemfile: test/gemfiles/sass_head.gemfile
notifications:
slack: heybb:3n88HHilXn76ji9vV4gL819Y

View File

@ -10,6 +10,36 @@ Rake::TestTask.new do |t|
t.verbose = true
end
desc 'Test all Gemfiles from test/*.gemfile'
task :test_all_gemfiles do
require 'term/ansicolor'
require 'pty'
require 'shellwords'
cmd = 'bundle install --quiet && bundle exec rake --trace'
statuses = Dir.glob('./test/gemfiles/*{[!.lock]}').map do |gemfile|
env = {'BUNDLE_GEMFILE' => gemfile}
cmd_with_env = " (#{env.map { |k, v| "export #{k}=#{Shellwords.escape v}" } * ' '}; #{cmd})"
$stderr.puts Term::ANSIColor.cyan("Testing\n#{cmd_with_env}")
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
[$? && $?.exitstatus == 0, cmd_with_env]
end
failed_cmds = statuses.reject(&:first).map { |(_status, cmd_with_env)| cmd_with_env }
if failed_cmds.empty?
$stderr.puts Term::ANSIColor.green('Tests pass with all gemfiles')
else
$stderr.puts Term::ANSIColor.red("Failing (#{failed_cmds.size} / #{statuses.size})\n#{failed_cmds * "\n"}")
exit 1
end
end
desc 'Dumps output to a CSS file for testing'
task :debug do
require 'sass'

View File

@ -12,13 +12,13 @@ end
require 'slim-rails'
require 'jquery-rails'
require 'compass'
require 'bootstrap-sass'
require 'uglifier'
module Dummy
class Application < Rails::Application
config.assets.enabled = true if config.assets.respond_to?(:enabled)
config.assets.precompile += %w( application.css application.js )
config.to_prepare do
if ENV['VERBOSE']
STDERR.puts "Loaded Rails #{Rails::VERSION::STRING}, Sprockets #{Sprockets::VERSION}",

View File

@ -0,0 +1,17 @@
source "https://rubygems.org"
gem 'actionpack', github: 'rails/rails'
gem 'activesupport', github: 'rails/rails'
# Required git dependencies as per https://github.com/rails/rails/blob/51211a94bd7a34d80f2412a7f94fefe7366647a5/Gemfile:
gem 'rack', github: 'rack/rack'
gem 'sprockets', github: 'rails/sprockets'
gem 'sprockets-rails', github: 'rails/sprockets-rails'
gem 'sass-rails', github: 'rails/sass-rails', branch: 'master'
gem 'autoprefixer-rails', github: 'ai/autoprefixer-rails'
gem 'compass', '~> 1.0.1', require: false
gemspec path: '../../'

View File

@ -14,4 +14,14 @@ module Kernel
run.call
end
end
def silence_stream(stream)
old_stream = stream.dup
stream.reopen(File::NULL)
stream.sync = true
yield
ensure
stream.reopen(old_stream)
old_stream.close
end unless method_defined?(:silence_stream)
end