Skip to content

Commit

Permalink
Merge pull request #5 from solanolabs/save-config-xml
Browse files Browse the repository at this point in the history
Save config xml
  • Loading branch information
IsaacChapman committed Dec 1, 2015
2 parents 89aefff + a8dabea commit 826646b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand All @@ -244,6 +256,7 @@ private static function usage()
echo(" --tddium-output-file <file> Can also be set with \$TDDIUM_OUTPUT_FILE environment variable\n");
echo(" --ignore-exclude Ignore <exclude/> child nodes of <testsuite/>.\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");
}
Expand Down
17 changes: 17 additions & 0 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ class SolanoLabs_PHPUnit_Configuration
*/
public $ignoreExclude = false;

/**
* @var boolean
*/
public $configDebug = false;

/**
* @var boolean
*/
Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit 826646b

Please sign in to comment.