1
|
#!/usr/bin/env php
|
2
|
<?php
|
3
|
|
4
|
/*
|
5
|
* This file is part of the Predis package.
|
6
|
*
|
7
|
* (c) Daniele Alessandri <suppakilla@gmail.com>
|
8
|
*
|
9
|
* For the full copyright and license information, please view the LICENSE
|
10
|
* file that was distributed with this source code.
|
11
|
*/
|
12
|
|
13
|
// -------------------------------------------------------------------------- //
|
14
|
// In order to be able to execute this script to create a PEAR package of Predis
|
15
|
// both `onion` and `pear` must be available and executable in your $PATH.
|
16
|
// -------------------------------------------------------------------------- //
|
17
|
|
18
|
function executeWithBackup($file, $callback)
|
19
|
{
|
20
|
$exception = null;
|
21
|
$backup = "$file.backup";
|
22
|
|
23
|
copy($file, $backup);
|
24
|
|
25
|
try {
|
26
|
call_user_func($callback, $file);
|
27
|
} catch (Exception $exception) {
|
28
|
// NOOP
|
29
|
}
|
30
|
|
31
|
unlink($file);
|
32
|
rename($backup, $file);
|
33
|
|
34
|
if ($exception) {
|
35
|
throw $exception;
|
36
|
}
|
37
|
}
|
38
|
|
39
|
function buildPackage()
|
40
|
{
|
41
|
passthru('onion build && pear -q package && rm package.xml');
|
42
|
}
|
43
|
|
44
|
executeWithBackup(__DIR__.'/../phpunit.xml.dist', function ($file) {
|
45
|
$cfg = new SimpleXMLElement($file, null, true);
|
46
|
|
47
|
$cfg[0]['bootstrap'] = str_replace('tests/', '', $cfg[0]['bootstrap']);
|
48
|
$cfg->testsuites->testsuite->directory = str_replace('tests/', '', $cfg->testsuites->testsuite->directory);
|
49
|
|
50
|
$cfg->saveXml($file);
|
51
|
|
52
|
buildPackage();
|
53
|
});
|