You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by do...@apache.org on 2013/10/09 12:51:35 UTC

svn commit: r1530559 - in /buildr/trunk: lib/buildr.rb lib/buildr/core/application.rb lib/buildr/core/cc.rb lib/buildr/core/console.rb lib/buildr/core/progressbar.rb spec/core/console_spec.rb

Author: donaldp
Date: Wed Oct  9 10:51:34 2013
New Revision: 1530559

URL: http://svn.apache.org/r1530559
Log:
Introduce a console class into buildr that will eventually replace the requirement on the Highline dependency. 

The highline dependency is used for interacting with the user at the console and coloring the output. Unfortunately there has been significant issues trying to get it to work consistently across platforms and across ruby implementations. 
  
The first step is to replace usage of the coloring functions with custom code simplified for our very specific needs.

Added:
    buildr/trunk/lib/buildr/core/console.rb
    buildr/trunk/spec/core/console_spec.rb
      - copied, changed from r1530200, buildr/trunk/spec/core/application_spec.rb
Modified:
    buildr/trunk/lib/buildr.rb
    buildr/trunk/lib/buildr/core/application.rb
    buildr/trunk/lib/buildr/core/cc.rb
    buildr/trunk/lib/buildr/core/progressbar.rb

Modified: buildr/trunk/lib/buildr.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr.rb?rev=1530559&r1=1530558&r2=1530559&view=diff
==============================================================================
--- buildr/trunk/lib/buildr.rb (original)
+++ buildr/trunk/lib/buildr.rb Wed Oct  9 10:51:34 2013
@@ -28,7 +28,6 @@ autoload :YAML, 'yaml'
 autoload :REXML, 'rexml/document'
 autoload :XmlSimple, 'xmlsimple'
 autoload :Builder, 'builder' # A different kind of buildr, one we use to create XML.
-require 'highline/import'
 autoload :RSpec, 'rspec'
 require 'erb'
 require 'find'
@@ -39,6 +38,7 @@ require 'orderedhash'
 require 'securerandom'
 
 require 'buildr/core/util'
+require 'buildr/core/console'
 require 'buildr/core/common'
 require 'buildr/core/application'
 require 'buildr/core/jrebel'

Modified: buildr/trunk/lib/buildr/core/application.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/core/application.rb?rev=1530559&r1=1530558&r2=1530559&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/core/application.rb (original)
+++ buildr/trunk/lib/buildr/core/application.rb Wed Oct  9 10:51:34 2013
@@ -242,7 +242,7 @@ module Buildr
             real << ('%ih' % (elapsed / 3600)) if elapsed >= 3600
             real << ('%im' % ((elapsed / 60) % 60)) if elapsed >= 60
             real << ('%.3fs' % (elapsed % 60))
-            puts $terminal.color("Completed in #{real.join}", :green)
+            puts Buildr::Console.color("Completed in #{real.join}", :green)
           end
           # On OS X this will load Cocoa and Growl which takes half a second we
           # don't want to measure, so put this after the console message.
@@ -537,7 +537,7 @@ module Buildr
         # Exit silently with current status
         exit(ex.status)
       rescue OptionParser::ParseError => ex
-        $stderr.puts $terminal.color(ex.message, :red)
+        $stderr.puts Buildr::Console.color(ex.message, :red)
         exit(1)
       rescue Exception => ex
         ex_msg = ex.class.name == "Exception" ? ex.message : "#{ex.class.name} : #{ex.message}"
@@ -545,11 +545,11 @@ module Buildr
         build_failed(title, message, ex)
         # Exit with error message
         $stderr.puts "Buildr aborted!"
-        $stderr.puts $terminal.color(ex_msg, :red)
+        $stderr.puts Buildr::Console.color(ex_msg, :red)
         if options.trace
           $stderr.puts ex.backtrace.join("\n")
         else
-          $stderr.puts ex.backtrace.select { |str| str =~ /#{rakefile}/ }.map { |line| $terminal.color(line, :red) }.join("\n") if rakefile
+          $stderr.puts ex.backtrace.select { |str| str =~ /#{rakefile}/ }.map { |line| Buildr::Console.color(line, :red) }.join("\n") if rakefile
           $stderr.puts "(See full trace by running task with --trace)"
         end
         exit(1)
@@ -597,29 +597,17 @@ module Buildr
 
 end
 
-
-# Add a touch of color when available and running in terminal.
-HighLine.use_color = false
-if $stdout.isatty
-  begin
-    require 'Win32/Console/ANSI' if RbConfig::CONFIG['host_os'] =~ /mswin|win32|dos|cygwin|mingw/i
-    HighLine.use_color = true
-  rescue LoadError
-  end
-end
-
-
 alias :warn_without_color :warn
 
 # Show warning message.
 def warn(message)
-  warn_without_color $terminal.color(message.to_s, :blue) if verbose
+  warn_without_color Buildr::Console.color(message.to_s, :blue) if verbose
 end
 
 # Show error message.  Use this when you need to show an error message and not throwing
 # an exception that will stop the build.
 def error(message)
-  puts $terminal.color(message.to_s, :red)
+  puts Buildr::Console.color(message.to_s, :red)
 end
 
 # Show optional information.  The message is printed only when running in verbose

Modified: buildr/trunk/lib/buildr/core/cc.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/core/cc.rb?rev=1530559&r1=1530558&r2=1530559&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/core/cc.rb (original)
+++ buildr/trunk/lib/buildr/core/cc.rb Wed Oct  9 10:51:34 2013
@@ -47,7 +47,7 @@ module Buildr #:nodoc:
         each_project { |p| p.test.compile.invoke }
         build_completed(project)
       rescue Exception => ex
-        $stderr.puts $terminal.color(ex.message, :red)
+        $stderr.puts Buildr::Console.color(ex.message, :red)
         $stderr.puts
 
         build_failed(project, ex)
@@ -108,12 +108,12 @@ module Buildr #:nodoc:
             each_project { |p| p.test.compile.invoke }
             build_completed(project)
           rescue Exception => ex
-            $stderr.puts $terminal.color(ex.message, :red)
+            $stderr.puts Buildr::Console.color(ex.message, :red)
             build_failed(project, ex)
             successful = false
           end
 
-          puts $terminal.color("Build complete", :green) if successful
+          puts Buildr::Console.color("Build complete", :green) if successful
         end
       end
     end

Added: buildr/trunk/lib/buildr/core/console.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/core/console.rb?rev=1530559&view=auto
==============================================================================
--- buildr/trunk/lib/buildr/core/console.rb (added)
+++ buildr/trunk/lib/buildr/core/console.rb Wed Oct  9 10:51:34 2013
@@ -0,0 +1,73 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+module Buildr #nodoc
+
+  # A utility class that helps with colorizing output for interactive shells where appropriate
+  class Console
+    class << self
+      def use_color
+        @use_color.nil? ? false : @use_color
+      end
+
+      def use_color=(use_color)
+        if Buildr::Util.win_os? && use_color
+          begin
+            require 'Win32/Console/ANSI'
+          rescue LoadError
+            return
+          end
+        end
+        @use_color = use_color
+      end
+
+      # Emit message with color at the start of the message and the clear color command at the end of the sequence.
+      def color(message, color)
+        raise "Unknown color #{color.inspect}" unless [:green, :red, :blue].include?(color)
+        return message unless use_color
+        constants = {:green => "\e[32m", :red => "\e[31m", :blue => "\e[34m"}
+        "#{constants[color]}#{message}\e[0m"
+      end
+
+      # Return the [rows, columns] of a console or nil if unknown
+      def console_dimensions
+        begin
+          if Buildr::Util.win_os?
+            Win32::Console.new(Win32::Console::STD_OUTPUT_HANDLE).MaxWindow
+          elsif $stdout.isatty
+            if /solaris/ =~ RUBY_PLATFORM and
+              `stty` =~ /\brows = (\d+).*\bcolumns = (\d+)/
+              [$2, $1].map { |c| x.to_i }
+            else
+              `stty size 2> /dev/null`.split.map { |x| x.to_i }.reverse
+            end
+          else
+            nil
+          end
+        rescue => e
+          nil
+        end
+      end
+
+      # Return the number of columns in console or nil if unknown
+      def output_cols
+        d = console_dimensions
+        d ? d[0] : nil
+      end
+    end
+  end
+end
+
+Buildr::Console.use_color = $stdout.isatty

Modified: buildr/trunk/lib/buildr/core/progressbar.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/core/progressbar.rb?rev=1530559&r1=1530558&r2=1530559&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/core/progressbar.rb (original)
+++ buildr/trunk/lib/buildr/core/progressbar.rb Wed Oct  9 10:51:34 2013
@@ -23,7 +23,7 @@ class ProgressBar
     end
 
     def width
-      @width ||= $terminal.output_cols || 0
+      @width ||= Buildr::Console.output_cols || 0
     end
 
   end

Copied: buildr/trunk/spec/core/console_spec.rb (from r1530200, buildr/trunk/spec/core/application_spec.rb)
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/core/console_spec.rb?p2=buildr/trunk/spec/core/console_spec.rb&p1=buildr/trunk/spec/core/application_spec.rb&r1=1530200&r2=1530559&rev=1530559&view=diff
==============================================================================
--- buildr/trunk/spec/core/application_spec.rb (original)
+++ buildr/trunk/spec/core/console_spec.rb Wed Oct  9 10:51:34 2013
@@ -13,566 +13,54 @@
 # License for the specific language governing permissions and limitations under
 # the License.
 
-
 require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
 
+describe Buildr::Console do
 
-describe Buildr::Application do
-
-  describe 'home_dir' do
-    it 'should point to ~/.buildr' do
-      Buildr.application.home_dir.should eql(File.expand_path('.buildr', ENV['HOME']))
-    end
-
-    it 'should point to existing directory' do
-      File.directory?(Buildr.application.home_dir).should be_true
-    end
-  end
-
-  describe '#run' do
-    it 'should execute *_load methods in order' do
-      order = [:load_gems, :load_artifact_ns, :load_tasks, :raw_load_buildfile]
-      order.each { |method| Buildr.application.should_receive(method).ordered }
-      Buildr.application.stub(:exit) # With this, shows the correct error instead of SystemExit.
-      Buildr.application.run
-    end
-
-    it 'should load imports after loading buildfile' do
-      method = Buildr.application.method(:raw_load_buildfile)
-      Buildr.application.should_receive(:raw_load_buildfile) do
-        Buildr.application.should_receive(:load_imports)
-        method.call
-      end
-      Buildr.application.stub(:exit) # With this, shows the correct error instead of SystemExit.
-      Buildr.application.run
-    end
+  describe 'console_dimensions' do
 
-    it 'should evaluate all projects after loading buildfile' do
-      Buildr.application.should_receive(:load_imports) do
-        Buildr.should_receive(:projects)
-      end
-      Buildr.application.stub(:exit) # With this, shows the correct error instead of SystemExit.
-      Buildr.application.run
+    it 'should return a value' do
+      Buildr::Console.console_dimensions.should_not be_nil
     end
   end
 
-  describe 'environment' do
-    it 'should return value of BUILDR_ENV' do
-      ENV['BUILDR_ENV'] = 'qa'
-      Buildr.application.environment.should eql('qa')
-    end
-
-    it 'should default to development' do
-      Buildr.application.environment.should eql('development')
-    end
-
-    it 'should set environment name from -e argument' do
-      ARGV.push('-e', 'test')
-      Buildr.application.send(:handle_options)
-      Buildr.application.environment.should eql('test')
-      ENV['BUILDR_ENV'].should eql('test')
-    end
-
-    it 'should be echoed to user' do
-      write 'buildfile'
-      ENV['BUILDR_ENV'] = 'spec'
-      Buildr.application.send(:handle_options)
-      lambda { Buildr.application.send :load_buildfile }.should show(%r{(in .*, spec)})
-    end
-  end
-
-  describe 'options' do
-    it "should have 'tasks' as the sole default rakelib" do
-      Buildr.application.send(:handle_options)
-      Buildr.application.options.rakelib.should == ['tasks']
-    end
-
-    it 'should show the version when prompted with -V' do
-      ARGV.push('-V')
-      test_exit(0) { Buildr.application.send(:handle_options) }.should show(/Buildr #{Buildr::VERSION}.*/)
-    end
-
-    it 'should show the version when prompted with --version' do
-      ARGV.push('--version')
-      test_exit(0) { Buildr.application.send(:handle_options) }.should show(/Buildr #{Buildr::VERSION}.*/)
-    end
-
-    it 'should enable tracing with --trace' do
-      ARGV.push('--trace')
-      Buildr.application.send(:handle_options)
-      Buildr.application.options.trace.should == true
-    end
-
-    it 'should enable tracing of [:foo, :bar] categories with --trace=foo,bar' do
-      ARGV.push('--trace=foo,bar')
-      Buildr.application.send(:handle_options)
-      Buildr.application.options.trace.should == true
-      Buildr.application.options.trace_categories.should == [:foo, :bar]
-      trace?(:foo).should == true
-      trace?(:not).should == false
-    end
-
-    it 'should enable tracing for all categories with --trace=all' do
-      ARGV.push('--trace=all')
-      Buildr.application.send(:handle_options)
-      Buildr.application.options.trace.should == true
-      Buildr.application.options.trace_all.should == true
-      trace?(:foo).should == true
-    end
+  describe 'color' do
 
-  end
-
-  describe 'gems' do
-    before do
-      class << Buildr.application
-        public :load_gems
+    describe 'when use_color is true' do
+      before do
+        Buildr::Console.use_color = true
       end
-    end
-
-    def load_with_yaml
-      write 'build.yaml', <<-YAML
-        gems:
-        - rake
-        - rspec ~> 2.9.0
-      YAML
-      Buildr.application.should_receive(:listed_gems).and_return([[Gem.loaded_specs['rspec'],Gem.loaded_specs['rake']],[]])
-      Buildr.application.load_gems
-    end
-
-    it 'should return empty array if no gems specified' do
-      Buildr.application.load_gems
-      Buildr.application.gems.should be_empty
-    end
-
-    it 'should return one entry for each gem specified in buildr.yaml' do
-      load_with_yaml
-      Buildr.application.gems.size.should be(2)
-    end
-
-    it 'should return a Gem::Specification for each installed gem' do
-      load_with_yaml
-      Buildr.application.gems.each { |gem| gem.should be_kind_of(Gem::Specification) }
-    end
-
-    it 'should parse Gem name correctly' do
-      load_with_yaml
-      Buildr.application.gems.map(&:name).should include('rspec', 'rake')
-    end
-
-    it 'should find installed version of Gem' do
-      load_with_yaml
-      Buildr.application.gems.each { |gem| gem.version.should eql(Gem.loaded_specs[gem.name].version) }
-    end
-  end
 
-  describe 'load_gems' do
-    before do
-      class << Buildr.application
-        public :load_gems
-      end
-      @spec = Gem::Specification.new do |spec|
-        spec.name = 'buildr-foo'
-        spec.version = '1.2'
+      it 'should emit red code when asked' do
+        Buildr::Console.color('message', :red).should eql("\e[31mmessage\e[0m")
       end
-      $stdout.stub(:isatty).and_return(true)
-    end
-
-    it 'should do nothing if no gems specified' do
-      lambda { Buildr.application.load_gems }.should_not raise_error
-    end
-
-    it 'should install nothing if specified gems already installed' do
-      Buildr.application.should_receive(:listed_gems).and_return([[Gem.loaded_specs['rspec']],[]])
-      Util.should_not_receive(:ruby)
-      lambda { Buildr.application.load_gems }.should_not raise_error
-    end
-
-    it 'should fail if required gem not installed' do
-      Buildr.application.should_receive(:listed_gems).and_return([[],[Gem::Dependency.new('buildr-foo', '>=1.1')]])
-      lambda { Buildr.application.load_gems }.should raise_error(LoadError, /cannot be found/i)
-    end
-
-    it 'should load previously installed gems' do
-      Gem.loaded_specs['rspec'].should_receive(:activate)
-      Buildr.application.should_receive(:listed_gems).and_return([[Gem.loaded_specs['rspec']],[]])
-      #Buildr.application.should_receive(:gem).with('rspec', Gem.loaded_specs['rspec'].version.to_s)
-      Buildr.application.load_gems
-    end
-
-    it 'should default to >=0 version requirement if not specified' do
-      write 'build.yaml', 'gems: buildr-foo'
-      should_attempt_to_load_dependency(Gem::Dependency.new('buildr-foo', '>= 0'))
-    end
-
-    it 'should parse exact version requirement' do
-      write 'build.yaml', 'gems: buildr-foo 2.5'
-      should_attempt_to_load_dependency(Gem::Dependency.new('buildr-foo', '=2.5'))
-    end
-
-    it 'should parse range version requirement' do
-      write 'build.yaml', 'gems: buildr-foo ~>2.3'
-      should_attempt_to_load_dependency(Gem::Dependency.new('buildr-foo', '~>2.3'))
-    end
-
-    it 'should parse multiple version requirements' do
-      write 'build.yaml', 'gems: buildr-foo >=2.0 !=2.1'
-      should_attempt_to_load_dependency(Gem::Dependency.new('buildr-foo', ['>=2.0', '!=2.1']))
-    end
-
-    def should_attempt_to_load_dependency(dep)
-      missing_gems = Buildr.application.send(:listed_gems)[1]
-      missing_gems.size.should eql(1)
-      missing_gems[0].eql?(dep)
-    end
-  end
 
-  describe 'load_tasks' do
-    before do
-      class << Buildr.application
-        public :load_tasks
+      it 'should emit green code when asked' do
+        Buildr::Console.color('message', :green).should eql("\e[32mmessage\e[0m")
       end
-      @original_loaded_features = $LOADED_FEATURES.dup
-      Buildr.application.options.rakelib = ["tasks"]
-    end
 
-    after do
-      $taskfiles = nil
-      ($LOADED_FEATURES - @original_loaded_features).each do |new_load|
-        $LOADED_FEATURES.delete(new_load)
+      it 'should emit blue code when asked' do
+        Buildr::Console.color('message', :blue).should eql("\e[34mmessage\e[0m")
       end
     end
 
-    def write_task(filename)
-      write filename, <<-RUBY
-        $taskfiles ||= []
-        $taskfiles << __FILE__
-      RUBY
-    end
-
-    def loaded_tasks
-      @loaded ||= Buildr.application.load_tasks
-      $taskfiles
-    end
-
-    it "should load {options.rakelib}/foo.rake" do
-      write_task 'tasks/foo.rake'
-      loaded_tasks.should have(1).task
-      loaded_tasks.first.should =~ %r{tasks/foo\.rake$}
-    end
-
-    it 'should load all *.rake files from the rakelib' do
-      write_task 'tasks/bar.rake'
-      write_task 'tasks/quux.rake'
-      loaded_tasks.should have(2).tasks
-    end
-
-    it 'should not load files which do not have the .rake extension' do
-      write_task 'tasks/foo.rb'
-      write_task 'tasks/bar.rake'
-      loaded_tasks.should have(1).task
-      loaded_tasks.first.should =~ %r{tasks/bar\.rake$}
-    end
-
-    it 'should load files only from the directory specified in the rakelib option' do
-      Buildr.application.options.rakelib = ['extensions']
-      write_task 'extensions/amp.rake'
-      write_task 'tasks/bar.rake'
-      write_task 'extensions/foo.rake'
-      loaded_tasks.should have(2).tasks
-      %w[amp foo].each do |filename|
-        loaded_tasks.select{|x| x =~ %r{extensions/#{filename}\.rake}}.should have(1).entry
+    describe ' use_color is false' do
+      before do
+        Buildr::Console.use_color = false
       end
-    end
-
-    it 'should load files from all the directories specified in the rakelib option' do
-      Buildr.application.options.rakelib = ['ext', 'more', 'tasks']
-      write_task 'ext/foo.rake'
-      write_task 'tasks/bar.rake'
-      write_task 'tasks/zeb.rake'
-      write_task 'more/baz.rake'
-      loaded_tasks.should have(4).tasks
-    end
-
-    it 'should not load files from the rakelib more than once' do
-      write_task 'tasks/new_one.rake'
-      write_task 'tasks/already.rake'
-      $LOADED_FEATURES << File.expand_path('tasks/already.rake')
-
-      loaded_tasks.should have(1).task
-      loaded_tasks.first.should =~ %r{tasks/new_one\.rake$}
-    end
-  end
-
-  describe 'exception handling' do
-
-    it 'should exit when given a SystemExit exception' do
-      test_exit(3) { Buildr.application.standard_exception_handling { raise SystemExit.new(3) } }
-    end
-
-    it 'should exit with status 1 when given an OptionParser::ParseError exception' do
-      test_exit(1) { Buildr.application.standard_exception_handling { raise OptionParser::ParseError.new() } }
-    end
 
-    it 'should exit with status 1 when given any other type of exception exception' do
-      test_exit(1) { Buildr.application.standard_exception_handling { raise Exception.new() } }
-    end
-
-    it 'should print the class name and the message when receiving an exception (except when the exception is named Exception)' do
-
-      # Our fake $stderr for the exercise. We could start it with a matcher instead
-      class FakeStdErr
-
-        attr_accessor :messages
-
-        def puts(*args)
-          @messages ||= []
-          @messages += args
-        end
-
-        alias :write :puts
+      it 'should not emit red code when asked' do
+        Buildr::Console.color('message', :red).should eql("message")
       end
 
-      # Save the old $stderr and make sure to restore it in the end.
-      old_stderr = $stderr
-      begin
-
-        $stderr = FakeStdErr.new
-        test_exit(1) {
-          Buildr.application.send :standard_exception_handling do
-            class MyOwnNicelyNamedException < Exception
-            end
-            raise MyOwnNicelyNamedException.new('My message')
-          end
-        }.call
-        $stderr.messages.select {|msg| msg =~ /.*MyOwnNicelyNamedException : My message.*/}.size.should == 1
-        $stderr.messages.clear
-        test_exit(1) {
-          Buildr.application.send :standard_exception_handling do
-            raise Exception.new('My message')
-          end
-        }.call
-        $stderr.messages.select {|msg| msg =~ /.*My message.*/ && !(msg =~ /Exception/)}.size.should == 1
+      it 'should not emit green code when asked' do
+        Buildr::Console.color('message', :green).should eql("message")
       end
-      $stderr = old_stderr
-    end
-  end
-
-end
-
-
-describe Buildr, 'settings' do
-
-  describe 'user' do
-
-    it 'should be empty hash if no settings.yaml file' do
-      Buildr.settings.user.should == {}
-    end
-
-    it 'should return loaded settings.yaml file' do
-      write 'home/.buildr/settings.yaml', 'foo: bar'
-      Buildr.settings.user.should == { 'foo'=>'bar' }
-    end
-
-    it 'should return loaded settings.yml file' do
-      write 'home/.buildr/settings.yml', 'foo: bar'
-      Buildr.settings.user.should == { 'foo'=>'bar' }
-    end
-
-    it 'should fail if settings.yaml file is not a hash' do
-      write 'home/.buildr/settings.yaml', 'foo bar'
-      lambda { Buildr.settings.user }.should raise_error(RuntimeError, /expecting.*settings.yaml/i)
-    end
-
-    it 'should be empty hash if settings.yaml file is empty' do
-      write 'home/.buildr/settings.yaml'
-      Buildr.settings.user.should == {}
-    end
-  end
-
-  describe 'configuration' do
-    it 'should be empty hash if no build.yaml file' do
-      Buildr.settings.build.should == {}
-    end
-
-    it 'should return loaded build.yaml file' do
-      write 'build.yaml', 'foo: bar'
-      Buildr.settings.build.should == { 'foo'=>'bar' }
-    end
-
-    it 'should return loaded build.yml file' do
-      write 'build.yml', 'foo: bar'
-      Buildr.settings.build.should == { 'foo'=>'bar' }
-    end
-
-    it 'should fail if build.yaml file is not a hash' do
-      write 'build.yaml', 'foo bar'
-      lambda { Buildr.settings.build }.should raise_error(RuntimeError, /expecting.*build.yaml/i)
-    end
-
-    it 'should be empty hash if build.yaml file is empty' do
-      write 'build.yaml'
-      Buildr.settings.build.should == {}
-    end
-  end
-
-  describe 'profiles' do
-    it 'should be empty hash if no profiles.yaml file' do
-      Buildr.settings.profiles.should == {}
-    end
-
-    it 'should return loaded profiles.yaml file' do
-      write 'profiles.yaml', <<-YAML
-        development:
-          foo: bar
-      YAML
-      Buildr.settings.profiles.should == { 'development'=> { 'foo'=>'bar' } }
-    end
-
-    it 'should return loaded profiles.yml file' do
-      write 'profiles.yml', <<-YAML
-        development:
-          foo: bar
-      YAML
-      Buildr.settings.profiles.should == { 'development'=> { 'foo'=>'bar' } }
-    end
-
-    it 'should fail if profiles.yaml file is not a hash' do
-      write 'profiles.yaml', 'foo bar'
-      lambda { Buildr.settings.profiles }.should raise_error(RuntimeError, /expecting.*profiles.yaml/i)
-    end
-
-    it 'should be empty hash if profiles.yaml file is empty' do
-      write 'profiles.yaml'
-      Buildr.settings.profiles.should == {}
-    end
-  end
 
-  describe 'profile' do
-    before do
-    end
-
-    it 'should be empty hash if no profiles.yaml' do
-      Buildr.settings.profile.should == {}
-    end
-
-    it 'should be empty hash if no matching profile' do
-      write 'profiles.yaml', <<-YAML
-        test:
-          foo: bar
-      YAML
-      Buildr.settings.profile.should == {}
-    end
-
-    it 'should return profile matching environment name' do
-      write 'profiles.yaml', <<-YAML
-        development:
-          foo: bar
-        test:
-          foo: baz
-      YAML
-      Buildr.settings.profile.should == { 'foo'=>'bar' }
-    end
-  end
-
-  describe 'buildfile task' do
-    before do
-      @buildfile_time = Time.now - 10
-      write 'buildfile'; File.utime(@buildfile_time, @buildfile_time, 'buildfile')
-    end
-
-    it 'should point to the buildfile' do
-      Buildr.application.buildfile.should point_to_path('buildfile')
-    end
-
-    it 'should be a defined task' do
-      Buildr.application.buildfile.should == file(File.expand_path('buildfile'))
-    end
-
-    it 'should ignore any rake namespace' do
-      namespace 'dummy_ns' do
-        Buildr.application.buildfile.should point_to_path('buildfile')
+      it 'should not emit blue code when asked' do
+        Buildr::Console.color('message', :blue).should eql("message")
       end
     end
-
-    it 'should have the same timestamp as the buildfile' do
-      Buildr.application.buildfile.timestamp.should be_within(1).of(@buildfile_time)
-    end
-
-    it 'should have the same timestamp as build.yaml if the latter is newer' do
-      write 'build.yaml'; File.utime(@buildfile_time + 5, @buildfile_time + 5, 'build.yaml')
-      Buildr.application.run
-      Buildr.application.buildfile.timestamp.should be_within(1).of(@buildfile_time + 5)
-    end
-
-    it 'should have the same timestamp as the buildfile if build.yaml is older' do
-      write 'build.yaml'; File.utime(@buildfile_time - 5, @buildfile_time - 5, 'build.yaml')
-      Buildr.application.run
-      Buildr.application.buildfile.timestamp.should be_within(1).of(@buildfile_time)
-    end
-
-    it 'should have the same timestamp as build.rb in home dir if the latter is newer (until version 1.6)' do
-      Buildr::VERSION.should < '1.6'
-      buildfile_should_have_same_timestamp_as 'home/buildr.rb'
-    end
-
-    it 'should have the same timestamp as build.rb in home dir if the latter is newer' do
-      buildfile_should_have_same_timestamp_as 'home/.buildr/buildr.rb'
-    end
-
-    it 'should have the same timestamp as .buildr.rb in buildfile dir if the latter is newer' do
-      buildfile_should_have_same_timestamp_as '.buildr.rb'
-    end
-
-    it 'should have the same timestamp as _buildr.rb in buildfile dir if the latter is newer' do
-      buildfile_should_have_same_timestamp_as '_buildr.rb'
-    end
-
-    def buildfile_should_have_same_timestamp_as(file)
-      write file; File.utime(@buildfile_time + 5, @buildfile_time + 5, file)
-      Buildr.application.send :load_tasks
-      Buildr.application.buildfile.timestamp.should be_within(1).of(@buildfile_time + 5)
-    end
   end
 end
 
-
-describe Buildr do
-
-  describe 'environment' do
-    it 'should be same as Buildr.application.environment' do
-      Buildr.environment.should eql(Buildr.application.environment)
-    end
-  end
-
-  describe 'application' do
-    it 'should be same as Rake.application' do
-      Buildr.application.should == Rake.application
-    end
-  end
-
-  describe 'settings' do
-    it 'should be same as Buildr.application.settings' do
-      Buildr.settings.should == Buildr.application.settings
-    end
-  end
-
-end
-
-describe Rake do
-  describe 'define_task' do
-   it 'should restore call chain when invoke is called' do
-     task1 = Rake::Task.define_task('task1') do
-     end
-
-     task2 = Rake::Task.define_task('task2') do
-       chain1 = Thread.current[:rake_chain]
-       task1.invoke
-       chain2 = Thread.current[:rake_chain]
-       chain2.should == chain1
-     end
-
-     task2.invoke
-   end
- end
-end
-