Ensure we get a decent display about the package.xml problems.
authorGunnar Wrobel <p@rdus.de>
Thu, 25 Nov 2010 14:24:41 +0000 (15:24 +0100)
committerGunnar Wrobel <p@rdus.de>
Thu, 25 Nov 2010 14:24:41 +0000 (15:24 +0100)
components/lib/Components/Pear/Package.php
components/test/Components/Integration/Components/Module/DevPackageTest.php
components/test/Components/StoryTestCase.php

index de24a01..b99b236 100644 (file)
@@ -357,16 +357,31 @@ class Components_Pear_Package
         $pkg->_packageInfo['version']['release'] = $version;
         $pkg->setDate(date('Y-m-d'));
         $pkg->setTime(date('H:i:s'));
+        $errors = array();
         ob_start();
         $old_dir = getcwd();
         chdir($archive_dir);
-        $result = Components_Exception_Pear::catchError(
-            $pkg->getDefaultGenerator()
-            ->toTgz(new PEAR_Common())
-        );
+        try {
+            $result = Components_Exception_Pear::catchError(
+                $pkg->getDefaultGenerator()->toTgz(new PEAR_Common())
+            );
+        } catch (Components_Exception_Pear $e) {
+            $errors[] = $e->getMessage();
+            $errors[] = '';
+            $result = false;
+            foreach ($pkg->getValidationWarnings() as $error) {
+                $errors[] = isset($error['message']) ? $error['message'] : 'Unknown Error';
+            }
+        }
         chdir($old_dir);
         $this->_output->pear(ob_get_clean());
-        $this->_output->ok('Generated snapshot ' . $result);
+        if ($result) {
+            $this->_output->ok('Generated snapshot ' . $result);
+        } else {
+            $this->_output->fail(
+                'Generating snapshot failed with:'. "\n\n" . join("\n", $errors)
+            );
+        }
         return $result;
     }
 
index 4380eb2..f75e246 100644 (file)
@@ -62,6 +62,7 @@ extends Components_StoryTestCase
     {
         $this->given('the default Components setup')
             ->when('calling the package with the devpackage option, the archive directory option and a path to an invalid Horde framework component')
-            ->then('the output should indicate an invalid package.xml');
+            ->then('the output should indicate an invalid package.xml')
+            ->and('indicate the specific problem of the package.xml');
     }
 }
\ No newline at end of file
index 3706d2f..9ba58e5 100644 (file)
@@ -621,6 +621,12 @@ extends PHPUnit_Extensions_Story_TestCase
                 $world['output']
             );
             break;
+        case 'indicate the specific problem of the package.xml':
+            $this->assertContains(
+                'Old.php" in package.xml does not exist',
+                $world['output']
+            );
+            break;
         default:
             return $this->notImplemented($action);
         }
@@ -679,7 +685,8 @@ extends PHPUnit_Extensions_Story_TestCase
 
     private function _callUnstrict(array $parameters)
     {
-        $old_errorreporting = error_reporting(E_ALL & ~E_STRICT);
+        $old_errorreporting = error_reporting(E_ALL & ~(E_STRICT | E_DEPRECATED));
+        error_reporting(E_ALL & ~(E_STRICT | E_DEPRECATED));
         $this->_callStrict($parameters);
         error_reporting($old_errorreporting);
     }
@@ -695,5 +702,6 @@ extends PHPUnit_Extensions_Story_TestCase
             '*' => false,
         );
         $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER'] = false;
+        $GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'] = array();
     }
 }
\ No newline at end of file