xref: /PHP-8.1/sapi/cli/tests/bug64529.phpt (revision 39131219)
1--TEST--
2Bug #64529 (Ran out of opcode space)
3--EXTENSIONS--
4readline
5--SKIPIF--
6<?php
7if (substr(PHP_OS, 0, 3) == "WIN") {
8    die("skip non windows test");
9}
10if (!readline_info("done")) {
11    die("skip readline support required");
12}
13exec('which expect', $output, $ret);
14if ($ret) {
15    die("skip no expect installed");
16}
17?>
18--FILE--
19<?php
20$expect_executable = trim(`which expect`);
21$php_executable = getenv('TEST_PHP_EXECUTABLE');
22$script = __DIR__ . "/expect.sh";
23
24if (extension_loaded("readline")) {
25    $expect_script = <<<SCRIPT
26
27set php_executable [lindex \$argv 0]
28
29spawn \$php_executable -n -d cli.prompt="" -a
30
31expect "php >"
32
33send "echo 'hello world';\n"
34send "\04"
35
36expect eof
37
38exit
39
40SCRIPT;
41
42} else {
43    $expect_script = <<<SCRIPT
44
45set php_executable [lindex \$argv 0]
46
47spawn \$php_executable -n -d cli.prompt="" -a
48
49expect "Interactive mode enabled"
50
51send "<?php echo 'hello world';\n"
52send "\04"
53
54expect eof
55
56exit
57
58SCRIPT;
59}
60
61file_put_contents($script, $expect_script);
62
63system($expect_executable . " " . $script . " " . $php_executable);
64
65@unlink($script);
66?>
67--EXPECTF--
68spawn %sphp -n -d cli.prompt="" -a
69Interactive %s
70
71%Secho 'hello world';
72%Shello world
73