Skip to content

Commit db22a3d

Browse files
committed
regtests: Fix line-ending mixup in 0327_prog_config
By default, Python's write() function translates "\n" to the host's native line-ending string. On armhf-linux-windows64, this causes test.py to generate an aws.ini that contains CRLF sequences, which prog_config mis-parses. Make sure the config file we generate has the canonical line-endings for the target we are testing. TN: eng/toolchain/aws#12
1 parent 42b9dfc commit db22a3d

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

regtests/0327_prog_config/test.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
1+
from e3.env import Env
2+
13
from test_support import *
24

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")
5+
def write_aws_ini(config):
6+
newline = None
7+
if Env().host.os.name == "windows" and Env().target.os.name == "linux":
8+
# On Linux, AWS will fail to parse ini files that contain CRLF line-endings: ask
9+
# Python to keep line-feeds verbatim on Windows-hosted cross-Linux testing.
10+
newline = "\n"
11+
12+
with open("aws.ini", "w", newline=newline) as ini_file:
13+
ini_file.write(config)
14+
15+
write_aws_ini("""\
16+
status_page aws.ini-status_page
17+
directory_browser_page aws.ini-directory_browser_page
18+
""")
619

720
build_and_run('prog_config')
821

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")
22+
write_aws_ini("""\
23+
status_page aws.ini-status_page
24+
directory_browser_page aws.ini-directory_browser_page
25+
disable_program_ini true
26+
""")
1327

1428
run('prog_config')

0 commit comments

Comments
 (0)