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

Add Robot Framework language server (again) #724

Merged
merged 16 commits into from
Jan 8, 2022
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/job.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ env:
PIP_DISABLE_PIP_VERSION_CHECK: 1
PYTHONUNBUFFERED: 1

ATEST_PROCESSES: 2
ATEST_RETRIES: 3
JLPM_CMD: jlpm --ignore-optional --prefer-offline --frozen-lockfile

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ node_modules
*.tgz

atest/output/
.pabotsuitenames
junit.xml
coverage/
.vscode/
Expand Down
5 changes: 3 additions & 2 deletions atest/00_Smoke.robot
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*** Settings ***
Suite Setup Set Screenshot Directory ${SCREENSHOTS DIR}${/}smoke
Resource Keywords.robot
Resource Keywords.resource

Suite Setup Set Screenshot Directory ${SCREENSHOTS DIR}${/}smoke

*** Test Cases ***
Lab Version
Expand Down
81 changes: 54 additions & 27 deletions atest/01_Editor.robot
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
*** Settings ***
Suite Setup Setup Suite For Screenshots editor
Force Tags ui:editor aspect:ls:features
Resource Keywords.robot
Resource Variables.robot
Resource Keywords.resource
Resource Variables.resource

Suite Setup Setup Suite For Screenshots editor

Force Tags ui:editor aspect:ls:features

*** Test Cases ***
Bash
Editor Shows Features for Language Bash example.sh Diagnostics=Failed to parse expression Jump to Definition=fib
Editor Shows Features for Language Bash example.sh Diagnostics=Failed to parse expression
... Jump to Definition=fib

CSS
${def} = Set Variable xpath:(//span[contains(@class, 'cm-variable-2')][contains(text(), '--some-var')])[last()]
Editor Shows Features for Language CSS example.css Diagnostics=Do not use empty rulesets Jump to Definition=${def} Rename=${def}
${def} = Set Variable
... xpath:(//span[contains(@class, 'cm-variable-2')][contains(text(), '--some-var')])[last()]
Editor Shows Features for Language CSS example.css Diagnostics=Do not use empty rulesets
... Jump to Definition=${def} Rename=${def}

Docker
${def} = Set Variable xpath://span[contains(@class, 'cm-string')][contains(text(), 'PLANET')]
Wait Until Keyword Succeeds 3x 100ms Editor Shows Features for Language Docker Dockerfile Diagnostics=Instructions should be written in uppercase letters
... Jump to Definition=${def} Rename=${def}
Wait Until Keyword Succeeds 3x 100ms Editor Shows Features for Language Docker Dockerfile
... Diagnostics=Instructions should be written in uppercase letters Jump to Definition=${def}
... Rename=${def}

JS
${def} = Set Variable xpath:(//span[contains(@class, 'cm-variable')][contains(text(), 'fib')])[last()]
Editor Shows Features for Language JS example.js Diagnostics=Expression expected Jump to Definition=${def} Rename=${def}
Editor Shows Features for Language JS example.js Diagnostics=Expression expected
... Jump to Definition=${def} Rename=${def}

JSON
Editor Shows Features for Language JSON example.json Diagnostics=Duplicate object key

JSX
${def} = Set Variable xpath:(//span[contains(@class, 'cm-variable')][contains(text(), 'hello')])[last()]
Editor Shows Features for Language JSX example.jsx Diagnostics=Expression expected Jump to Definition=${def} Rename=${def}
#Julia
Editor Shows Features for Language JSX example.jsx Diagnostics=Expression expected
... Jump to Definition=${def} Rename=${def}
# Julia
# ${def} = Set Variable xpath:(//span[contains(@class, 'cm-builtin')][contains(text(), 'add_together')])[last()]
# Editor Shows Features for Language Julia example.jl Jump to Definition=${def} Rename=${def}

Expand All @@ -38,34 +46,48 @@ LaTeX

Less
${def} = Set Variable xpath:(//span[contains(@class, 'cm-variable-2')][contains(text(), '@width')])[last()]
Editor Shows Features for Language Less example.less Diagnostics=Do not use empty rulesets Jump to Definition=${def}
Editor Shows Features for Language Less example.less Diagnostics=Do not use empty rulesets
... Jump to Definition=${def}

Markdown
Editor Shows Features for Language Markdown example.md Diagnostics=`Color` is misspelt

Python (pylsp)
${def} = Set Variable xpath:(//span[contains(@class, 'cm-variable')][contains(text(), 'fib')])[last()]
Editor Shows Features for Server pylsp Python example.py Diagnostics=undefined name 'result' (pyflakes) Jump to Definition=${def} Rename=${def}
Editor Shows Features for Server pylsp Python example.py Diagnostics=undefined name 'result' (pyflakes)
... Jump to Definition=${def} Rename=${def}

Python (pyright)
${def} = Set Variable xpath:(//span[contains(@class, 'cm-variable')][contains(text(), 'fib')])[last()]
Editor Shows Features for Server pyright Python example.py Diagnostics=is not defined (Pyright) Jump to Definition=${def}
Editor Shows Features for Server pyright Python example.py Diagnostics=is not defined (Pyright)
... Jump to Definition=${def}

R
${def} = Set Variable xpath:(//span[contains(@class, 'cm-variable')][contains(text(), 'fib')])[last()]
Editor Shows Features for Language R example.R Diagnostics=Put spaces around all infix operators Jump to Definition=${def}
Editor Shows Features for Language R example.R Diagnostics=Put spaces around all infix operators
... Jump to Definition=${def}

Robot Framework
[Tags] gh:332
${def} = Set Variable xpath:(//span[contains(@class, 'cm-keyword')][contains(text(), 'Special Log')])[last()]
Editor Shows Features for Language Robot Framework example.robot Diagnostics=Undefined keyword
... Jump to Definition=${def}

SCSS
${def} = Set Variable xpath:(//span[contains(@class, 'cm-variable-2')][contains(text(), 'primary-color')])[last()]
Editor Shows Features for Language SCSS example.scss Diagnostics=Do not use empty rulesets Jump to Definition=${def}
${def} = Set Variable
... xpath:(//span[contains(@class, 'cm-variable-2')][contains(text(), 'primary-color')])[last()]
Editor Shows Features for Language SCSS example.scss Diagnostics=Do not use empty rulesets
... Jump to Definition=${def}

TSX
${def} = Set Variable xpath:(//span[contains(@class, 'cm-tag')][contains(text(), 'HelloWorld')])[last()]
Editor Shows Features for Language TSX example.tsx Diagnostics='hello' is declared but its value is never read. Jump to Definition=${def} Rename=${def}
Editor Shows Features for Language TSX example.tsx
... Diagnostics='hello' is declared but its value is never read. Jump to Definition=${def} Rename=${def}

TypeScript
${def} = Set Variable xpath:(//span[contains(@class, 'cm-variable')][contains(text(), 'inc')])[last()]
Editor Shows Features for Language TypeScript example.ts Diagnostics=The left-hand side of an arithmetic Jump to Definition=${def} Rename=${def}
Editor Shows Features for Language TypeScript example.ts Diagnostics=The left-hand side of an arithmetic
... Jump to Definition=${def} Rename=${def}

SQL
Editor Shows Features for Language SQL example.sql Diagnostics=Expected
Expand All @@ -90,9 +112,13 @@ Editor Shows Features for Language
Wait Until Fully Initialized
# Run Keyword If "${Language}" == "Julia" Sleep 5s
FOR ${f} IN @{features}
Run Keyword If "${f}" == "Diagnostics" Editor Should Show Diagnostics ${features["${f}"]}
... ELSE IF "${f}" == "Jump to Definition" Editor Should Jump To Definition ${features["${f}"]}
... ELSE IF "${f}" == "Rename" Editor Should Rename ${features["${f}"]}
IF "${f}" == "Diagnostics"
Editor Should Show Diagnostics ${features["${f}"]}
ELSE IF "${f}" == "Jump to Definition"
Editor Should Jump To Definition ${features["${f}"]}
ELSE IF "${f}" == "Rename"
Editor Should Rename ${features["${f}"]}
END
END
Capture Page Screenshot 99-done.png
[Teardown] Clean Up After Working With File ${file}
Expand All @@ -110,16 +136,17 @@ Editor Should Show Diagnostics

Editor Content Changed
[Arguments] ${old_content}
${new_content} Get Editor Content
${new_content} = Get Editor Content
Should Not Be Equal ${old_content} ${new_content}
[Return] ${new_content}

Editor Should Rename
[Arguments] ${symbol}
Set Tags feature:rename
${sel} = Set Variable If "${symbol}".startswith(("xpath", "css")) ${symbol} xpath:(//span[@role="presentation"][contains(., "${symbol}")])[last()]
${sel} = Set Variable If "${symbol}".startswith(("xpath", "css")) ${symbol}
... xpath:(//span[@role="presentation"][contains(., "${symbol}")])[last()]
Open Context Menu Over ${sel}
${old_content} Get Editor Content
${old_content} = Get Editor Content
Capture Page Screenshot 03-rename-0.png
Mouse Over ${MENU RENAME}
Capture Page Screenshot 03-rename-1.png
Expand All @@ -128,5 +155,5 @@ Editor Should Rename
Input Into Dialog new_name
Sleep 2s
Capture Page Screenshot 03-rename-3.png
${new_content} Wait Until Keyword Succeeds 10 x 0.1 s Editor Content Changed ${old_content}
${new_content} = Wait Until Keyword Succeeds 10 x 0.1 s Editor Content Changed ${old_content}
Should Be True "new_name" in """${new_content}"""
5 changes: 3 additions & 2 deletions atest/02_Settings.robot
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*** Settings ***
Suite Setup Setup Suite For Screenshots settings
Resource Keywords.robot
Resource Keywords.resource

Suite Setup Setup Suite For Screenshots settings

*** Test Cases ***
Settings
Expand Down
10 changes: 6 additions & 4 deletions atest/03_Notebook.robot
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
*** Settings ***
Suite Setup Setup Suite For Screenshots notebook
Test Setup Try to Close All Tabs
Resource Keywords.robot
Resource Keywords.resource

Suite Setup Setup Suite For Screenshots notebook
Test Setup Try to Close All Tabs

*** Test Cases ***
Python
Expand Down Expand Up @@ -70,7 +71,8 @@ Code Overrides
Wait Until Created ${virtual_path}
Wait Until Keyword Succeeds 10x 1s File Should Not Be Empty ${virtual_path}
${document} = Get File ${virtual_path}
Should Be Equal ${document} get_ipython().run_line_magic("ls", "")\n\n\nget_ipython().run_line_magic("pip", " freeze")\n
Should Be Equal ${document}
... get_ipython().run_line_magic("ls", "")\n\n\nget_ipython().run_line_magic("pip", " freeze")\n
[Teardown] Clean Up After Working With File Code overrides.ipynb

Adding Text To Cells Is Reflected In Virtual Document
Expand Down
11 changes: 6 additions & 5 deletions atest/04_Interface/BackendFailure.robot
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
*** Settings ***
Suite Setup Setup Server and Browser server_extension_enabled=${False}
Suite Teardown Setup Server and Browser server_extension_enabled=${True}
Resource ../Keywords.robot
Resource ../Keywords.resource

Suite Setup Setup Server and Browser server_extension_enabled=${False}
Suite Teardown Setup Server and Browser server_extension_enabled=${True}

*** Variables ***
${STATUSBAR} css:div.lsp-statusbar-item
${POPOVER} css:.lsp-popover
${STATUSBAR} css:div.lsp-statusbar-item
${POPOVER} css:.lsp-popover

*** Test Cases ***
Handles Server Extension Failure
Expand Down
52 changes: 31 additions & 21 deletions atest/04_Interface/DiagnosticsPanel.robot
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
*** Settings ***
Suite Setup Setup Suite For Screenshots diagnostics_panel
Resource ../Keywords.robot
Force Tags ui:notebook aspect:ls:features
Test Setup Set Up
Test Teardown Clean Up
Resource ../Keywords.resource

Suite Setup Setup Suite For Screenshots diagnostics_panel
Test Setup Set Up
Test Teardown Clean Up

Force Tags ui:notebook aspect:ls:features

*** Variables ***
${EXPECTED_COUNT} 4
${DIAGNOSTIC} W291 trailing whitespace (pycodestyle)
${DIAGNOSTIC MESSAGE} trailing whitespace
${DIAGNOSTIC MESSAGE R} Closing curly-braces should always be on their own line
${R CELL} %%R\n{}
${MENU COLUMNS} xpath://div[contains(@class, 'lm-Menu-itemLabel')][contains(text(), "columns")]
${DIAGNOSTIC MESSAGE R} Closing curly-braces should always be on their own line
${DIAGNOSTIC MESSAGE} trailing whitespace
${DIAGNOSTIC} W291 trailing whitespace (pycodestyle)
${EXPECTED_COUNT} 4
${MENU COLUMNS} xpath://div[contains(@class, 'lm-Menu-itemLabel')][contains(text(), "columns")]
${R CELL} %%R\n{}

*** Test Cases ***
Diagnostics Panel Opens
Expand Down Expand Up @@ -45,17 +47,20 @@ Diagnostics Panel Can Be Restored
Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count ${EXPECTED_COUNT}

Columns Can Be Hidden
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL} ${DIAGNOSTIC MESSAGE}
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL}
... ${DIAGNOSTIC MESSAGE}
Open Context Menu Over css:.lsp-diagnostics-listing th
Capture Page Screenshot 01-menu-visible.png
Expand Menu Entry columns
Select Menu Entry Message
Capture Page Screenshot 03-message-column-toggled.png
Wait Until Keyword Succeeds 10 x 1s Element Should Not Contain ${DIAGNOSTICS PANEL} ${DIAGNOSTIC MESSAGE}
Wait Until Keyword Succeeds 10 x 1s Element Should Not Contain ${DIAGNOSTICS PANEL}
... ${DIAGNOSTIC MESSAGE}

Can Sort By Cell
# https://github.com/jupyter-lsp/jupyterlab-lsp/issues/707
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL} ${DIAGNOSTIC MESSAGE}
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL}
... ${DIAGNOSTIC MESSAGE}
Click Element css:.lsp-diagnostics-listing th[data-id="Line:Ch"]
Table Cell Should Equal Line:Ch row=1 column=-1
Table Cell Should Equal 0:0 row=2 column=-1
Expand All @@ -68,7 +73,7 @@ Can Sort By Cell
Diagnostics Can Be Ignored By Code
Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count ${EXPECTED_COUNT}
# W291 should be shown twice, lets try to hide it
${EXPECTED_AFTER} Evaluate ${EXPECTED_COUNT}-2
${EXPECTED_AFTER} = Evaluate ${EXPECTED_COUNT}-2
Open Context Menu Over W291
Expand Menu Entry Ignore diagnostics
Select Menu Entry code
Expand All @@ -79,7 +84,7 @@ Diagnostics Can Be Ignored By Code
Diagnostics Can Be Ignored By Message
Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count ${EXPECTED_COUNT}
# W291 should be shown twice, lets try to hide it
${EXPECTED_AFTER} Evaluate ${EXPECTED_COUNT}-2
${EXPECTED_AFTER} = Evaluate ${EXPECTED_COUNT}-2
Open Context Menu Over W291
Expand Menu Entry Ignore diagnostics
Capture Page Screenshot 02-menu-visible.png
Expand All @@ -89,7 +94,8 @@ Diagnostics Can Be Ignored By Message
Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count ${EXPECTED_AFTER}

Diagnostic Message Can Be Copied
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL} ${DIAGNOSTIC MESSAGE}
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL}
... ${DIAGNOSTIC MESSAGE}
Open Context Menu Over css:.lsp-diagnostics-listing tbody tr
Select Menu Entry Copy diagnostic
Close Diagnostics Panel
Expand All @@ -100,16 +106,20 @@ Diagnostics Panel Works After Removing Foreign Document
Lab Command Insert Cell Below
Enter Cell Editor 3
Press Keys None ${R CELL}
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL} ${DIAGNOSTIC MESSAGE}
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL} ${DIAGNOSTIC MESSAGE R}
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL}
... ${DIAGNOSTIC MESSAGE}
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL}
... ${DIAGNOSTIC MESSAGE R}
Lab Command Delete Cells
# regain focus by entering cell
Enter Cell Editor 2
# trigger 7 document updates to trigger the garbage collector that removes unused documents
# (search for VirtualDocument.remainining_lifetime for more)
Press Keys None 1234567
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL} ${DIAGNOSTIC MESSAGE}
Wait Until Keyword Succeeds 10 x 1s Element Should Not Contain ${DIAGNOSTICS PANEL} ${DIAGNOSTIC MESSAGE R}
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL}
... ${DIAGNOSTIC MESSAGE}
Wait Until Keyword Succeeds 10 x 1s Element Should Not Contain ${DIAGNOSTICS PANEL}
... ${DIAGNOSTIC MESSAGE R}

*** Keywords ***
Open Context Menu Over W291
Expand Down
17 changes: 10 additions & 7 deletions atest/04_Interface/Statusbar.robot
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
*** Settings ***
Suite Setup Setup Suite For Screenshots statusbar
Resource ../Keywords.robot
Resource ../Keywords.resource

Suite Setup Setup Suite For Screenshots statusbar

*** Variables ***
${STATUSBAR} css:div.lsp-statusbar-item
${DIAGNOSTIC} W291 trailing whitespace (pycodestyle)
${POPOVER} css:.lsp-popover
${HELP_BUTTON} css:.lsp-popover .lsp-help-button
${STATUSBAR} css:div.lsp-statusbar-item
${DIAGNOSTIC} W291 trailing whitespace (pycodestyle)
${POPOVER} css:.lsp-popover
${HELP_BUTTON} css:.lsp-popover .lsp-help-button

*** Test Cases ***
Statusbar Popup Opens
Expand All @@ -21,7 +22,9 @@ Statusbar Popup Opens
[Teardown] Clean Up After Working With File Python.ipynb

Troubleshooting And Help Is Offered For Known Non-Installed Servers
[Documentation] When specification of a language server has been configured or provided, but the server is not installed (or detected) the user should get help on installation and/or troubleshooting
[Documentation] When specification of a language server has been configured
... or provided, but the server is not installed (or detected) the user
... should get help on installation and/or troubleshooting
Prepare File for Editing Python status example.klingon
Wait Until Element Contains ${STATUSBAR} Initialized (additional servers needed) timeout=60s
Click Element ${STATUSBAR}
Expand Down
Loading