@@ -8,16 +8,49 @@ Rake::TestTask.new do |t|
88 t . verbose = true
99end
1010
11+ desc 'Test all Gemfiles from test/*.gemfile'
12+ task :test_all_gemfiles do
13+ require 'term/ansicolor'
14+ require 'pty'
15+ require 'shellwords'
16+ cmd = 'bundle install --quiet && bundle exec rake --trace'
17+ statuses = Dir . glob ( './test/gemfiles/*{[!.lock]}' ) . map do |gemfile |
18+ env = { 'BUNDLE_GEMFILE' => gemfile }
19+ cmd_with_env = " (#{ env . map { |k , v | "export #{ k } =#{ Shellwords . escape v } " } * ' ' } ; #{ cmd } )"
20+ $stderr. puts Term ::ANSIColor . cyan ( "Testing\n #{ cmd_with_env } " )
21+ PTY . spawn ( env , cmd ) do |r , _w , pid |
22+ begin
23+ r . each_line { |l | puts l }
24+ rescue Errno ::EIO
25+ # Errno:EIO error means that the process has finished giving output.
26+ ensure
27+ ::Process . wait pid
28+ end
29+ end
30+ [ $? && $?. exitstatus == 0 , cmd_with_env ]
31+ end
32+ failed_cmds = statuses . reject ( &:first ) . map { |( _status , cmd_with_env ) | cmd_with_env }
33+ if failed_cmds . empty?
34+ $stderr. puts Term ::ANSIColor . green ( 'Tests pass with all gemfiles' )
35+ else
36+ $stderr. puts Term ::ANSIColor . red ( "Failing (#{ failed_cmds . size } / #{ statuses . size } )\n #{ failed_cmds * "\n " } " )
37+ exit 1
38+ end
39+ end
40+
1141desc 'Dumps output to a CSS file for testing'
1242task :debug do
1343 require 'sass'
1444 require './lib/bootstrap'
1545 require 'term/ansicolor'
46+ require 'autoprefixer-rails'
1647 path = Bootstrap . stylesheets_path
1748 %w( _bootstrap _bootstrap-flex _bootstrap-reboot _bootstrap-grid ) . each do |file |
1849 engine = Sass ::Engine . for_file ( "#{ path } /#{ file } .scss" , syntax : :scss , load_paths : [ path ] )
1950 out = File . join ( 'tmp' , "#{ file [ 1 ..-1 ] } .css" )
20- File . write ( out , engine . render )
51+ css = engine . render
52+ css = AutoprefixerRails . process ( css )
53+ File . write ( out , css )
2154 $stderr. puts Term ::ANSIColor . green "Compiled #{ out } "
2255 end
2356end
0 commit comments