Skip to content

Commit b8fc996

Browse files
committed
Fix aggregate_vector_diagnosis description indent handling
Fix a bug in aggregate_vector_diagnosis that breaks Julienne diagnostic string agreggation with .also. Currently given an incremental diagnosis pattern like this: ```fortran diag = .true. diag = .diag. .also. .false. // "whatever" do i=1,100 diag = .diag. .also. .true. end do ``` The code in aggregate_vector_diagnosis will prepend 100 `new_line_indent` strings into the diagnosis string (ie 100 blank lines), even though there was only one actual failure. Fundamentally the problem is that a `new_line_indent` is being prepended each time `aggregate_vector_diagnosis` is called with a failing argument, even if the failing diagnosis was the outcome of a previous call to `aggregate_vector_diagnosis` that already prepended a new line. The surgical solution in this PR prevents this defect. As a side-benefit it also provides nicer behavior if the client has formatted their own output line and already inserted a line break, eg: ```fortran diag = test_diagnosis_t(.false.,new_line('') // " I formatted this line myself!") ```
1 parent a1404e7 commit b8fc996

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/julienne/julienne_test_diagnosis_s.F90

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,12 @@ pure function aggregate_vector_diagnosis(diagnoses) result(diagnosis)
9595
integer i
9696
allocate(array(size(diagnoses)))
9797
do i = 1, size(diagnoses)
98-
array(i) = string_t(new_line_indent // diagnoses(i)%diagnostics_string_)
98+
if (diagnoses(i)%diagnostics_string_(1:1) == new_line('')) then
99+
! don't prepend a another newline if the string already begins with one
100+
array(i) = diagnoses(i)%diagnostics_string_
101+
else
102+
array(i) = string_t(new_line_indent // diagnoses(i)%diagnostics_string_)
103+
end if
99104
end do
100105
diagnosis = test_diagnosis_t( &
101106
test_passed = all(diagnoses%test_passed_) &
@@ -119,7 +124,12 @@ pure function aggregate_vector_diagnosis(diagnoses) result(diagnosis)
119124
integer i
120125
allocate(array(size(diagnoses)))
121126
do i = 1, size(diagnoses)
122-
array(i) = string_t(new_line_indent // diagnoses(i)%diagnostics_string_)
127+
if (diagnoses(i)%diagnostics_string_(1:1) == new_line('')) then
128+
! don't prepend a another newline if the string already begins with one
129+
array(i) = diagnoses(i)%diagnostics_string_
130+
else
131+
array(i) = string_t(new_line_indent // diagnoses(i)%diagnostics_string_)
132+
end if
123133
end do
124134
diagnosis = test_diagnosis_t( &
125135
test_passed = all(diagnoses%test_passed_) &

0 commit comments

Comments
 (0)