Skip to content

Commit 799de3e

Browse files
committed
improve support for vscode test explorer
1 parent 3d9d2a6 commit 799de3e

File tree

15 files changed

+634
-220
lines changed

15 files changed

+634
-220
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ RobotFramework Language Server and client for Visual Studio Code.
55

66
## Requirements
77

8-
* Python 3.9 or above
8+
* Python 3.8 or above
99
* Robotframework 4.0 and above
10-
* VSCode version 1.59 and above
10+
* VSCode version 1.60 and above
1111

1212
## Installation
1313

@@ -40,6 +40,6 @@ Download the vscode-package artifact from the latest [CI/Actions](https://github
4040
* Hover Information
4141
* Document Symbols
4242
* Loading Library/Resources with support for builtin variables
43-
43+
* Support for VSCode test explorer
4444

4545
... more comming soon

package.json

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Robot Framework support for Visual Studio Code",
55
"icon": "images/icon.png",
66
"publisher": "d-biehl",
7-
"version": "0.2.0-alpha.0",
7+
"version": "0.2.0-alpha.0",
88
"repository": {
99
"type": "git",
1010
"url": "https://github.com/d-biehl/robotcode.git"
@@ -383,7 +383,10 @@
383383
"pretest": "npm run compile && npm run lint",
384384
"lint": "eslint --ext .ts,.tsx,.js .",
385385
"lint-fix": "eslint --ext .ts,.tsx,.js --fix .",
386-
"test": "node ./out/test/runTest.js"
386+
"test": "node ./out/test/runTest.js",
387+
"download-api": "vscode-dts dev",
388+
"postdownload-api": "vscode-dts main",
389+
"_postinstall": "npm run download-api"
387390
},
388391
"extensionDependencies": [
389392
"ms-python.python"
@@ -395,10 +398,10 @@
395398
"devDependencies": {
396399
"@types/glob": "^7.1.4",
397400
"@types/mocha": "^9.0.0",
398-
"@types/node": "^16.7.10",
401+
"@types/node": "^16.9.1",
399402
"@types/vscode": "^1.60.0",
400-
"@typescript-eslint/eslint-plugin": "^4.30.0",
401-
"@typescript-eslint/parser": "^4.30.0",
403+
"@typescript-eslint/eslint-plugin": "^4.31.1",
404+
"@typescript-eslint/parser": "^4.31.1",
402405
"eslint": "^7.32.0",
403406
"eslint-config-airbnb": "^18.2.1",
404407
"eslint-config-prettier": "^8.3.0",
@@ -413,13 +416,14 @@
413416
"eslint-plugin-react-hooks": "^4.2.0",
414417
"glob": "^7.1.7",
415418
"mocha": "^9.1.1",
416-
"prettier": "^2.3.2",
419+
"prettier": "^2.4.0",
417420
"ts-loader": "^9.2.5",
418-
"typescript": "^4.4.2",
419-
"vsce": "^1.96.3",
421+
"typescript": "^4.4.3",
422+
"vsce": "^1.99.0",
420423
"vscode-debugadapter-testsupport": "^1.49.0",
421424
"vscode-test": "^1.6.1",
422-
"webpack": "^5.51.2",
423-
"webpack-cli": "^4.8.0"
425+
"webpack": "^5.52.1",
426+
"webpack-cli": "^4.8.0",
427+
"vscode-dts": "^0.3.1"
424428
}
425429
}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include = ["robotcode/py.typed", "README.md"]
77
exclude = ["robotcode/external"]
88

99
[tool.poetry.dependencies]
10-
python = "^3.9"
10+
python = "^3.8"
1111
robotframework = "^4.0.0"
1212

1313

robotcode/debugger/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ async def start_debugpy_async() -> None:
197197
Debugger.instance().output_messages = output_messages
198198
Debugger.instance().output_log = output_log
199199
Debugger.instance().group_output = group_output
200-
200+
Debugger.instance().no_debug = no_debug
201201
Debugger.instance().set_main_thread(threading.current_thread())
202202
Debugger.instance().start()
203203

robotcode/debugger/debugger.py

Lines changed: 63 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ def __init__(self) -> None:
184184
self.hit_counts: Dict[HitCountEntry, int] = {}
185185
self.last_fail_message: Optional[str] = None
186186
self.stop_on_entry = False
187+
self.no_debug = False
188+
189+
@property
190+
def debug(self) -> bool:
191+
return not self.no_debug
187192

188193
@property
189194
def robot_report_file(self) -> Optional[str]:
@@ -549,35 +554,37 @@ def start_suite(self, name: str, attributes: Dict[str, Any]) -> None:
549554

550555
entry = self.add_stackframe_entry(longname, type, source, line_no)
551556

552-
if self.stop_on_entry:
553-
self.stop_on_entry = False
557+
if self.debug:
558+
if self.stop_on_entry:
559+
self.stop_on_entry = False
554560

555-
self.state = State.Paused
556-
self.send_event(
557-
self,
558-
StoppedEvent(
559-
body=StoppedEventBody(
560-
reason=StoppedReason.ENTRY,
561-
thread_id=threading.current_thread().ident,
562-
)
563-
),
564-
)
561+
self.state = State.Paused
562+
self.send_event(
563+
self,
564+
StoppedEvent(
565+
body=StoppedEventBody(
566+
reason=StoppedReason.ENTRY,
567+
thread_id=threading.current_thread().ident,
568+
)
569+
),
570+
)
565571

566-
self.wait_for_running()
567-
elif entry.source:
568-
self.process_start_state(entry.source, entry.line, entry.type, status)
572+
self.wait_for_running()
573+
elif entry.source:
574+
self.process_start_state(entry.source, entry.line, entry.type, status)
569575

570-
self.wait_for_running()
576+
self.wait_for_running()
571577

572578
def end_suite(self, name: str, attributes: Dict[str, Any]) -> None:
573-
status = attributes.get("status", "")
574-
575-
self.process_end_state(
576-
status,
577-
"failed_suite",
578-
"Suite failed.",
579-
f"Suite failed{f': {v}' if (v:=attributes.get('message', None)) else ''}",
580-
)
579+
if self.debug:
580+
status = attributes.get("status", "")
581+
582+
self.process_end_state(
583+
status,
584+
"failed_suite",
585+
"Suite failed.",
586+
f"Suite failed{f': {v}' if (v:=attributes.get('message', None)) else ''}",
587+
)
581588

582589
if self.stack_frames:
583590
self.stack_frames.popleft()
@@ -592,20 +599,22 @@ def start_test(self, name: str, attributes: Dict[str, Any]) -> None:
592599

593600
entry = self.add_stackframe_entry(longname, type, source, line_no)
594601

595-
if entry.source:
596-
self.process_start_state(entry.source, entry.line, entry.type, status)
602+
if self.debug:
603+
if entry.source:
604+
self.process_start_state(entry.source, entry.line, entry.type, status)
597605

598-
self.wait_for_running()
606+
self.wait_for_running()
599607

600608
def end_test(self, name: str, attributes: Dict[str, Any]) -> None:
601-
status = attributes.get("status", "")
602-
603-
self.process_end_state(
604-
status,
605-
"failed_test",
606-
"Test failed.",
607-
f"Test failed{f': {v}' if (v:=attributes.get('message', None)) else ''}",
608-
)
609+
if self.debug:
610+
status = attributes.get("status", "")
611+
612+
self.process_end_state(
613+
status,
614+
"failed_test",
615+
"Test failed.",
616+
f"Test failed{f': {v}' if (v:=attributes.get('message', None)) else ''}",
617+
)
609618

610619
if self.stack_frames:
611620
self.stack_frames.popleft()
@@ -623,18 +632,20 @@ def start_keyword(self, name: str, attributes: Dict[str, Any]) -> None:
623632

624633
entry = self.add_stackframe_entry(kwname, type, source, line_no)
625634

626-
if entry.source:
627-
self.process_start_state(entry.source, entry.line, entry.type, status)
635+
if self.debug:
636+
if entry.source:
637+
self.process_start_state(entry.source, entry.line, entry.type, status)
628638

629-
self.wait_for_running()
639+
self.wait_for_running()
630640

631641
def end_keyword(self, name: str, attributes: Dict[str, Any]) -> None:
632-
status = attributes.get("status", "")
642+
if self.debug:
643+
status = attributes.get("status", "")
633644

634-
if status == "NOT RUN":
635-
return
636-
637-
self.process_end_state(status, "failed_keyword", "Keyword failed.", f"Keyword failed: {self.last_fail_message}")
645+
if status != "NOT RUN":
646+
self.process_end_state(
647+
status, "failed_keyword", "Keyword failed.", f"Keyword failed: {self.last_fail_message}"
648+
)
638649

639650
if self.stack_frames:
640651
self.stack_frames.popleft()
@@ -674,12 +685,20 @@ def log_message(self, message: Dict[str, Any]) -> None:
674685
if message["level"] == "FAIL":
675686
self.last_fail_message = message["message"]
676687

688+
current_frame = self.stack_frames[-1] if self.stack_frames else None
689+
source = Source(path=current_frame.source) if current_frame else None
690+
line = current_frame.line - 1 if current_frame else None
691+
677692
if self.output_log:
678693
self.send_event(
679694
self,
680695
OutputEvent(
681696
body=OutputEventBody(
682-
output="LOG> {timestamp} {level}: {message}\n".format(**message), category="log"
697+
output="LOG> {timestamp} {level}: {message}\n".format(**message),
698+
category="log",
699+
source=source,
700+
line=line,
701+
column=0 if source is not None else None,
683702
)
684703
),
685704
)

0 commit comments

Comments
 (0)