From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS33070 50.56.128.0/17 X-Spam-Status: No, score=0.5 required=5.0 tests=AWL,RDNS_NONE shortcircuit=no autolearn=no version=3.3.2 X-Original-To: archivist@yhbt.net Delivered-To: archivist@dcvr.yhbt.net Received: from rubyforge.org (unknown [50.56.192.79]) by dcvr.yhbt.net (Postfix) with ESMTP id BE51E1F5B3 for ; Fri, 7 Jun 2013 09:26:03 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 358832E150; Fri, 7 Jun 2013 09:26:03 +0000 (UTC) X-Original-To: mongrel-unicorn@rubyforge.org Delivered-To: mongrel-unicorn@rubyforge.org Received: from dcvr.yhbt.net (dcvr.yhbt.net [64.71.152.64]) by rubyforge.org (Postfix) with ESMTP id 311082E14E for ; Fri, 7 Jun 2013 09:26:00 +0000 (UTC) Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 000301F43F; Fri, 7 Jun 2013 09:25:57 +0000 (UTC) Date: Fri, 7 Jun 2013 09:25:57 +0000 From: Eric Wong To: unicorn list Subject: Re: [PATCH 1/2] Integration test for --no-default-middleware option Message-ID: <20130607092557.GA19297@dcvr.yhbt.net> References: <5690F44F-E5B5-4D5D-9DDE-44689B1A02AD@micahchalmer.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5690F44F-E5B5-4D5D-9DDE-44689B1A02AD@micahchalmer.net> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: Micah Chalmer X-BeenThere: mongrel-unicorn@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: mongrel-unicorn-bounces@rubyforge.org Errors-To: mongrel-unicorn-bounces@rubyforge.org Micah Chalmer wrote: > This adds an integration test to ensure that the -N option > continues to function as documented. Thanks for this fix. To avoid breaking bisection, I always keep previously-failing test cases in the same commit as the fix, so I'll squash your commits together. Your 2/2 came whitespace mangled, too. The git-format-patch(1) manpage has info for popular mailers, and git also comes with a 'send-email' command for use in conjunction with 'format-patch'. > +++ b/t/t0300-no-default-middleware.sh > @@ -0,0 +1,15 @@ > +#!/bin/sh > +. ./test-lib.sh > +t_plan 2 "test the -N / --no-default-middleware option" > + > +t_begin "setup and start" && { > + unicorn_setup > + unicorn -N -D -c $unicorn_config fails-rack-lint.ru > + unicorn_wait_start Existing integration tests use hard tabs for indentation, I'll update your patch to match on my end (my personal preference is hard tabs, especially for non-Ruby languages). I'll push out the following unless you have objections: --------------------------------8<---------------------------------- From: Micah Chalmer Subject: [PATCH] Make -N/--no-default-middleware option work This fixes the -N (a.k.a. --no-defaut-middleware) option, which was not working. The problem was that Unicorn::Configurator::RACKUP is cleared before the lambda returned by Unicorn.builder is run, which means that checking whether the :no_default_middleware option was set from the lambda could not detect anything. This patch copies it to a local variable that won't get clobbered, restoring the feature. [ew: squashed test commit into the fix, whitespace fixes] Signed-off-by: Eric Wong --- lib/unicorn.rb | 6 +++++- t/fails-rack-lint.ru | 5 +++++ t/t0300-no-default-middleware.sh | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 t/fails-rack-lint.ru create mode 100644 t/t0300-no-default-middleware.sh diff --git a/lib/unicorn.rb b/lib/unicorn.rb index f0ceffe..2535159 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -35,6 +35,10 @@ module Unicorn # allow Configurator to parse cli switches embedded in the ru file op = Unicorn::Configurator::RACKUP.merge!(:file => ru, :optparse => op) + # Op is going to get cleared before the returned lambda is called, so + # save this value so that it's still there when we need it: + no_default_middleware = op[:no_default_middleware] + # always called after config file parsing, may be called after forking lambda do || inner_app = case ru @@ -49,7 +53,7 @@ module Unicorn pp({ :inner_app => inner_app }) if $DEBUG - return inner_app if op[:no_default_middleware] + return inner_app if no_default_middleware # return value, matches rackup defaults based on env # Unicorn does not support persistent connections, but Rainbows! diff --git a/t/fails-rack-lint.ru b/t/fails-rack-lint.ru new file mode 100644 index 0000000..82bfb5f --- /dev/null +++ b/t/fails-rack-lint.ru @@ -0,0 +1,5 @@ +# This rack app returns an invalid status code, which will cause +# Rack::Lint to throw an exception if it is present. This +# is used to check whether Rack::Lint is in the stack or not. + +run lambda {|env| return [42, {}, ["Rack::Lint wasn't there if you see this"]]} diff --git a/t/t0300-no-default-middleware.sh b/t/t0300-no-default-middleware.sh new file mode 100644 index 0000000..c017c16 --- /dev/null +++ b/t/t0300-no-default-middleware.sh @@ -0,0 +1,15 @@ +#!/bin/sh +. ./test-lib.sh +t_plan 2 "test the -N / --no-default-middleware option" + +t_begin "setup and start" && { + unicorn_setup + unicorn -N -D -c $unicorn_config fails-rack-lint.ru + unicorn_wait_start +} + +t_begin "check exit status with Rack::Lint not present" && { + test 42 -eq "$(curl -sf -o/dev/null -w'%{http_code}' http://$listen/)" +} + +t_done -- Eric Wong _______________________________________________ Unicorn mailing list - mongrel-unicorn@rubyforge.org http://rubyforge.org/mailman/listinfo/mongrel-unicorn Do not quote signatures (like this one) or top post when replying