Skip to content

Commit a2bc94d

Browse files
committed
Do not part program specific ini file if asked.
Add corresponding regression test. Fixes T530-009.
1 parent 07be992 commit a2bc94d

File tree

6 files changed

+109
-2
lines changed

6 files changed

+109
-2
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
------------------------------------------------------------------------------
2+
-- Ada Web Server --
3+
-- --
4+
-- Copyright (C) 2020, AdaCore --
5+
-- --
6+
-- This is free software; you can redistribute it and/or modify it --
7+
-- under terms of the GNU General Public License as published by the --
8+
-- Free Software Foundation; either version 3, or (at your option) any --
9+
-- later version. This software is distributed in the hope that it will --
10+
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty --
11+
-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
12+
-- General Public License for more details. --
13+
-- --
14+
-- You should have received a copy of the GNU General Public License --
15+
-- distributed with this software; see file COPYING3. If not, go --
16+
-- to http://www.gnu.org/licenses for a complete copy of the license. --
17+
------------------------------------------------------------------------------
18+
19+
with Ada.Text_IO;
20+
21+
with AWS.Config;
22+
with AWS.Utils;
23+
24+
procedure Prog_Config is
25+
26+
use Ada;
27+
use AWS;
28+
29+
Conf : constant Config.Object := Config.Get_Current;
30+
-- Config as read from the ini files
31+
32+
-------------
33+
-- Display --
34+
-------------
35+
36+
procedure Display (O : Config.Object) is
37+
begin
38+
Text_IO.Put_Line
39+
("Disable Program Ini : "
40+
& Boolean'Image (Config.Disable_Program_Ini));
41+
Text_IO.Put_Line (Config.Server_Name (O));
42+
Text_IO.Put_Line (Config.WWW_Root (O));
43+
Text_IO.Put_Line (Utils.Image (Config.Server_Port (O)));
44+
Text_IO.Put_Line (Utils.Image (Config.Max_Connection (O)));
45+
Text_IO.Put_Line (Config.Directory_Browser_Page (O));
46+
Text_IO.New_Line;
47+
end Display;
48+
49+
begin
50+
Display (Conf);
51+
end Prog_Config;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
------------------------------------------------------------------------------
2+
-- Ada Web Server --
3+
-- --
4+
-- Copyright (C) 2020, AdaCore --
5+
-- --
6+
-- This is free software; you can redistribute it and/or modify it --
7+
-- under terms of the GNU General Public License as published by the --
8+
-- Free Software Foundation; either version 3, or (at your option) any --
9+
-- later version. This software is distributed in the hope that it will --
10+
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty --
11+
-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
12+
-- General Public License for more details. --
13+
-- --
14+
-- You should have received a copy of the GNU General Public License --
15+
-- distributed with this software; see file COPYING3. If not, go --
16+
-- to http://www.gnu.org/licenses for a complete copy of the license. --
17+
------------------------------------------------------------------------------
18+
19+
with "aws";
20+
21+
project Prog_Config is
22+
for Source_Dirs use (".");
23+
for Main use ("prog_config.adb");
24+
end Prog_Config;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
directory_browser_page prog_config.ini-directory_browser_page
2+
max_connection 10

regtests/0327_prog_config/test.out

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Disable Program Ini : FALSE
2+
AWS Module
3+
./
4+
8080
5+
10
6+
prog_config.ini-directory_browser_page
7+
8+
Disable Program Ini : TRUE
9+
AWS Module
10+
./
11+
8080
12+
5
13+
aws.ini-directory_browser_page

regtests/0327_prog_config/test.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from test_support import *
2+
3+
with open('aws.ini', 'w') as ini_file:
4+
ini_file.write("status_page aws.ini-status_page\n")
5+
ini_file.write("directory_browser_page aws.ini-directory_browser_page\n")
6+
7+
build_and_run('prog_config')
8+
9+
with open('aws.ini', 'w') as ini_file:
10+
ini_file.write("status_page aws.ini-status_page\n")
11+
ini_file.write("directory_browser_page aws.ini-directory_browser_page\n")
12+
ini_file.write("disable_program_ini true\n")
13+
14+
run('prog_config')

src/core/aws-config.adb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,11 @@ package body AWS.Config is
439439
Read_If_Present
440440
(Config_Directory & OS_Lib.Directory_Separator & "aws.ini");
441441
Read_If_Present ("aws.ini");
442-
Read_If_Present (Ini.Program_Ini_File (Full_Path => True));
443-
Read_If_Present (Ini.Program_Ini_File (Full_Path => False));
442+
443+
if not Disable_Program_Ini then
444+
Read_If_Present (Ini.Program_Ini_File (Full_Path => True));
445+
Read_If_Present (Ini.Program_Ini_File (Full_Path => False));
446+
end if;
444447
end Load_Config;
445448

446449
-------------------

0 commit comments

Comments
 (0)