Skip to content

Commit 5ce5e86

Browse files
committed
W119-049 Add --on-hang-script option to tester-run
1 parent 094f132 commit 5ce5e86

File tree

7 files changed

+249
-169
lines changed

7 files changed

+249
-169
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Current features:
1515
* [GNAT project files](https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/gnat_project_manager.html) support.
1616
* Code completion for names, keywords, aggregates, etc.
1717
* Code navigation, such as Go to Definition/Declaration, Find All References, Call Hierarchies, etc.
18-
* Code refactoring like insert named associations, auto-add `with`-clauses.
18+
* [Code refactoring](#refactoring-tools) like insert named associations, auto-add `with`-clauses, etc.
1919
* Document/Workspace symbol search.
2020
* Code folding and formatting.
2121

@@ -97,7 +97,8 @@ You can turn some debugging and experimental features trought
9797
[the traces file](doc/traces.md).
9898

9999
The server also gets configuration via `workspace/didChangeConfiguration`
100-
notification. See more [details here](doc/settings.md). Each LSP
100+
notification and `initializationOptions` of `initialize` request.
101+
See more [details here](doc/settings.md). Each LSP
101102
client provides its-own way to set such settings.
102103

103104
## Supported LSP Server Requests

source/client/lsp-raw_clients.adb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,15 @@ package body LSP.Raw_Clients is
133133
end if;
134134
end Send_Message;
135135

136+
----------------
137+
-- Server_PID --
138+
----------------
139+
140+
function Server_PID (Self : Raw_Client'Class) return String is
141+
begin
142+
return Self.Server.Identifier;
143+
end Server_PID;
144+
136145
-------------------
137146
-- Set_Arguments --
138147
-------------------

source/client/lsp-raw_clients.ads

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ package LSP.Raw_Clients is
114114
-- Return True when server's process is running and send queue is empty,
115115
-- thus send operation can start immidiately.
116116

117+
function Server_PID (Self : Raw_Client'Class) return String;
118+
-- Return server process id (pid) if the server has been started.
119+
117120
private
118121
type Listener (Client : access Raw_Client'Class) is limited
119122
new Spawn.Processes.Process_Listener with null record;

source/tester/tester-run.adb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ procedure Tester.Run is
4141
Long_Name => "debug",
4242
Description => "disable timeouts then pause after server start");
4343

44+
On_Hang : constant VSS.Command_Line.Value_Option :=
45+
(Short_Name => "",
46+
Long_Name => "on-hang-script",
47+
Value_Name => "command_and_args",
48+
Description => "the command to launch if the test hangs");
49+
4450
File : constant VSS.Command_Line.Positional_Option :=
4551
(Name => "test.json",
4652
Description => "JSON test script");
@@ -52,6 +58,7 @@ procedure Tester.Run is
5258
JSON : GNATCOLL.JSON.JSON_Value;
5359
begin
5460
VSS.Command_Line.Add_Option (Options.Debug);
61+
VSS.Command_Line.Add_Option (Options.On_Hang);
5562
VSS.Command_Line.Add_Option (Options.File);
5663
VSS.Command_Line.Process; -- This terminates process on option's error
5764

@@ -69,6 +76,10 @@ begin
6976
(" --" & Options.Debug.Long_Name
7077
& " (-" & Options.Debug.Short_Name & ")"
7178
& " " & Options.Debug.Description);
79+
Usage.Append
80+
(" --" & Options.On_Hang.Long_Name
81+
& "=" & Options.On_Hang.Value_Name
82+
& " " & Options.On_Hang.Description);
7283
VSS.Command_Line.Report_Error (Usage.Join_Lines (VSS.Strings.LF));
7384
end;
7485
end if;
@@ -99,7 +110,10 @@ begin
99110
declare
100111
Test : Tester.Tests.Test;
101112
begin
102-
Test.Run (JSON.Get, Debug => Options.Debug.Is_Specified);
113+
Test.Run
114+
(JSON.Get,
115+
On_Hang => Options.On_Hang.Value,
116+
Debug => Options.Debug.Is_Specified);
103117
end;
104118
end;
105119
end Tester.Run;

0 commit comments

Comments
 (0)