diff --git a/src/Command.php b/src/Command.php index 968aaea..67f5836 100644 --- a/src/Command.php +++ b/src/Command.php @@ -193,6 +193,14 @@ private static function runTests($config) // Write temporary XML file $xml = SolanoLabs_PHPUnit_XmlGenerator::GenerateXml($config); $tempFile = tempnam($config->tempDir, 'SLPHPU'); + if ($config->configDebug) { + $tempFileXML = $tempFile . ".xml"; + if (!empty(getenv('TDDIUM_TEST_EXEC_ID'))) { + $tempFileXML = dirname($tempFile) . DIRECTORY_SEPARATOR . 'phpunit-' . getenv('TDDIUM_TEST_EXEC_ID') . '.xml'; + } + rename($tempFile, $tempFileXML); + $tempFile = $tempFileXML; + } file_put_contents($tempFile, $xml); // Run PHPUnit @@ -225,9 +233,13 @@ private static function runTests($config) SolanoLabs_PHPUnit_JsonReporter::writeJsonToFile($config->outputFile, $jsonData); } + // Save generated configuration XML file? + if ($config->configDebug) { + echo("# XML phpunit configuration file: " . $tempFile . "\n"); + } else { + unlink($tempFile); + } - // Delete temporary XML file - unlink($tempFile); return $exitCode; } @@ -244,6 +256,7 @@ private static function usage() echo(" --tddium-output-file Can also be set with \$TDDIUM_OUTPUT_FILE environment variable\n"); echo(" --ignore-exclude Ignore child nodes of .\n"); echo(" --split Run tests one test file per process.\n"); + echo(" --config-debug XML configuration passed to phpunit will not be deleted.\n"); echo(" -h|--help Prints this usage information.\n"); echo(" * Any other supplied options will be passed on to phpunit\n"); } diff --git a/src/Configuration.php b/src/Configuration.php index 487d501..8d57f92 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -91,6 +91,11 @@ class SolanoLabs_PHPUnit_Configuration */ public $ignoreExclude = false; + /** + * @var boolean + */ + public $configDebug = false; + /** * @var boolean */ @@ -123,6 +128,7 @@ public static function parseArgs($args) $config->setOutputFile(); $config->checkSplit(); $config->checkIgnoreExclude(); + $config->checkConfigDebug(); $config->checkTestsuiteOption(); if (count($config->parseErrors)) { return $config; } @@ -169,6 +175,17 @@ private function checkIgnoreExclude() } } + /** + * Check if --config-debug was supplied + */ + private function checkConfigDebug() + { + if ($key = array_search('--config-debug', $this->args)) { + $this->configDebug = true; + unset($this->args[$key]); + } + } + /** * Adds cli specified files to the configuration */