Skip to content

Commit 9923a0a

Browse files
committed
All tests writing json to stdout write valid json
- Tests 1 and 8 were writing multiple json structures to stdout, which prevented the output being piped into json lint. Now some additional print statements are used to combine each test's three json structures into a since json structure. (Other text is sent to stderr.)
1 parent ebdbf73 commit 9923a0a

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/tests/jf_test_1.f90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ subroutine test_1(error_cnt)
101101
! print the parsed data to the console
102102
write(error_unit,'(A)') ''
103103
write(error_unit,'(A)') 'printing the file...'
104+
write(output_unit,'(A)') '{ "part a" :' !Wrap 3 outputs to make stdout valid json
104105
call json%print_file()
105106
if (json_failed()) then
106107
call json_print_error_message(error_unit)
@@ -232,6 +233,7 @@ subroutine test_1(error_cnt)
232233

233234
write(error_unit,'(A)') ''
234235
write(error_unit,'(A)') 'printing the modified structure...'
236+
write(output_unit,'(A)') ', "part b" : '
235237
call json%print_file()
236238
if (json_failed()) then
237239
call json_print_error_message(error_unit)
@@ -260,7 +262,9 @@ subroutine test_1(error_cnt)
260262

261263
write(error_unit,'(A)') ''
262264
write(error_unit,'(A)') 'printing the modified structure...'
265+
write(output_unit,'(A)') ', "part c" : '
263266
call json%print_file()
267+
write(output_unit,'(A)') '}'
264268
if (json_failed()) then
265269
call json_print_error_message(error_unit)
266270
error_cnt = error_cnt + 1

src/tests/jf_test_8.f90

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ subroutine test_8(error_cnt)
9999
call json_print_error_message(error_unit)
100100
error_cnt = error_cnt + 1
101101
end if
102-
call json_print(p,OUTPUT_UNIT) ! print to console
102+
write(output_unit,'(A)') '{ "part a" : '
103+
call json_print(p,output_unit) ! print to console
104+
write(output_unit,'(A)') ','
103105
if (json_failed()) then
104106
call json_print_error_message(error_unit)
105107
error_cnt = error_cnt + 1
@@ -120,7 +122,9 @@ subroutine test_8(error_cnt)
120122
call json_print_error_message(error_unit)
121123
error_cnt = error_cnt + 1
122124
end if
123-
call json_print(p,OUTPUT_UNIT) ! print to console
125+
write(output_unit,'(A)') '"part b" : '
126+
call json_print(p,output_unit) ! print to console
127+
write(output_unit,'(A)') ','
124128
if (json_failed()) then
125129
call json_print_error_message(error_unit)
126130
error_cnt = error_cnt + 1
@@ -143,7 +147,9 @@ subroutine test_8(error_cnt)
143147
write(error_unit,'(A)') 'This should have failed!'
144148
error_cnt = error_cnt + 1
145149
end if
146-
call json_print(p,OUTPUT_UNIT) ! print to console
150+
write(output_unit,'(A)') '"part c" : '
151+
call json_print(p,output_unit) ! print to console
152+
write(output_unit,'(A)') '}'
147153
if (json_failed()) then
148154
call json_print_error_message(error_unit)
149155
error_cnt = error_cnt + 1

0 commit comments

Comments
 (0)