Nuclide HHVM Debugger - Fix flaky test shutdown
[hiphop-php.git] / hphp / test / slow / ext_vsdebug / step.php
blob84ac843fb70e5b2cc663e70fd3919da9311695bf
1 <?hh
2 require(__DIR__ . '/common.inc');
4 $path = __DIR__ . "/step.php.test";
5 $GLOBALS["path"] = $path;
6 $GLOBALS["file"] = "step.php.test";
8 // Calibration mappings:
9 $mapping[9] = 9;
10 $mapping[13] = 13;
11 $GLOBALS['mapping'] = $mapping;
13 function verifyStopLine($frames, $line) {
14 global $path;
16 $msg = json_decode(getNextVsDebugMessage(), true);
17 checkObjEqualRecursively($msg, array(
18 "type" => "event",
19 "event" => "stopped",
20 "body" => array(
21 "threadId" => 1
22 )));
24 sendVsCommand(array(
25 "command" => "stackTrace",
26 "type" => "request",
27 "seq" => 1,
28 "arguments" => array(
29 "threadId" => 1
30 )));
32 $msg = json_decode(getNextVsDebugMessage(), true);
33 checkObjEqualRecursively($msg, array(
34 "type" => "response",
35 "command" => "stackTrace",
36 "request_seq" => 1,
37 "success" => true,
38 "body" => array(
39 "totalFrames" => $frames,
40 "stackFrames" => [
41 array(
42 "source" => array("path" => $path, "name" => $path),
43 "line" => $line,
47 ));
50 function stepCommand($cmd) {
51 sendVsCommand(array(
52 "command" => $cmd,
53 "type" => "request",
54 "seq" => 5,
55 "arguments" => array("threadId" => 1)));
56 $msg = json_decode(getNextVsDebugMessage(), true);
57 checkObjEqualRecursively($msg, array(
58 "type" => "response",
59 "command" => $cmd,
60 "request_seq" => 5,
61 "success" => true));
63 $msg = json_decode(getNextVsDebugMessage(), true);
64 checkObjEqualRecursively($msg, array(
65 "type" => "event",
66 "event" => "continued",
67 "body" => array(
68 "threadId" => 1
69 )));
72 $setBreakpointsCommand = array(
73 "command" => "setBreakpoints",
74 "type" => "request",
75 "seq" => 3,
76 "arguments" => array(
77 "source" =>
78 array(
79 "path" => $path,
80 "name" => "step.php.test"
82 "lines" => [9, 13],
83 "breakpoints" => [
84 array("line" => 9, "condition" => ""),
85 array("line" => 13, "condition" => "")
87 ));
89 $setBreakpointsRepsponse = array(
90 "type" => "response",
91 "command" => "setBreakpoints",
92 "success" => true,
93 "request_seq" => 3,
94 "body" => array(
95 "breakpoints" => array(
96 array("id" => 1, "verified" => false),
97 array("id" => 2, "verified" => false),
98 )));
100 $testProcess = vsDebugLaunch(
101 __DIR__ . '/step.php.test',
102 true,
103 [$setBreakpointsCommand],
105 // Response event
106 $setBreakpointsRepsponse,
108 // New BP event for each breakpoint
109 bpEvent($path, 9, 1, "new", false),
110 bpEvent($path, 13, 1, "new", false),
112 // Resolved BP event for each bp
113 bpEvent($path, 9, 1, "changed", true),
114 bpEvent($path, 13, 1, "changed", true)
118 // Verify we resumed from loader break.
119 $msg = json_decode(getNextVsDebugMessage(), true);
120 checkObjEqualRecursively($msg, array(
121 "type" => "event",
122 "event" => "continued",
123 "body" => array(
124 "allThreadsContinued" => false
125 )));
127 $msg = json_decode(getNextVsDebugMessage(), true);
128 checkObjEqualRecursively($msg, array(
129 "type" => "event",
130 "event" => "continued",
131 "body" => array(
132 "allThreadsContinued" => true,
133 "threadId" => 1
134 )));
136 // Verify we hit breakpoint 1.
137 verifyBpHit(1, 9);
139 // Step over.
140 stepCommand("next");
141 verifyStopLine(1, 10);
143 // Step in
144 stepCommand("stepIn");
145 verifyStopLine(2, 4);
147 // Step over.
148 stepCommand("next");
149 verifyStopLine(2, 5);
151 // Step out.
152 stepCommand("stepOut");
153 verifyStopLine(1, 11);
155 // Step over function.
156 stepCommand("next");
157 verifyStopLine(1, 12);
159 // Continue to location hits bp on the way to the target line.
160 sendVsCommand(array(
161 "command" => "fb_continueToLocation",
162 "type" => "request",
163 "seq" => 5,
164 "arguments" =>
165 array(
166 "threadId" => 1,
167 "source" => array("path" => $path),
168 "line" => 15
169 )));
170 $msg = json_decode(getNextVsDebugMessage(), true);
171 checkObjEqualRecursively($msg, array(
172 "type" => "event",
173 "event" => "output",
174 "body" => array(
175 "category" => "info",
176 )));
178 $msg = json_decode(getNextVsDebugMessage(), true);
179 checkObjEqualRecursively($msg, array(
180 "type" => "response",
181 "command" => "fb_continueToLocation",
182 "request_seq" => 5));
184 $msg = json_decode(getNextVsDebugMessage(), true);
185 checkObjEqualRecursively($msg, array(
186 "type" => "event",
187 "event" => "continued"));
189 verifyBpHit(2, 13);
191 // Resume and exit.
192 resumeAndCleanup($testProcess);