Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/gold_tests/records/gold/no_newline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
records:
http:
negative_caching_enabled: 0
1 change: 1 addition & 0 deletions tests/gold_tests/records/legacy_config/no_newline.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG proxy.config.http.negative_caching_enabled INT 0
9 changes: 9 additions & 0 deletions tests/gold_tests/records/records_config_to_yaml.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,12 @@
tr.Processes.Default.Streams.stdout += Testers.ContainsExpression(
"We cannot continue with 'proxy.config.ssl.client.verify.server' at line '3' as an existing YAML map will be overridden.",
"Error should be present")

file_suffix = file_suffix + 1

tr = Test.AddTestRun("Test config file without trailing newline")
tr.Setup.Copy(os.path.join(Test.Variables.RepoDir, "tools/records/convert2yaml.py"))
tr.Setup.Copy('legacy_config/no_newline.config')
tr.Processes.Default.Command = f'python3 convert2yaml.py -f no_newline.config --output generated{file_suffix}.yaml --yaml --mute'
f = tr.Disk.File(f"generated{file_suffix}.yaml")
f.Content = "gold/no_newline.yaml"
4 changes: 2 additions & 2 deletions tools/records/convert2yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ def handle_file_input(args):
elif args.node and name.startswith("proxy.node."):
name = name[len("proxy."):]

# Build the object
add_object(config, name, value[:-1], type, track_info)
# Build the object (use rstrip to handle files without trailing newline)
add_object(config, name, value.rstrip('\n'), type, track_info)
idx = idx + 1

ts = {}
Expand Down