Skip to content

Commit b05ef28

Browse files
committed
Cucumber tests for testing deeper stacks
1 parent 4b62410 commit b05ef28

File tree

5 files changed

+59
-2
lines changed

5 files changed

+59
-2
lines changed

features/correct_window_setup.feature

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,22 @@ Feature: Correct window setup
3030
When I step over
3131
Then the first item on the stack should show the file example.php
3232
And the first item on the stack should show line 3
33+
34+
Scenario: Reading the stack window with multiple files
35+
Given I have a file example.php containing
36+
"""
37+
<?php
38+
include "example2.php";
39+
?>
40+
"""
41+
And I have a file example2.php containing
42+
"""
43+
<?php
44+
$var1 = 1;
45+
$var2 = array("hello", "world");
46+
?>
47+
"""
48+
And I start the debugger with the PHP script example.php
49+
When I step in
50+
Then item 1 on the stack should show the file example2.php
51+
And item 1 on the stack should show line 2

features/step_definitions/debugger_command_steps.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@
22
vdebug.step_over
33
vdebug.running?.should be(true), 'Vdebug is not running'
44
end
5+
6+
When "I step in" do
7+
vdebug.step_in
8+
vdebug.running?.should be(true), 'Vdebug is not running'
9+
end

features/step_definitions/stack_window_steps.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,17 @@
55
Then "the first item on the stack should show line $line" do |line|
66
vdebug.stack.first[:line].should == line
77
end
8+
9+
Then "item $item on the stack should show the file $file" do |idx, file|
10+
idx = idx.to_i
11+
stack_length = vdebug.stack.length
12+
stack_length.should be >= idx, "There are only #{stack_length} items on the stack"
13+
vdebug.stack[idx-1][:file].should include file
14+
end
15+
16+
Then "item $item on the stack should show line $line" do |idx, line|
17+
idx = idx.to_i
18+
stack_length = vdebug.stack.length
19+
stack_length.should be >= idx, "There are only #{stack_length} items on the stack"
20+
vdebug.stack[idx-1][:line].should == line
21+
end

features/support/helpers.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@ def kill_vim
1919
end
2020

2121
module ScriptRunner
22+
STDERR_FILE = "error.out"
23+
2224
def run_php_script(path)
2325
fork_and_run "php -c #{PHP_INI}", Shellwords.escape(path)
2426
end
2527

28+
def stderr_contents
29+
File.read(STDERR_FILE)
30+
end
31+
2632
def fork_and_run(bin, argstr)
2733
fork do
28-
exec %Q{XDEBUG_CONFIG="idekey=something" /usr/bin/env #{bin} #{argstr}}
34+
exec %Q{XDEBUG_CONFIG="idekey=something" /usr/bin/env #{bin} #{argstr} 2>#{STDERR_FILE}}
2935
exit!
3036
end
3137
sleep 0.5

rubylib/vdebug.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,23 @@ def start_listening
1313
sleep 1
1414
end
1515

16+
def messages
17+
vim.command("messages")
18+
end
19+
20+
def step_to_line(number)
21+
vim.command "#{number}"
22+
vim.command "python debugger.run_to_cursor()"
23+
end
24+
1625
def step_over
1726
vim.command 'python debugger.step_over()'
1827
end
1928

29+
def step_in
30+
vim.command 'python debugger.step_into()'
31+
end
32+
2033
# Retrieve a hash with the buffer names (values) and numbers (keys)
2134
def buffers
2235
@buffers ||= fetch_buffers
@@ -64,7 +77,7 @@ def stack_window_content
6477
def stack
6578
stack_window_content.split("\n").map { |l|
6679
s = {}
67-
matches = /^\[(\d+)\] {([^}]+)} @ ([^:]+):(\d+)/.match(l)
80+
matches = /^\[(\d+)\] (\S+) @ ([^:]+):(\d+)/.match(l)
6881
if matches
6982
s[:level] = matches[1]
7083
s[:name] = matches[2]

0 commit comments

Comments
 (0)