CFE-2663: Select empty region at end of file when select_end_match_eof is set#6208
Conversation
An insert_lines promise using select_region with select_end_match_eof cannot select the region of the final section when that section header is the last line of the file. The region is empty and sits at the end of the file, SelectRegion() rejects it, and the insertion fails with "could not select an edit region". This test fails today and will pass once SelectRegion() honors select_end_match_eof for an empty region at end of file. Ticket: CFE-2663 Changelog: None Signed-off-by: Nick Anderson <nick@cmdln.org>
When select_region matched a start delimiter on the last line of the file and include_start_delimiter was false, SelectRegion() rejected the region as an "empty region at the end of file" and the edit failed with "could not select an edit region". This happened even when select_end_match_eof was true, which is meant to let the region extend to the end of the file. Now the empty region at end of file is accepted when select_end_match_eof is set, so a trailing section (its header being the last line of the file) can still be populated by insert_lines and similar promises. Ticket: CFE-2663 Changelog: Title Signed-off-by: Nick Anderson <nick@cmdln.org>
|
@cf-bottom jenkins please |
|
Alright, I triggered a build: Jenkins: https://ci.cfengine.com/job/pr-pipeline/14084/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-14084/ |
|
@cf-bottom jenkins please |
|
Sure, I triggered a build: Jenkins: https://ci.cfengine.com/job/pr-pipeline/14093/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-14093/ |
|
@cf-bottom jenkins please |
|
Alright, I triggered a build: Jenkins: https://ci.cfengine.com/job/pr-pipeline/14114/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-14114/ |
|
@cf-bottom jenkins please |
|
Alright, I triggered a build: Jenkins: https://ci.cfengine.com/job/pr-pipeline/14120/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-14120/ |
|
@cf-bottom jenkins please |
|
Alright, I triggered a build: Jenkins: https://ci.cfengine.com/job/pr-pipeline/14127/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-14127/ |
When an
insert_lines(or otheredit_line) promise usesselect_regionwithselect_end_match_eof => "true", and theselect_startdelimiter matches the last line of the file,SelectRegion()rejects the (empty) region at EOF and the edit fails with "could not select an edit region". This makes the final section of an INI-style file impossible to populate once it is empty, which is exactly whatset_variable_values_ini()/manage_variable_values_ini()hit in the wild.This PR is structured for TDD:
31_tickets/CFE-2663/) that inserts a key into an empty trailing section. It fails today.SelectRegion()honorselect_end_match_eoffor an empty region at end of file, turning the test green.Ticket: https://northerntech.atlassian.net/browse/CFE-2663
Together with: https://github.com/cfengine/system-testing/pull/692/