@@ -341,7 +341,8 @@ def test_options_parses_as_nonstrict_for_py2_py3_compat(self):
341
341
# should not raise configparser.DuplicateSectionError on py3
342
342
343
343
def test_options_with_environment_expansions (self ):
344
- s = lstrip ("""[supervisorctl]
344
+ s = lstrip ("""
345
+ [supervisorctl]
345
346
serverurl=http://localhost:%(ENV_SERVER_PORT)s
346
347
username=%(ENV_CLIENT_USER)s
347
348
password=%(ENV_CLIENT_PASS)s
@@ -454,11 +455,7 @@ def test_version(self):
454
455
self .assertEqual (options .stdout .getvalue (), VERSION + '\n ' )
455
456
456
457
def test_options (self ):
457
- s = lstrip ("""[inet_http_server]
458
- port=127.0.0.1:8999
459
- username=chrism
460
- password=foo
461
-
458
+ s = lstrip ("""
462
459
[supervisord]
463
460
directory=%(tempdir)s
464
461
backofflimit=10
@@ -478,6 +475,11 @@ def test_options(self):
478
475
minprocs=300
479
476
environment=FAKE_ENV_VAR=/some/path
480
477
478
+ [inet_http_server]
479
+ port=127.0.0.1:8999
480
+ username=chrism
481
+ password=foo
482
+
481
483
[program:cat1]
482
484
command=/bin/cat
483
485
priority=1
@@ -1844,11 +1846,6 @@ def test_processes_from_section_redirect_stderr_with_auto(self):
1844
1846
1845
1847
def test_options_with_environment_expansions (self ):
1846
1848
text = lstrip ("""\
1847
- [inet_http_server]
1848
- port=*:%(ENV_HTSRV_PORT)s
1849
- username=%(ENV_HTSRV_USER)s
1850
- password=%(ENV_HTSRV_PASS)s
1851
-
1852
1849
[supervisord]
1853
1850
logfile = %(ENV_HOME)s/supervisord.log
1854
1851
logfile_maxbytes = %(ENV_SUPD_LOGFILE_MAXBYTES)s
@@ -1864,6 +1861,11 @@ def test_options_with_environment_expansions(self):
1864
1861
strip_ansi = %(ENV_SUPD_STRIP_ANSI)s
1865
1862
environment = FAKE_ENV_VAR=/some/path
1866
1863
1864
+ [inet_http_server]
1865
+ port=*:%(ENV_HTSRV_PORT)s
1866
+ username=%(ENV_HTSRV_USER)s
1867
+ password=%(ENV_HTSRV_PASS)s
1868
+
1867
1869
[program:cat1]
1868
1870
command=%(ENV_CAT1_COMMAND)s --logdir=%(ENV_CAT1_COMMAND_LOGDIR)s
1869
1871
priority=%(ENV_CAT1_PRIORITY)s
@@ -1996,6 +1998,57 @@ def test_options_supervisord_section_expands_here(self):
1996
1998
self .assertEqual (instance .pidfile ,
1997
1999
os .path .join (here , 'supervisord.pid' ))
1998
2000
2001
+ def test_options_program_section_expands_env_from_supervisord_sect (self ):
2002
+ instance = self ._makeOne ()
2003
+ text = lstrip ('''
2004
+ [supervisord]
2005
+ environment=CMD=/bin/from/supervisord/section
2006
+
2007
+ [program:cmd]
2008
+ command=%(ENV_CMD)s
2009
+ ''' )
2010
+ here = tempfile .mkdtemp ()
2011
+ supervisord_conf = os .path .join (here , 'supervisord.conf' )
2012
+ with open (supervisord_conf , 'w' ) as f :
2013
+ f .write (text )
2014
+ try :
2015
+ instance .configfile = supervisord_conf
2016
+ instance .realize (args = [])
2017
+ finally :
2018
+ shutil .rmtree (here , ignore_errors = True )
2019
+ options = instance .configroot .supervisord
2020
+ group = options .process_group_configs [0 ]
2021
+ self .assertEqual (group .name , 'cmd' )
2022
+ proc = group .process_configs [0 ]
2023
+ self .assertEqual (proc .command ,
2024
+ os .path .join (here , '/bin/from/supervisord/section' ))
2025
+
2026
+ def test_options_program_section_expands_env_from_program_sect (self ):
2027
+ instance = self ._makeOne ()
2028
+ text = lstrip ('''
2029
+ [supervisord]
2030
+ environment=CMD=/bin/from/supervisord/section
2031
+
2032
+ [program:cmd]
2033
+ command=%(ENV_CMD)s
2034
+ environment=CMD=/bin/from/program/section
2035
+ ''' )
2036
+ here = tempfile .mkdtemp ()
2037
+ supervisord_conf = os .path .join (here , 'supervisord.conf' )
2038
+ with open (supervisord_conf , 'w' ) as f :
2039
+ f .write (text )
2040
+ try :
2041
+ instance .configfile = supervisord_conf
2042
+ instance .realize (args = [])
2043
+ finally :
2044
+ shutil .rmtree (here , ignore_errors = True )
2045
+ options = instance .configroot .supervisord
2046
+ group = options .process_group_configs [0 ]
2047
+ self .assertEqual (group .name , 'cmd' )
2048
+ proc = group .process_configs [0 ]
2049
+ self .assertEqual (proc .command ,
2050
+ os .path .join (here , '/bin/from/program/section' ))
2051
+
1999
2052
def test_options_program_section_expands_here (self ):
2000
2053
instance = self ._makeOne ()
2001
2054
text = lstrip ('''
0 commit comments