make sure failed builds exit with correct status code

This commit is contained in:
Thomas Reynolds 2011-12-11 15:49:13 -08:00
parent ecc77ae89f
commit f2221cd9a0
6 changed files with 18 additions and 3 deletions

View file

@ -17,11 +17,17 @@ Feature: Builder
Then "images/Read me (example).txt" should exist at "test-app"
Then "images/Child folder/regular_file(example).txt" should exist at "test-app"
Then ".htaccess" should exist at "test-app"
Then the last exit code should be "0"
Scenario: Build glob
Given a built app at "glob-app" with flags "--glob '*.css'"
Then "stylesheets/site.css" should exist at "glob-app" and include "html"
Then "index.html" should not exist at "glob-app"
Then the last exit code should be "0"
Scenario: Build with errors
Given a built app at "build-with-errors-app"
Then the last exit code should be "1"
# Scenario: Force relative assets
# Given a built app at "relative-app" with flags "--relative"

View file

@ -0,0 +1 @@
set :layout, false

View file

@ -0,0 +1 @@
<%= error_error_error %>

View file

@ -42,11 +42,13 @@ module Middleman
destination, request_path = ::Middleman::Builder.shared_instance.reroute_builder(destination, request_path)
response = ::Middleman::Builder.shared_rack.get(request_path.gsub(/\s/, "%20"))
create_file(destination, response.body, config) if response.status == 200
create_file(destination, response.body, config)
destination
rescue
say_status :error, destination, :red
abort
end
end
end

View file

@ -3,7 +3,7 @@ require 'rack/showexceptions'
module Middleman::CoreExtensions::ShowExceptions
class << self
def registered(app)
app.after_configuration do
app.configure :development do
if show_exceptions
use ::Middleman::CoreExtensions::ShowExceptions::Middleware
end

View file

@ -43,3 +43,8 @@ Then /^"([^\"]*)" should not exist at "([^\"]*)"$/ do |target_file, path|
target = File.join(PROJECT_ROOT_PATH, "fixtures", path, "build", target_file)
File.exists?(target).should be_false
end
Then /^the last exit code should be "([^\"]*)"$/ do |exit_code|
exit_code = exit_code.to_i
$?.exitstatus.should == exit_code
end