Repository navigation
Expand file tree
/
Copy pathsetup_simpletest.php
More file actions
103 lines (87 loc) · 3.26 KB
/
Copy pathsetup_simpletest.php
File metadata and controls
103 lines (87 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
if( ! defined('EVODIR') )
{
require dirname(__FILE__).'/config.php';
}
require EVODIR.'blogs/inc/_main.inc.php';
load_funcs('_core/_param.funcs.php');
param('action', 'string', '');
?>
<html>
<head>
<title>Setup simpletest for b2evolution</title>
</head>
<body>
<h1>Setup simpletest for b2evolution</h1>
<p>This will setup the simpletest framework for b2evolution, by unzipping the simpletest snapshot
<small>(<a href="http://evocms.cvs.sourceforge.net/viewvc/*checkout*/evocms/b2evolution/tests/simpletest.tar.bz2?revision=1.1">link to the CVS HEAD (most current) version</a>)</small> shipped with b2evolution.</p>
<p><small>This snapshot is provided for your convenience and gets packaged from <a href="http://github.com/blueyed/simpletest">http://github.com/blueyed/simpletest</a> (basically upstream trunk with useful/required patches)</small></p>
<?php
if( $action == 'unzip_simpletest' )
{
echo '<h1>Unzipping...</h1>';
$target_dir = dirname(__FILE__);
$source_file = 'simpletest.tar.bz2';
# Test if "tar" exists
exec( 'tar --version', $output, $return );
if( $return !== 0 )
{
echo '<p><strong>ERROR: The "tar" binary is not installed on your system.</strong></p>';
}
else
{
$commands[] = 'tar xjv -f '.escapeshellarg($source_file).' 2>&1';
}
if( empty($commands) && @file_exists( 'C:\Program Files\7-Zip\7z.exe' ) )
{ // 7-Zip is installed, let's use it
echo '<p><strong>GOOD NEWS! "7-Zip" is found, we\'ll use it instead.</strong></p>';
$source_bz = $source_file;
$source_tar = str_replace( '.bz2', '', $source_file );
// Extract the temporary .tar file
$commands[] = '"C:\Program Files\7-Zip\7z.exe" e '.escapeshellarg($target_dir.'/'.$source_bz).' -y -o'.escapeshellarg($target_dir);
// Extract the files
$commands[] = '"C:\Program Files\7-Zip\7z.exe" e '.escapeshellarg($target_dir.'/'.$source_tar).' -y -o'.escapeshellarg($target_dir).'/simpletest';
}
if( ! is_dir($target_dir) || ! is_writable($target_dir) )
{
printf('<p><strong>ERROR: Target directory (%s) is not writable (for me).</strong></p>', htmlspecialchars($target_dir));
}
elseif( ! empty($commands) )
{
// Change to target dir (instead of "-C") and use filename without path for tar in cygwin
chdir($target_dir);
foreach( $commands as $cmd )
{
exec( $cmd, $output, $return );
}
if( !empty($source_tar) )
{ // Get rid of the temporary .tar file
unlink($target_dir.'/'.$source_tar);
}
if( $return !== 0 )
{ // Error
echo '<p><strong>An error occured (exit code '.$return.')!</strong></p>';
echo '<p><small>Command: '.implode('<br />', $commands).'</small></p>';
}
else
{ // Success
echo '<p class="success">The simpletest framework has been extracted successfully.<br />Target directory: '.$target_dir.'/simpletest</p>';
echo '<p><a href="../">Now go testing...</a></p>'; # link to current dir (index.php is not present in e.g. evocore/blogs/)
}
echo '<p><strong>Command output:</strong></p>';
echo '<ul style="font-size:smaller"><li>'.implode('</li><li>', $output).'</li></ul>';
}
else
{
echo '<p>You will need to manually extract simpletest files and folders from <b>simpletest.tar.bz2</b> into /test/simpletest directory.</p>';
}
}
else
{ // no action:
?>
<a href="?action=unzip_simpletest">OK, do it for me.</a>
<?php
}
?>
</body>
</html>