1
1
-- ----------------------------------------------------------------------------
2
2
-- Language Server Protocol --
3
3
-- --
4
- -- Copyright (C) 2018-2019 , AdaCore --
4
+ -- Copyright (C) 2018-2023 , AdaCore --
5
5
-- --
6
6
-- This is free software; you can redistribute it and/or modify it under --
7
7
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -21,35 +21,72 @@ with Ada.Strings.Unbounded;
21
21
with Ada.Text_IO ;
22
22
with GNATCOLL.JSON ;
23
23
24
- with Tester.Macros ;
25
- with Tester.Tests ;
24
+ with VSS.Command_Line ;
25
+ with VSS.Strings ;
26
+ with VSS.Strings.Conversions ;
27
+ with VSS.String_Vectors ;
26
28
27
29
with Spawn.Environments ;
28
30
31
+ with Tester.Macros ;
32
+ with Tester.Tests ;
33
+
29
34
procedure Tester.Run is
35
+
36
+ package Options is
37
+ -- Command line options and arguments
38
+
39
+ Debug : constant VSS.Command_Line.Binary_Option :=
40
+ (Short_Name => " d" ,
41
+ Long_Name => " debug" ,
42
+ Description => " disable timeouts then pause after server start" );
43
+
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
+
50
+ File : constant VSS.Command_Line.Positional_Option :=
51
+ (Name => " test.json" ,
52
+ Description => " JSON test script" );
53
+ end Options ;
54
+
30
55
Env : constant Spawn.Environments.Process_Environment :=
31
56
Spawn.Environments.System_Environment;
32
57
33
58
JSON : GNATCOLL.JSON.JSON_Value;
34
59
begin
35
- if not (Ada.Command_Line.Argument_Count = 1
36
- or else (Ada.Command_Line.Argument_Count = 2
37
- and then Ada.Command_Line.Argument (1 ) = " --debug" ))
38
- then
39
- Ada.Text_IO.Put_Line (" Usage:" );
40
- Ada.Text_IO.Put_Line
41
- (" " & Ada.Command_Line.Command_Name & " [options] test.json" );
42
- Ada.Text_IO.New_Line;
43
- Ada.Text_IO.Put_Line (" Options are:" );
44
- Ada.Text_IO.Put_Line
45
- (" --debug disable timeouts and pause after server start" );
46
- Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
47
- return ;
60
+ VSS.Command_Line.Add_Option (Options.Debug);
61
+ VSS.Command_Line.Add_Option (Options.On_Hang);
62
+ VSS.Command_Line.Add_Option (Options.File);
63
+ VSS.Command_Line.Process; -- This terminates process on option's error
64
+
65
+ if not Options.File.Is_Specified then
66
+ declare
67
+ use type VSS.Strings.Virtual_String;
68
+ Usage : VSS.String_Vectors.Virtual_String_Vector;
69
+ begin
70
+ Usage.Append (" Usage:" );
71
+ Usage.Append
72
+ (" tester-run [options] " & Options.File.Name);
73
+ Usage.Append (" " );
74
+ Usage.Append (" Options are:" );
75
+ Usage.Append
76
+ (" --" & Options.Debug.Long_Name
77
+ & " (-" & Options.Debug.Short_Name & " )"
78
+ & " " & Options.Debug.Description);
79
+ Usage.Append
80
+ (" --" & Options.On_Hang.Long_Name
81
+ & " =" & Options.On_Hang.Value_Name
82
+ & " " & Options.On_Hang.Description);
83
+ VSS.Command_Line.Report_Error (Usage.Join_Lines (VSS.Strings.LF));
84
+ end ;
48
85
end if ;
49
86
50
87
declare
51
- File : constant String := Ada.Command_Line.Argument
52
- (Ada.Command_Line.Argument_Count );
88
+ File : constant String := VSS.Strings.Conversions.To_UTF_8_String
89
+ (Options.File.Value );
53
90
Input : Ada.Text_IO.File_Type;
54
91
Text : Ada.Strings.Unbounded.Unbounded_String;
55
92
begin
@@ -73,7 +110,10 @@ begin
73
110
declare
74
111
Test : Tester.Tests.Test;
75
112
begin
76
- Test.Run (JSON.Get, Debug => Ada.Command_Line.Argument_Count = 2 );
113
+ Test.Run
114
+ (JSON.Get,
115
+ On_Hang => Options.On_Hang.Value,
116
+ Debug => Options.Debug.Is_Specified);
77
117
end ;
78
118
end ;
79
119
end Tester.Run ;
0 commit comments