Skip to content

Commit fce7685

Browse files
committed
Add append_to_env command to tester-run
1 parent 60acc55 commit fce7685

File tree

6 files changed

+146
-69
lines changed

6 files changed

+146
-69
lines changed

source/tester/tester-macros.adb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Language Server Protocol --
33
-- --
4-
-- Copyright (C) 2018-2019, AdaCore --
4+
-- Copyright (C) 2018-2023, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it under --
77
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -22,6 +22,9 @@ with Ada.Strings.Maps;
2222

2323
with GNAT.Regpat;
2424
with GNAT.OS_Lib;
25+
26+
with VSS.Strings.Conversions;
27+
2528
with URIs;
2629

2730
package body Tester.Macros is
@@ -171,11 +174,16 @@ package body Tester.Macros is
171174
procedure Expand
172175
(Test : in out GNATCOLL.JSON.JSON_Value;
173176
Env : Spawn.Environments.Process_Environment;
174-
Path : String)
177+
Path : VSS.Strings.Virtual_String)
175178
is
176-
Full_Name : constant String := Ada.Directories.Full_Name (Path);
179+
File : constant String :=
180+
VSS.Strings.Conversions.To_UTF_8_String (Path);
181+
182+
Full_Name : constant String := Ada.Directories.Full_Name (File);
183+
177184
Directory : constant String :=
178185
Ada.Directories.Containing_Directory (Full_Name);
186+
179187
Env_With_Dir : Spawn.Environments.Process_Environment := Env;
180188
begin
181189
Env_With_Dir.Insert ("DIR", Directory);

source/tester/tester-macros.ads

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Language Server Protocol --
33
-- --
4-
-- Copyright (C) 2018-2019, AdaCore --
4+
-- Copyright (C) 2018-2023, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it under --
77
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -19,15 +19,17 @@ with GNATCOLL.JSON;
1919

2020
with Spawn.Environments;
2121

22+
with VSS.Strings;
23+
2224
package Tester.Macros is
2325

2426
procedure Expand
2527
(Test : in out GNATCOLL.JSON.JSON_Value;
2628
Env : Spawn.Environments.Process_Environment;
27-
Path : String);
29+
Path : VSS.Strings.Virtual_String);
2830
-- Expand macros in given JSON test. The Path is test's path.
2931
--
30-
-- Currently only one macro is supported:
32+
-- Currently next macros are supported:
3133
-- * ${NAME} - expands with environment variable NAME from Env
3234
--
3335
-- * $URI{x} - rewrite as "file:///path", treat x as relative to test

source/tester/tester-run.adb

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ with VSS.Strings;
2626
with VSS.Strings.Conversions;
2727
with VSS.String_Vectors;
2828

29-
with Spawn.Environments;
30-
31-
with Tester.Macros;
3229
with Tester.Tests;
3330

3431
procedure Tester.Run is
@@ -52,9 +49,6 @@ procedure Tester.Run is
5249
Description => "JSON test script");
5350
end Options;
5451

55-
Env : constant Spawn.Environments.Process_Environment :=
56-
Spawn.Environments.System_Environment;
57-
5852
JSON : GNATCOLL.JSON.JSON_Value;
5953
begin
6054
VSS.Command_Line.Add_Option (Options.Debug);
@@ -105,15 +99,15 @@ begin
10599

106100
Ada.Text_IO.Close (Input);
107101
JSON := GNATCOLL.JSON.Read (Text, File);
108-
Tester.Macros.Expand (JSON, Env, File);
109102

110103
declare
111104
Test : Tester.Tests.Test;
112105
begin
113106
Test.Run
114-
(JSON.Get,
115-
On_Hang => Options.On_Hang.Value,
116-
Debug => Options.Debug.Is_Specified);
107+
(Commands => JSON.Get,
108+
File => Options.File.Value,
109+
On_Hang => Options.On_Hang.Value,
110+
Debug => Options.Debug.Is_Specified);
117111
end;
118112
end;
119113
end Tester.Run;

0 commit comments

Comments
 (0)