From 3d0330fd9d41c79113862b848af4366b6a72dfde Mon Sep 17 00:00:00 2001 From: Herman Venter Date: Fri, 7 Jun 2013 18:28:49 -0700 Subject: [PATCH] Provide a command line switch to specify the path to the debugger config file Currently the debugger config file is always expected to be at ~/.hphpd.hdf, except when the debugger is controlled via the API, in which case the API client can specify the path. With these changes the path can now also be specified via the command line. Also, the test runner has been modified to look for an hphpd.hdf file and specify the path to it as a command line option. If present, this file also indicates that tests in the directory must be run in debugger mode, making the .opt files redundant. Note that it is important for tests to be able to control the contents of the config file since debugger output is controlled by it and tests will be brittle unless the config is part of the suite and not controlled by the user running the tests --- hphp/runtime/base/program_functions.cpp | 2 + hphp/test/README.md | 4 ++ hphp/test/quick/debugger/flow.php.norepo | 0 hphp/test/quick/debugger/flow.php.opts | 1 - hphp/test/quick/debugger/flow2.php.norepo | 0 hphp/test/quick/debugger/flow2.php.opts | 1 - .../test/quick/debugger/flow_excep.php.norepo | 0 hphp/test/quick/debugger/flow_excep.php.opts | 1 - hphp/test/quick/debugger/flow_gen.php.norepo | 0 hphp/test/quick/debugger/flow_gen.php.opts | 1 - .../quick/debugger/flow_gen_excep.php.norepo | 0 .../quick/debugger/flow_gen_excep.php.opts | 1 - .../quick/debugger/flow_multistep.php.norepo | 0 .../quick/debugger/flow_multistep.php.opts | 1 - hphp/test/quick/debugger/hphpd.hdf | 68 +++++++++++++++++++ hphp/test/quick/debugger/printThis.php.norepo | 0 hphp/test/quick/debugger/printThis.php.opts | 1 - hphp/test/run | 11 ++- 18 files changed, 84 insertions(+), 8 deletions(-) delete mode 100644 hphp/test/quick/debugger/flow.php.norepo delete mode 100644 hphp/test/quick/debugger/flow.php.opts delete mode 100644 hphp/test/quick/debugger/flow2.php.norepo delete mode 100644 hphp/test/quick/debugger/flow2.php.opts delete mode 100644 hphp/test/quick/debugger/flow_excep.php.norepo delete mode 100644 hphp/test/quick/debugger/flow_excep.php.opts delete mode 100644 hphp/test/quick/debugger/flow_gen.php.norepo delete mode 100644 hphp/test/quick/debugger/flow_gen.php.opts delete mode 100644 hphp/test/quick/debugger/flow_gen_excep.php.norepo delete mode 100644 hphp/test/quick/debugger/flow_gen_excep.php.opts delete mode 100644 hphp/test/quick/debugger/flow_multistep.php.norepo delete mode 100644 hphp/test/quick/debugger/flow_multistep.php.opts create mode 100644 hphp/test/quick/debugger/hphpd.hdf delete mode 100644 hphp/test/quick/debugger/printThis.php.norepo delete mode 100644 hphp/test/quick/debugger/printThis.php.opts diff --git a/hphp/runtime/base/program_functions.cpp b/hphp/runtime/base/program_functions.cpp index f11b03e06..8d7ad20bb 100644 --- a/hphp/runtime/base/program_functions.cpp +++ b/hphp/runtime/base/program_functions.cpp @@ -808,6 +808,8 @@ static int execute_program_impl(int argc, char **argv) { "use specified fd for SSL instead of creating a socket") ("admin-port", value(&po.admin_port)->default_value(-1), "start admin listener at specified port") + ("debug-config", value(&po.debugger_options.configFName), + "load specified debugger config file") ("debug-host,h", value(&po.debugger_options.host), "connect to debugger server at specified address") ("debug-port", value(&po.debugger_options.port)->default_value(-1), diff --git a/hphp/test/README.md b/hphp/test/README.md index cfc87ab4d..f9b36a246 100644 --- a/hphp/test/README.md +++ b/hphp/test/README.md @@ -51,6 +51,10 @@ 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 test/config.hdf. +If a suite contains an `hphpd.hdf` file, all of the files in the suite will be +run with the -m debug and --debug-config _dir_/hphpd.hdf switches added to the +command line. (_dir_ will be replaced by path of the suite directory.) + Name your test in a descriptive manner and when in doubt break your test into many files. You can use comments too so future engineers know if it is a real breakage or they need to change the expected output. diff --git a/hphp/test/quick/debugger/flow.php.norepo b/hphp/test/quick/debugger/flow.php.norepo deleted file mode 100644 index e69de29bb..000000000 diff --git a/hphp/test/quick/debugger/flow.php.opts b/hphp/test/quick/debugger/flow.php.opts deleted file mode 100644 index cf014a32f..000000000 --- a/hphp/test/quick/debugger/flow.php.opts +++ /dev/null @@ -1 +0,0 @@ - -m debug \ No newline at end of file diff --git a/hphp/test/quick/debugger/flow2.php.norepo b/hphp/test/quick/debugger/flow2.php.norepo deleted file mode 100644 index e69de29bb..000000000 diff --git a/hphp/test/quick/debugger/flow2.php.opts b/hphp/test/quick/debugger/flow2.php.opts deleted file mode 100644 index cf014a32f..000000000 --- a/hphp/test/quick/debugger/flow2.php.opts +++ /dev/null @@ -1 +0,0 @@ - -m debug \ No newline at end of file diff --git a/hphp/test/quick/debugger/flow_excep.php.norepo b/hphp/test/quick/debugger/flow_excep.php.norepo deleted file mode 100644 index e69de29bb..000000000 diff --git a/hphp/test/quick/debugger/flow_excep.php.opts b/hphp/test/quick/debugger/flow_excep.php.opts deleted file mode 100644 index cf014a32f..000000000 --- a/hphp/test/quick/debugger/flow_excep.php.opts +++ /dev/null @@ -1 +0,0 @@ - -m debug \ No newline at end of file diff --git a/hphp/test/quick/debugger/flow_gen.php.norepo b/hphp/test/quick/debugger/flow_gen.php.norepo deleted file mode 100644 index e69de29bb..000000000 diff --git a/hphp/test/quick/debugger/flow_gen.php.opts b/hphp/test/quick/debugger/flow_gen.php.opts deleted file mode 100644 index cf014a32f..000000000 --- a/hphp/test/quick/debugger/flow_gen.php.opts +++ /dev/null @@ -1 +0,0 @@ - -m debug \ No newline at end of file diff --git a/hphp/test/quick/debugger/flow_gen_excep.php.norepo b/hphp/test/quick/debugger/flow_gen_excep.php.norepo deleted file mode 100644 index e69de29bb..000000000 diff --git a/hphp/test/quick/debugger/flow_gen_excep.php.opts b/hphp/test/quick/debugger/flow_gen_excep.php.opts deleted file mode 100644 index cf014a32f..000000000 --- a/hphp/test/quick/debugger/flow_gen_excep.php.opts +++ /dev/null @@ -1 +0,0 @@ - -m debug \ No newline at end of file diff --git a/hphp/test/quick/debugger/flow_multistep.php.norepo b/hphp/test/quick/debugger/flow_multistep.php.norepo deleted file mode 100644 index e69de29bb..000000000 diff --git a/hphp/test/quick/debugger/flow_multistep.php.opts b/hphp/test/quick/debugger/flow_multistep.php.opts deleted file mode 100644 index cf014a32f..000000000 --- a/hphp/test/quick/debugger/flow_multistep.php.opts +++ /dev/null @@ -1 +0,0 @@ - -m debug \ No newline at end of file diff --git a/hphp/test/quick/debugger/hphpd.hdf b/hphp/test/quick/debugger/hphpd.hdf new file mode 100644 index 000000000..e32112326 --- /dev/null +++ b/hphp/test/quick/debugger/hphpd.hdf @@ -0,0 +1,68 @@ +UTF8 = 1 +Color = 0 +Color { + SupportedNames { + 1 = black + 2 = red + 3 = green + 4 = brown + 5 = blue + 6 = magenta + 7 = cyan + 8 = gray + 9 = dark_gray + 10 = light_red + 11 = light_green + 12 = yellow + 13 = light_blue + 14 = light_magenta + 15 = light_cyan + 16 = white + } + Palette { + emacs { + Keyword = CYAN + Comment = RED + String = GREEN + Variable = BROWN + Html = GRAY + Tag = MAGENTA + Declaration = BLUE + Constant = MAGENTA + LineNo = GRAY + } + vim { + Keyword = MAGENTA + Comment = BLUE + String = RED + Variable = CYAN + Html = GRAY + Tag = MAGENTA + Declaration = WHITE + Constant = WHITE + LineNo = GRAY + } + } + Help = BROWN + Info = GREEN + Output = CYAN + Error = RED + ItemName = GRAY + HighlightForeground = RED + HighlightBackground = GRAY + Code { + Keyword = CYAN + Comment = RED + String = GREEN + Variable = BROWN + Html = GRAY + Tag = MAGENTA + Declaration = BLUE + Constant = MAGENTA + LineNo = GRAY + } +} +Tutorial = 0 +Tutorial { +} +MaxCodeLines = -1 diff --git a/hphp/test/quick/debugger/printThis.php.norepo b/hphp/test/quick/debugger/printThis.php.norepo deleted file mode 100644 index e69de29bb..000000000 diff --git a/hphp/test/quick/debugger/printThis.php.opts b/hphp/test/quick/debugger/printThis.php.opts deleted file mode 100644 index cf014a32f..000000000 --- a/hphp/test/quick/debugger/printThis.php.opts +++ /dev/null @@ -1 +0,0 @@ - -m debug \ No newline at end of file diff --git a/hphp/test/run b/hphp/test/run index 259692317..a8cd9dc0a 100755 --- a/hphp/test/run +++ b/hphp/test/run @@ -209,6 +209,14 @@ function find_config_for_dir($dir, $name) { return __DIR__.'/'.$name; } +function find_debug_config($test, $name) { + $debug_config = find_config_for_dir(dirname($test), $name); + if (is_file($debug_config)) { + return "-m debug --debug-config ".$debug_config; + } + return ""; +} + function mode_cmd($options) { $repo_args = "-v Repo.Local.Mode=-- -v Repo.Central.Path=".verify_hhbc(); $jit_args = "$repo_args -v Eval.Jit=true -v Eval.JitEnableRenameFunction=true"; @@ -229,6 +237,7 @@ function hhvm_cmd($options, $test) { idx_file($_ENV, 'HHVM_BIN', bin_root().'/hphp/hhvm/hhvm'), '--config', find_config($test, 'config.hdf'), + find_debug_config($test, 'hphpd.hdf'), mode_cmd($options), '-v Eval.EnableArgsInBacktraces=true', read_file("$test.opts"), @@ -368,7 +377,7 @@ function run_test($options, $test) { $hhvm = hhvm_cmd($options, $test); $output = ""; if (isset($options['repo'])) { - if (strpos($test, '.hhas') !== false || is_file($test.'.norepo')) { + if (strpos($test, '.hhas') !== false || strpos($hhvm, '-m debug') != false || is_file($test.'.norepo')) { # We don't have a way to skip, I guess run non-repo? } else { unlink("$test.repo/hhvm.hhbc");