'help' => 'generate a development snapshot'
)
),
+ new Horde_Argv_Option(
+ '-Z',
+ '--archivedir',
+ array(
+ 'action' => 'store',
+ 'help' => 'the path to the directory where any resulting source archives will be placed.'
+ )
+ )
);
}
/**
* Generate a snapshot of the package using the provided version number.
*
- * @param string $varsion The snapshot version.
+ * @param string $version The snapshot version.
+ * @param string $archive_dir The path where the snapshot should be placed.
*
* @return string The path to the snapshot.
*/
- public function generateSnapshot($version)
+ public function generateSnapshot($version, $archive_dir)
{
$pkg = $this->_getPackageFile();
$pkg->_packageInfo['version']['release'] = $version;
$pkg->setDate(date('Y-m-d'));
$pkg->setTime(date('H:i:s'));
ob_start();
+ $old_dir = getcwd();
+ chdir($archive_dir);
$result = Components_Exception_Pear::catchError(
$pkg->getDefaultGenerator()
->toTgz(new PEAR_Common())
);
+ chdir($old_dir);
$this->_output->pear(ob_get_clean());
$this->_output->ok('Generated snapshot ' . $result);
return $result;
public function run()
{
- $options = $this->_config->getOptions();
$arguments = $this->_config->getArguments();
$package = $this->_factory->createPackageForDefaultLocation(
$arguments[0] . DIRECTORY_SEPARATOR . 'package.xml'
);
+
+ $options = $this->_config->getOptions();
+ if ($options['archivedir']) {
+ $archivedir = $options['archivedir'];
+ } else {
+ $archivedir = getcwd();
+ }
$package->generateSnapshot(
- $package->getVersion() . 'dev' . strftime('%Y%m%d%H%M')
+ $package->getVersion() . 'dev' . strftime('%Y%m%d%H%M'),
+ $archivedir
);
}
}
$arguments[0] . DIRECTORY_SEPARATOR . 'package.xml'
);
$version = $package->getVersion() . 'dev' . strftime('%Y%m%d%H%M');
- $package->generateSnapshot($version);
+ $package->generateSnapshot($version, dirname($options['distribute']));
ob_start();
include $template->getPathname();
/**
* @scenario
*/
+ public function theTheLOptionListThePackageDependenciesAsTreeWithoutColorIfSelected()
+ {
+ $this->given('the default Components setup')
+ ->when('calling the package with the list dependencies option, the nocolor option and a path to a Horde framework component')
+ ->then('the non-Horde dependencies of the component will be listed')
+ ->and('the Horde dependencies of the component will be listed');
+ }
+
+ /**
+ * @scenario
+ */
public function theTheVerboseLOptionListThePackageDependenciesAsTree()
{
$this->given('the default Components setup')
--- /dev/null
+<?php
+/**
+ * Test the DevPackage module.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package Components
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Components
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../Autoload.php';
+
+/**
+ * Test the DevPackage module.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Horde
+ * @package Components
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Components
+ */
+class Components_Integration_Components_Module_DevPackageTest
+extends Components_StoryTestCase
+{
+ /**
+ * @scenario
+ */
+ public function theDevPackageModuleAddsTheDOptionInTheHelpOutput()
+ {
+ $this->given('the default Components setup')
+ ->when('calling the package with the help option')
+ ->then('the help will contain the option', '-d,\s*--devpackage');
+ }
+
+ /**
+ * @scenario
+ */
+ public function theTheLowerCaseDOptionGeneratesAPackageSnapshot()
+ {
+ $this->given('the default Components setup')
+ ->when('calling the package with the devpackage option, the archive directory option and a path to a Horde framework component')
+ ->then('a package snapshot will be generated at the indicated archive directory');
+ }
+}
\ No newline at end of file
);
$world['output'] = $this->_callUnstrictComponents();
break;
+ case 'calling the package with the list dependencies option, the nocolor option and a path to a Horde framework component':
+ $_SERVER['argv'] = array(
+ 'horde-components',
+ '--nocolor',
+ '--list-deps',
+ dirname(__FILE__) . '/fixture/framework/Install'
+ );
+ $world['output'] = $this->_callUnstrictComponents();
+ break;
case 'calling the package with the quiet list dependencies option and a path to a Horde framework component':
$_SERVER['argv'] = array(
'horde-components',
);
$world['output'] = $this->_callUnstrictComponents();
break;
+ case 'calling the package with the devpackage option, the archive directory option and a path to a Horde framework component':
+ $_SERVER['argv'] = array(
+ 'horde-components',
+ '--verbose',
+ '--devpackage',
+ '--archivedir=' . $this->_getTemporaryDirectory(),
+ dirname(__FILE__) . '/fixture/framework/Install'
+ );
+ $world['output'] = $this->_callUnstrictComponents();
+ break;
case 'calling the package with the distribute option and a path to a Horde framework component':
$_SERVER['argv'] = array(
'horde-components',
$world['output']
);
break;
+ case 'a package snapshot will be generated at the indicated archive directory':
+ $found = false;
+ foreach (new DirectoryIterator($this->_temp_dir) as $file) {
+ if (preg_match('/Install-[0-9]+(\.[0-9]+)+([a-z0-9]+)?/', $file->getBasename('.tgz'), $matches)) {
+ $found = true;
+ }
+ }
+ $this->assertTrue($found);
+ break;
case 'a package definition will be generated at the indicated location':
$this->assertTrue(
file_exists(