-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathcompile_plugin_test.php
104 lines (84 loc) · 2.39 KB
/
compile_plugin_test.php
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
104
<?php
/*
* phc -- the open source PHP compiler
* See doc/license/README.license for licensing information
*
* Compile a plugin using phc_compile_plugin, and check it works
*/
class CompilePluginTest extends AsyncTest
{
function check_prerequisites ()
{
global $phc_compile_plugin;
return check_for_program ($phc_compile_plugin);
}
// all plugins are tests
function get_test_subjects ()
{
return get_all_plugins ();
}
function get_dependent_test_names ()
{
return array (); // the subjects arent used elsewhere
}
function copy_headers ()
{
global $working_directory, $plugin_dir, $base_dir;
// copy the header files from the plugin's directory to
// working dir
$headers = preg_split ("/\n/", chop (`find $base_dir/plugins -name "*.h"`));
$new_headers = array ();
if ($headers !== array (""))
{
foreach ($headers as $header)
{
$dest = "$working_directory/".basename ($header);
if (!copy ($header, $dest))
{
print("dying while copying headers: $header to $dest");
die(-1);
}
}
}
}
function run ()
{
$this->copy_headers ();
parent::run ();
}
function run_test ($subject)
{
global $phc, $trunk_CPPFLAGS, $phc_compile_plugin, $working_directory, $base_dir;
// setup the files
$plugin_name = tempnam ($working_directory, "plugin");
unlink ("$plugin_name");
if (!copy ($subject, "$plugin_name.cpp"))
{
$this->mark_failure ($subject, "Copy failed");
return;
}
$async = new AsyncBundle ($this, $subject);
# phc_compile_plugin only allows CFLAGS and LDFLAGS, even
# though we use CPPFLAGS
if ($trunk_CPPFLAGS)
$CPPFLAGS = "$trunk_CPPFLAGS";
else
$CPPFLAGS = "''";
$CPPFLAGS[0] = ' ';
$CPPFLAGS="CFLAGS='-Wno-deprecated $CPPFLAGS";
$async->commands[0] = "$CPPFLAGS $phc_compile_plugin $plugin_name.cpp";
$async->err_handlers[0] = "fail_on_output";
$async->exit_handlers[0] = "fail_on_output";
// Check it runs under phc
$files = get_all_scripts ();
$filename = $files[0];
// --r-option is a special option for reduce_statements.la, which doesn't harm the other tests.
$async->commands[1] = "$phc --run $plugin_name.la $filename --r-option 0:1";
$async->err_handlers[1] = "fail_on_output";
$async->exit_handlers[1] = "fail_on_output";
$async->final = "async_success";
$async->start ();
}
}
array_push($tests, new CompilePluginTest ());
?>