Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow debugging inside __init__.robot files #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions DebugLibrary/steplistener.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import inspect
import os

from .globals import context

Expand Down Expand Up @@ -28,6 +29,13 @@ def _start_keyword(self, name, attrs):
path = attrs['source']
lineno = attrs['lineno']

if path and os.path.isdir(path):
# we might be in folder-wide __init__.robot, but listener args are not telling us that
# - gives us only the folder path.
init_path = os.path.join(path, '__init__.robot')
if os.path.exists(init_path):
path = init_path

if path:
lineno_0_based = lineno - 1
context.current_source_path = path
Expand Down
11 changes: 11 additions & 0 deletions tests/robot/__init__.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*** Settings ***
Library DebugLibrary

Suite Setup Setup


*** Keywords ***
Setup
debug
log to console __init__ working
@{list} = Create List __init__ hello world
File renamed without changes.
26 changes: 21 additions & 5 deletions tests/test_debuglibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ def base_functional_testing():

def step_functional_testing():
global child
# Command "coverage run robot tests/step.robot" does not work,
# Command "coverage run robot tests/robot/step.robot" does not work,
# so start the program using DebugLibrary's shell instead of "robot".
child = pexpect.spawn('coverage',
['run', '--append', 'DebugLibrary/shell.py',
'tests/step.robot'])
'tests/robot'])
child.expect('Type "help" for more information.*>',
timeout=TIMEOUT_SECONDS * 3)

Expand All @@ -114,18 +114,34 @@ def step_functional_testing():
support_source_lineno = get_version() >= '3.2'

if support_source_lineno:

check_command('s', # step
'/tests/robot/__init__.robot.10.*'
'-> log to console __init__ working.*'
'=> BuiltIn.Log To Console __init__ working'
)
check_command('s', # step
'/tests/robot/__init__.robot.11.*'
'@.* = Create List __init__ hello world.*'
'@.* = BuiltIn.Create List __init__ hello world')
check_command('n', # next
'/tests/robot/step.robot.6..*'
'-> debug.*'
'=> DebugLibrary.Debug')
check_command('s', # step
'')
check_command('s', # step
'/tests/step.robot.7..*'
'/tests/robot/step.robot.7..*'
'-> log to console working.*'
'=> BuiltIn.Log To Console working')
check_command('l', # list
' 7 -> log to console working')
check_command('n', # next
'/tests/step.robot.8..*'
'/tests/robot/step.robot.8..*'
'@.* = Create List hello world.*'
'@.* = BuiltIn.Create List hello world')
check_command('', # just repeat last command
'/tests/step.robot.11..*'
'/tests/robot/step.robot.11..*'
'-> log to console another test case.*'
'=> BuiltIn.Log To Console another test case')
check_command('l', # list
Expand Down
Loading