Change TERM when running tests with input

In general, a test which gets its input piped in is not really interacting with a terminal like it normally would. Thus, letting it think it has the same terminal as the environment is incorrect. More specifically, hphpd uses Readline, which inspects the TERM env var and based on that and a stunning array of other options will attempt to initialize the terminal with extra control characters on first use. It would be tough to try to control for all of the different options and ensure they're all the same, and honestly testing Readline is not the objective of our tests anyway. Thus, I'm forcing TERM to 'dumb' when a test has input to ensure a) a simple terminal which requires no control characters and b) consistency no matter what environment is present when the tests are run.
Esse commit está contido em:
Mike Magruder
2013-07-01 11:47:55 -07:00
commit de Sara Golemon
commit 0d14e585fd
22 arquivos alterados com 38 adições e 32 exclusões
+1 -1
Ver Arquivo
@@ -1,5 +1,5 @@
Program %s/break1.php loaded. Type '[r]un' or '[c]ontinue' to go.
%Srun
run
break1.php loaded
Program %s/break1.php exited normally.
break break1.php:7
+6 -6
Ver Arquivo
@@ -1,7 +1,7 @@
Program %s/break2.php loaded. Type '[r]un' or '[c]ontinue' to go.
%Sbreak quick/debugger/break2.php:7
Breakpoint 1 set on line 7 of quick/debugger/break2.php
But wont break until file quick/debugger/break2.php has been loaded.
break %s/break2.php:7
Breakpoint 1 set on line 7 of %s/break2.php
But wont break until file %s/break2.php has been loaded.
break foo2()
Breakpoint 2 set upon entering foo2()
But wont break until function foo2 has been loaded.
@@ -12,7 +12,7 @@ break cls2::pubCls()
Breakpoint 4 set upon entering cls2::pubCls()
But wont break until class cls2 has been loaded.
break list
1 ALWAYS on line 7 of quick/debugger/break2.php (unbound)
1 ALWAYS on line 7 of %s/break2.php (unbound)
2 ALWAYS upon entering foo2() (unbound)
3 ALWAYS upon entering cls2::pubObj() (unbound)
4 ALWAYS upon entering cls2::pubCls() (unbound)
@@ -26,12 +26,12 @@ Breakpoint 2 reached at foo2() on line 6 of %s/break2.php
7 error_log($y);
break list
1 ALWAYS on line 7 of quick/debugger/break2.php
1 ALWAYS on line 7 of %s/break2.php
2 ALWAYS upon entering foo2()
3 ALWAYS upon entering cls2::pubObj()
4 ALWAYS upon entering cls2::pubCls()
continue
Breakpoint 1 reached at foo2() on line 7 of %s/quick/debugger/break2.php
Breakpoint 1 reached at foo2() on line 7 of %s/break2.php
6 $y = $x.'_suffix';
7 error_log($y);
8 }
+1 -1
Ver Arquivo
@@ -1,5 +1,5 @@
Program %s/break3.php loaded. Type '[r]un' or '[c]ontinue' to go.
%Scontinue
continue
break3.php loaded
Program %s/break3.php exited normally.
break \TestNs\foo()
+1 -1
Ver Arquivo
@@ -1,5 +1,5 @@
Program %s/break4.php loaded. Type '[r]un' or '[c]ontinue' to go.
%Sbreak :fb:my:thing::doIt()
break :fb:my:thing::doIt()
Breakpoint 1 set upon entering xhp_fb__my__thing::doIt()
But wont break until class xhp_fb__my__thing has been loaded.
continue
@@ -1,5 +1,5 @@
Program %s/error_bad_cmd_type_receive.php loaded. Type '[r]un' or '[c]ontinue' to go.
%Sbreak error_bad_cmd_type_receive.php:3
break error_bad_cmd_type_receive.php:3
Breakpoint 1 set on line 3 of error_bad_cmd_type_receive.php
But wont break until file error_bad_cmd_type_receive.php has been loaded.
run
@@ -1,5 +1,5 @@
Program %s/error_bad_cmd_type_send.php loaded. Type '[r]un' or '[c]ontinue' to go.
%Sbreak error_bad_cmd_type_send.php:3
break error_bad_cmd_type_send.php:3
Breakpoint 1 set on line 3 of error_bad_cmd_type_send.php
But wont break until file error_bad_cmd_type_send.php has been loaded.
run
@@ -1,5 +1,5 @@
Program %s/error_short_cmd_receive.php loaded. Type '[r]un' or '[c]ontinue' to go.
%Sbreak error_short_cmd_receive.php:3
break error_short_cmd_receive.php:3
Breakpoint 1 set on line 3 of error_short_cmd_receive.php
But wont break until file error_short_cmd_receive.php has been loaded.
run
@@ -1,5 +1,5 @@
Program %s/error_short_cmd_send.php loaded. Type '[r]un' or '[c]ontinue' to go.
%Sbreak error_short_cmd_send.php:3
break error_short_cmd_send.php:3
Breakpoint 1 set on line 3 of error_short_cmd_send.php
But wont break until file error_short_cmd_send.php has been loaded.
run
+1 -1
Ver Arquivo
@@ -1,5 +1,5 @@
Program %s/eval1.php loaded. Type '[r]un' or '[c]ontinue' to go.
%Srun
run
eval1.php loaded
Program %s/eval1.php exited normally.
print function_exists('test1')
+1 -1
Ver Arquivo
@@ -1,5 +1,5 @@
Program %s/exception1.php loaded. Type '[r]un' or '[c]ontinue' to go.
%Sexception MyException
exception MyException
Breakpoint 1 set right before throwing MyException
But note that class MyException has yet been loaded.
break list
+1 -1
Ver Arquivo
@@ -1,5 +1,5 @@
Program %s/flow.php loaded. Type '[r]un' or '[c]ontinue' to go.
%Sbreak cls::pub()
break cls::pub()
Breakpoint 1 set upon entering cls::pub()
But wont break until class cls has been loaded.
run
+1 -1
Ver Arquivo
@@ -1,5 +1,5 @@
Program %s/flow2.php loaded. Type '[r]un' or '[c]ontinue' to go.
%Srun
run
flow2.php done
Program %s/flow2.php exited normally.
break test()
+1 -1
Ver Arquivo
@@ -1,5 +1,5 @@
Program %s/flow_excep.php loaded. Type '[r]un' or '[c]ontinue' to go.
%Sbreak main()
break main()
Breakpoint 1 set upon entering main()
But wont break until function main has been loaded.
run
+1 -1
Ver Arquivo
@@ -1,5 +1,5 @@
Program %s/flow_gen.php loaded. Type '[r]un' or '[c]ontinue' to go.
%Srun
run
flow_gen.php loaded
Program %s/flow_gen.php exited normally.
break flow_gen.php:12
@@ -1,5 +1,5 @@
Program %s/flow_gen_excep.php loaded. Type '[r]un' or '[c]ontinue' to go.
%Srun
run
int(8)
Caught Exception given to continuation 8 in genFoo()
int(4)
@@ -1,5 +1,5 @@
Program %s/flow_multistep.php loaded. Type '[r]un' or '[c]ontinue' to go.
%Sbreak flow_multistep.php:58
break flow_multistep.php:58
Breakpoint 1 set on line 58 of flow_multistep.php
But wont break until file flow_multistep.php has been loaded.
run
+1 -1
Ver Arquivo
@@ -1,5 +1,5 @@
Program %s/flow_small.php loaded. Type '[r]un' or '[c]ontinue' to go.
%Sset SmallStep on
set SmallStep on
SmallStep(ss) set to on.
break cls::pub()
+1 -1
Ver Arquivo
@@ -1,5 +1,5 @@
Program %s/info1.php loaded. Type '[r]un' or '[c]ontinue' to go.
%S@
@
info array_key_exists
/**
+1 -1
Ver Arquivo
@@ -1,5 +1,5 @@
Program %s/list.php loaded. Type '[r]un' or '[c]ontinue' to go.
%Sbr SplMaxHeap::insert()
br SplMaxHeap::insert()
Breakpoint 1 set upon entering SplMaxHeap::insert()
run
Breakpoint 1 reached at SplHeap::insert() on line %d of systemlib.php
+1 -1
Ver Arquivo
@@ -1,5 +1,5 @@
Program %s/printThis.php loaded. Type '[r]un' or '[c]ontinue' to go.
%Sbreak printThis.php:5
break printThis.php:5
Breakpoint 1 set on line 5 of printThis.php
But wont break until file printThis.php has been loaded.
run
+1 -1
Ver Arquivo
@@ -1,5 +1,5 @@
Program %s/stack1.php loaded. Type '[r]un' or '[c]ontinue' to go.
%Srun
run
stack1.php loaded
Program %s/stack1.php exited normally.
break bar()
+12 -6
Ver Arquivo
@@ -255,6 +255,7 @@ function extra_args($options) {
return idx($options, 'args', '');
}
// Return the command and the env to run it in.
function hhvm_cmd($options, $test, $test_run = null) {
if ($test_run === null) {
$test_run = $test;
@@ -271,12 +272,17 @@ function hhvm_cmd($options, $test, $test_run = null) {
'--file',
escapeshellarg($test_run)
));
$env = $_ENV;
$in = find_test_ext($test, 'in');
if ($in !== null) {
$cmd .= ' < ' . escapeshellarg($in);
// If we're piping the input into the command then setup a simple
// dumb terminal so hhvm doesn't try to control it and pollute the
// output with control characters, which could change depending on
// a wide variety of terminal settings.
$env["TERM"] = "dumb";
}
return $cmd;
return array($cmd, $env);
}
function hphp_cmd($options, $test) {
@@ -432,14 +438,14 @@ function skip_test($options, $test) {
return false;
}
$hhvm = hhvm_cmd($options, $test, $skipif_test);
list($hhvm, $_) = hhvm_cmd($options, $test, $skipif_test);
$out = shell_exec($hhvm . ' 2> /dev/null');
$out = trim($out);
return (bool)strlen($out);
}
function run_test($options, $test) {
$hhvm = hhvm_cmd($options, $test);
list($hhvm, $hhvm_env) = hhvm_cmd($options, $test);
$hhvm = __DIR__."/../tools/timeout.sh -t 300 $hhvm";
$output = "";
@@ -466,7 +472,7 @@ function run_test($options, $test) {
1 => array("pipe", "w"),
2 => array("pipe", "w"),
);
$process = proc_open("$hhvm 2>&1", $descriptorspec, $pipes);
$process = proc_open("$hhvm 2>&1", $descriptorspec, $pipes, null, $hhvm_env);
if (!is_resource($process)) {
file_put_contents("$test.diff", "Couldn't invoke $hhvm");
return false;
@@ -691,7 +697,7 @@ SHIP
print $header_start."Run these by hand:".$header_end;
foreach ($failed as $test) {
$command = hhvm_cmd($options, $test);
list($command, $_) = hhvm_cmd($options, $test);
if (isset($options['repo'])) {
$command .= " -vRepo.Authoritative=true ";
$command = str_replace(verify_hhbc(), "$test.repo/hhvm.hhbc",