From 5a9d8751afd0b46bfc3b8e56048625776bbb4d69 Mon Sep 17 00:00:00 2001 From: Herman Venter Date: Thu, 30 May 2013 18:32:55 -0700 Subject: [PATCH] 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. --- hphp/test/README.md | 21 +++++----- hphp/test/quick/debugger/config.hdf | 39 +++++++++++++++++++ .../debugger}/printThis.php | 0 .../debugger/printThis.php.expectf} | 0 .../debugger/printThis.php.in} | 0 hphp/test/quick/debugger/printThis.php.opts | 1 + hphp/test/run | 6 ++- hphp/test/test_debugger.cpp | 30 -------------- 8 files changed, 56 insertions(+), 41 deletions(-) create mode 100644 hphp/test/quick/debugger/config.hdf rename hphp/test/{debugger_tests => quick/debugger}/printThis.php (100%) rename hphp/test/{debugger_tests/printThis.expectf => quick/debugger/printThis.php.expectf} (100%) rename hphp/test/{debugger_tests/printThis.cmds => quick/debugger/printThis.php.in} (100%) create mode 100644 hphp/test/quick/debugger/printThis.php.opts diff --git a/hphp/test/README.md b/hphp/test/README.md index 8c041be87..cfc87ab4d 100644 --- a/hphp/test/README.md +++ b/hphp/test/README.md @@ -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 diff --git a/hphp/test/quick/debugger/config.hdf b/hphp/test/quick/debugger/config.hdf new file mode 100644 index 000000000..97062059f --- /dev/null +++ b/hphp/test/quick/debugger/config.hdf @@ -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 +} diff --git a/hphp/test/debugger_tests/printThis.php b/hphp/test/quick/debugger/printThis.php similarity index 100% rename from hphp/test/debugger_tests/printThis.php rename to hphp/test/quick/debugger/printThis.php diff --git a/hphp/test/debugger_tests/printThis.expectf b/hphp/test/quick/debugger/printThis.php.expectf similarity index 100% rename from hphp/test/debugger_tests/printThis.expectf rename to hphp/test/quick/debugger/printThis.php.expectf diff --git a/hphp/test/debugger_tests/printThis.cmds b/hphp/test/quick/debugger/printThis.php.in similarity index 100% rename from hphp/test/debugger_tests/printThis.cmds rename to hphp/test/quick/debugger/printThis.php.in diff --git a/hphp/test/quick/debugger/printThis.php.opts b/hphp/test/quick/debugger/printThis.php.opts new file mode 100644 index 000000000..cf014a32f --- /dev/null +++ b/hphp/test/quick/debugger/printThis.php.opts @@ -0,0 +1 @@ + -m debug \ No newline at end of file diff --git a/hphp/test/run b/hphp/test/run index b6f92398e..b435af82b 100755 --- a/hphp/test/run +++ b/hphp/test/run @@ -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) { diff --git a/hphp/test/test_debugger.cpp b/hphp/test/test_debugger.cpp index d42354174..0f6b926a4 100644 --- a/hphp/test/test_debugger.cpp +++ b/hphp/test/test_debugger.cpp @@ -51,7 +51,6 @@ bool TestDebugger::RunTests(const std::string &which) { unlink("/tmp/hphpd_test_error.log"); - RUN_TEST(TestCommandLine); AsyncFunc 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;