Skip to content

Commit 9ee3443

Browse files
BoulangerAdrienBoulanger
authored andcommitted
Improve testsuite
- Allow string as "id" - Add PYTHON macro for local runs Closes eng/ide/ada_language_server#1475
1 parent e93d16b commit 9ee3443

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

source/tester/tester-tests.adb

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ package body Tester.Tests is
9898
function Find_Matching_Request
9999
(Request : GNATCOLL.JSON.JSON_Value;
100100
Search_Array : GNATCOLL.JSON.JSON_Array;
101-
Request_ID : out Integer)
101+
Request_ID : out Unbounded_String)
102102
return GNATCOLL.JSON.JSON_Value;
103103
-- Search for the matching Request in Search_Array. Return JSON_Null if
104104
-- Request was not matched.
@@ -930,9 +930,9 @@ package body Tester.Tests is
930930
for J in 1 .. GNATCOLL.JSON.Length (R) loop
931931
-- For each request, try to find the request with the same ID
932932
declare
933-
Expected : constant GNATCOLL.JSON.JSON_Value :=
933+
Expected : constant GNATCOLL.JSON.JSON_Value :=
934934
GNATCOLL.JSON.Get (R, J);
935-
Expected_ID : Integer;
935+
Expected_ID : Unbounded_String;
936936
Matching_Request : constant GNATCOLL.JSON.JSON_Value :=
937937
Find_Matching_Request
938938
(Request => Expected,
@@ -947,11 +947,11 @@ package body Tester.Tests is
947947
Minimal => Minimal,
948948
Result => Result);
949949
else
950-
if Expected_ID /= -1 then
950+
if Expected_ID = Null_Unbounded_String then
951951
-- Alert the user we failed to find the request
952952
Result.Append
953953
("Failed to find result for request:"
954-
& Expected_ID'Image);
954+
& Expected_ID);
955955
Result.Append (Ada.Characters.Latin_1.LF);
956956
Result.Append
957957
("Either the result was never received or the id "
@@ -982,26 +982,44 @@ package body Tester.Tests is
982982
function Find_Matching_Request
983983
(Request : GNATCOLL.JSON.JSON_Value;
984984
Search_Array : GNATCOLL.JSON.JSON_Array;
985-
Request_ID : out Integer)
985+
Request_ID : out Unbounded_String)
986986
return GNATCOLL.JSON.JSON_Value
987987
is
988-
function Get_ID (Value : GNATCOLL.JSON.JSON_Value) return Integer;
988+
function Get_ID
989+
(Value : GNATCOLL.JSON.JSON_Value) return Unbounded_String;
989990

990991
------------
991992
-- Get_ID --
992993
------------
993994

994-
function Get_ID (Value : GNATCOLL.JSON.JSON_Value) return Integer is
995+
function Get_ID
996+
(Value : GNATCOLL.JSON.JSON_Value) return Unbounded_String is
995997
begin
996998
if Value.Kind = JSON_Object_Type and then Value.Has_Field ("id") then
997-
return Value.Get ("id");
999+
declare
1000+
ID : constant GNATCOLL.JSON.JSON_Value := Value.Get ("id");
1001+
begin
1002+
if ID.Kind = JSON_Int_Type then
1003+
declare
1004+
ID_Value : constant Integer := Value.Get ("id");
1005+
begin
1006+
return To_Unbounded_String (ID_Value'Image);
1007+
end;
1008+
elsif ID.Kind = JSON_String_Type then
1009+
declare
1010+
ID_Value : constant String := Value.Get ("id");
1011+
begin
1012+
return To_Unbounded_String (ID_Value);
1013+
end;
1014+
end if;
1015+
end;
9981016
end if;
999-
return -1;
1017+
return Null_Unbounded_String;
10001018
end Get_ID;
10011019

10021020
begin
10031021
Request_ID := Get_ID (Request);
1004-
if Request_ID = -1 then
1022+
if Request_ID = Null_Unbounded_String then
10051023
-- No ID, so left was not a request object
10061024
return GNATCOLL.JSON.JSON_Null;
10071025
end if;

testsuite/drivers/basic.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import glob
22
import os
3+
import sys
34

45
from e3.testsuite.result import TestStatus
56

@@ -41,6 +42,7 @@ def run(self, previous_values, slot):
4142
"ALS": self.env.als,
4243
"ALS_HOME": self.env.als_home,
4344
"ALS_WAIT_FACTOR": str(self.env.wait_factor),
45+
"PYTHON": sys.executable
4446
},
4547
ignore_environ=False,
4648
)

0 commit comments

Comments
 (0)