Move the debugger command line test out of the C++ debugger test harness and use the standard harness.

Added a tweak to test/run to make it look for $test.in and, if there is one, to add <$test.in to the command line for running the test. Together with $file.opts and a config.hdf, this makes it possible to fire up a command line debugger for php, feed it with commands, obtain its output and check it against expected output.
Esse commit está contido em:
Herman Venter
2013-05-30 18:32:55 -07:00
commit de sgolemon
commit 5a9d8751af
8 arquivos alterados com 56 adições e 41 exclusões
+11 -10
Ver Arquivo
@@ -33,18 +33,19 @@ you to easily run the .php file without first running the test suite.
These are the allowed extensions:
* .php - The source of the test.
* .expect - The exact string expected output.
* .expectf - The exact string expected output with formating characters.
* .expectregex - A regex that matches the output.
* .out - When you run the test, the output will be stored here.
* .opts - Runtime options to pass to hhvm.
* .hphp_opts - Options passed to hphp when generating a bytecode repo.
* .diff - The diff for .expect tests.
* .php.expect - The exact string expected output.
* .php.expectf - The exact string expected output with formating characters.
* .php.expectregex - A regex that matches the output.
* .php.in - When you run the test, the input will be obtained from here.
* .php.out - When you run the test, the output will be stored here.
* .php.opts - Runtime options to pass to hhvm.
* .php.hphp_opts - Options passed to hphp when generating a bytecode repo.
* .php.diff or hhas.diff - The diff for .expect tests.
* .hhas - HipHop Assembly.
* .norepo - don't run the test in repo mode
* .php.norepo - don't run the test in repo mode
You must have one `.php`; one and only one of `.expect`, `.expectf`, and
`.expectregex`; and the rest are optional.
You must have one `.php`; one and only one of `.php.expect`, `.php.expectf`, and
`.php.expectregex`; and the rest are optional.
Any suite can have a `config.hdf` file in it that will be used. If one isn't
present, then the parent suite it checked recusrivly until we use
+39
Ver Arquivo
@@ -0,0 +1,39 @@
Eval {
EnableXHP = true
AllowHhas = true
EnableHipHopSyntax = true
EnableObjDestructCall = true
Debugger {
EnableDebugger = true
}
}
Repo {
Local.Mode = r-
Central.Path = /var/facebook/hhvm/cli_%{schema}.hhbc
Eval.Mode = readonly
Commit = true
DebugInfo = true
}
MySQL {
ReadTimeout = 5000
}
EnvVariables {
HPHP_INTERPRETER = 1
}
ServerVariables {
ALPHA_CONSOLE = 1
TFBENV = 16777216
}
ErrorHandling {
NoticeFrequency = 1
WarningFrequency = 1
}
ResourceLimit {
SerializationSizeLimit=134217728
}
@@ -0,0 +1 @@
-m debug
+5 -1
Ver Arquivo
@@ -222,7 +222,7 @@ function mode_cmd($options) {
}
function hhvm_cmd($options, $test) {
return implode(" ", array(
$cmd = implode(" ", array(
idx_file($_ENV, 'HHVM', bin_root().'/hphp/hhvm/hhvm'),
'--config',
find_config($test, 'config.hdf'),
@@ -232,6 +232,10 @@ function hhvm_cmd($options, $test) {
'--file',
$test
));
if (file_exists("$test.in")) {
$cmd .= " <$test.in";
}
return $cmd;
}
function hphp_cmd($options, $test) {
-30
Ver Arquivo
@@ -51,7 +51,6 @@ bool TestDebugger::RunTests(const std::string &which) {
unlink("/tmp/hphpd_test_error.log");
RUN_TEST(TestCommandLine);
AsyncFunc<TestDebugger> func(this, &TestDebugger::runServer);
func.start();
@@ -110,35 +109,6 @@ bool TestDebugger::getResponse(const string& path, string& result,
///////////////////////////////////////////////////////////////////////////////
bool TestDebugger::runCommandLineTestCase(string testName) {
string path = Process::GetCurrentDirectory()+"/test/debugger_tests/";
string pathAndName = path+testName;
String s = f_file_get_contents((pathAndName+".expectf").c_str());
string expected = string(s.data(), s.size());
string::size_type pos = 0;
while ((pos = expected.find("%s")) != string::npos) {
expected.replace(pos, 2, path);
}
s = f_file_get_contents((pathAndName+".cmds").c_str());
string cmds = string(s.data(), s.size());
string actual, err;
string filearg = "--file="+pathAndName+".php";
const char *argv[] = {"", "-mdebug", filearg.c_str(), nullptr};
bool ret = Process::Exec(HHVM_PATH, argv, cmds.c_str(),
actual, &err, false);
if (ret && expected != actual) {
f_file_put_contents(pathAndName+".expected", expected);
f_file_put_contents(pathAndName+".out", actual);
ret = false;
}
return Count(ret);
}
bool TestDebugger::TestCommandLine() {
if (!runCommandLineTestCase("printThis")) return false;
return true;
}
bool TestDebugger::TestSanity() {
// first test, server might not be ready yet
bool ret = false;