OSDN Git Service

behat: pass process result to checkString() for richer error messages
authorscribu <mail@scribu.net>
Tue, 27 Aug 2013 22:28:56 +0000 (01:28 +0300)
committerscribu <mail@scribu.net>
Tue, 27 Aug 2013 22:29:00 +0000 (01:29 +0300)
features/bootstrap/Process.php
features/bootstrap/support.php
features/steps/basic_steps.php

index 16b248d..e0abcff 100644 (file)
@@ -71,7 +71,8 @@ class ProcessRun {
        }
 
        public function __toString() {
-               return sprintf( "%s: %s\ncwd: %s", $this->command, $this->STDERR, $this->cwd );
+               return sprintf( "%s: %s\n" . "cwd: %s\n" . "exit status: %d",
+                       $this->command, $this->STDERR, $this->cwd, $this->return_code );
        }
 }
 
index 7b77eb7..afe96ec 100644 (file)
@@ -14,7 +14,7 @@ function assertNumeric( $actual ) {
        }
 }
 
-function checkString( $output, $expected, $action ) {
+function checkString( $output, $expected, $action, $message = false ) {
        switch ( $action ) {
 
        case 'be':
@@ -34,7 +34,9 @@ function checkString( $output, $expected, $action ) {
        }
 
        if ( !$r ) {
-               throw new Exception( $output );
+               if ( false === $message )
+                       $message = $output;
+               throw new Exception( $message );
        }
 }
 
index c08a64a..1557f91 100644 (file)
@@ -149,7 +149,7 @@ $steps->Then( '/^(STDOUT|STDERR) should (be|contain|not contain):$/',
        function ( $world, $stream, $action, PyStringNode $expected ) {
                $expected = $world->replace_variables( (string) $expected );
 
-               checkString( $world->result->$stream, $expected, $action );
+               checkString( $world->result->$stream, $expected, $action, $world->result );
        }
 );