Permalink
Browse files

Return a non-zero exit code if there are any stylesheet compilation e…

…rrors. Closes GH-432.
  • Loading branch information...
1 parent 23d3d34 commit b8b6af9d498cea6269be56fe77a8c1ee413af5d3 @chriseppstein chriseppstein committed Jul 3, 2011
@@ -63,6 +63,15 @@ Feature: Command Line
And I am told that I can place stylesheets in the sass subdirectory
And I am told how to compile my sass stylesheets
+ Scenario: Compiling a project with errors
+ Given I am using the existing project in test/fixtures/stylesheets/compass
+ And the project has a file named "sass/error.scss" containing:
+ """
+ .broken {
+ """
+ When I run: compass compile
+ Then the command exits with a non-zero error code
+
Scenario: Creating a bare project with a framework
When I create a project using: compass create bare_project --using blueprint --bare
Then an error message is printed out: A bare project cannot be created when a framework is specified.
@@ -53,6 +53,13 @@
@cleanup_directories << directory
end
+Given %r{^the project has a file named "([^"]*)" containing:$} do |arg1, string|
+ File.open(arg1, "w") do |f|
+ f << string
+ end
+end
+
+
# When Actions are performed
When /^I create a project using: compass create ([^\s]+) ?(.+)?$/ do |dir, args|
@cleanup_directories << dir
@@ -22,6 +22,14 @@ def perform
raise StandardError.new("Not Implemented")
end
+ def successful?
+ !@failed
+ end
+
+ def failed!
+ @failed = true
+ end
+
protected
def framework
@@ -34,7 +34,8 @@ def perform
compiler = new_compiler_instance
check_for_sass_files!(compiler)
compiler.clean! if compiler.new_config?
- compiler.run
+ error_count = compiler.run
+ failed! if error_count > 0
end
def check_for_sass_files!(compiler)
View
@@ -82,6 +82,7 @@ def clean!
end
def run
+ failure_count = 0
if new_config?
# Wipe out the cache and force compilation if the configuration has changed.
remove options[:cache_location] if options[:cache_location]
@@ -97,13 +98,15 @@ def run
begin
compile_if_required sass_filename, css_filename
rescue Sass::SyntaxError => e
+ failure_count += 1
handle_exception(sass_filename, css_filename, e)
end
end
end
if options[:time]
puts "Compilation took #{(result.__duration * 1000).round / 1000.0}s"
end
+ return failure_count
end
def compile_if_required(sass_filename, css_filename)
@@ -12,8 +12,7 @@ def initialize(args)
def run!
begin
- perform!
- return 0
+ return perform!
rescue Exception => e
raise e if e.is_a? SystemExit
if e.is_a?(::Compass::Error) || e.is_a?(OptionParser::ParseError)
@@ -40,7 +39,9 @@ def perform!
else
command_class.parse!(args)
end
- command_class.new(Dir.getwd, @options).execute
+ cmd = command_class.new(Dir.getwd, @options)
+ cmd.execute
+ cmd.successful? ? 0 : 1
rescue OptionParser::ParseError => e
puts "Error: #{e.message}"
puts command_class.usage if command_class.respond_to?(:usage)

0 comments on commit b8b6af9

Please sign in to comment.