Skip to content

Commit

Permalink
Properly resolve CURDIR. Fixes #449
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Oct 18, 2021
1 parent 72e7c6f commit 0759292
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,10 @@ def _resolve_builtin(self, var_name, value_if_not_found, log_info):

ret = BUILTIN_VARIABLES_RESOLVED.get(var_name, Sentinel.SENTINEL)
if ret is Sentinel.SENTINEL:
if var_name == "CURDIR":
import os

return os.path.dirname(self._doc.path)
log.info(*log_info)
return value_if_not_found
return ret
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*** Settings ***
Resource ${CURDIR}/lib/my.resource


*** Test Cases ***
Test
Some Keyword
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,19 @@ def test_find_definition_variables_dict_access(
)


def test_find_definition_curdir(workspace, libspec_manager, data_regression):
from robotframework_ls.impl.completion_context import CompletionContext
from robotframework_ls.impl.find_definition import find_definition

workspace.set_root("case_curdir", libspec_manager=libspec_manager)
doc = workspace.get_doc("main.robot")

completion_context = CompletionContext(doc, workspace=workspace.ws)
data_regression.check(
_definitions_to_data_regression(find_definition(completion_context))
)


def test_variables_completions_recursive(workspace, libspec_manager, data_regression):
from robotframework_ls.impl.completion_context import CompletionContext
from robotframework_ls.impl.find_definition import find_definition
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- col_offset: 0
end_col_offset: 37
end_lineno: 2
lineno: 1
source: my.resource

0 comments on commit 0759292

Please sign in to comment.