Skip to content

Commit 7a2a569

Browse files
committed
fix: Windows CI compatibility - add file system delays and error handling
- Add windows_safe_delay() for file system operations in legend tests - Replace error stop with traditional stop statements for Windows compatibility - Add extra delay for PDF operations which may be slower on Windows - Implement platform-independent delay using cpu_time intrinsic Addresses failing Windows CI tests: test_legend_comprehensive.exe and test_streamplot.exe Fixes #361
1 parent 79a6499 commit 7a2a569

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

test/test_legend_comprehensive.f90

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ subroutine test_basic_legend(failures)
5555
call legend()
5656
call savefig('test_legend_basic.png')
5757

58+
! Windows-compatible: Allow time for file system operations
59+
call windows_safe_delay(100)
60+
5861
val = validate_file_exists('test_legend_basic.png')
5962
if (val%passed) then
6063
print *, " ✓ Basic legend PNG created"
@@ -97,6 +100,7 @@ subroutine test_legend_positions(failures)
97100
call add_plot(x, y, label="sin(x)")
98101
call legend(position=trim(positions(i)))
99102
call savefig(trim(filenames(i)))
103+
call windows_safe_delay(100) ! Windows file system delay
100104

101105
val = validate_file_exists(trim(filenames(i)))
102106
if (val%passed) then
@@ -133,6 +137,7 @@ subroutine test_legend_with_markers(failures)
133137
call add_plot(x, y3, label="Logarithm", linestyle=":^")
134138
call legend()
135139
call savefig('test_legend_markers.png')
140+
call windows_safe_delay(100) ! Windows file system delay
136141

137142
val = validate_file_exists('test_legend_markers.png')
138143
if (val%passed) then
@@ -173,6 +178,7 @@ subroutine test_pdf_legend(failures)
173178
call add_plot(x, y2, label="0.5*sin(x)")
174179
call legend(position="upper right")
175180
call savefig('test_legend.pdf')
181+
call windows_safe_delay(150) ! Extra delay for PDF operations
176182

177183
val = validate_file_exists('test_legend.pdf')
178184
if (val%passed) then
@@ -214,6 +220,7 @@ subroutine test_ascii_legend(failures)
214220
call add_plot(x, y2, label="Sqrt")
215221
call legend()
216222
call savefig('test_legend.txt')
223+
call windows_safe_delay(100) ! Windows file system delay
217224

218225
val = validate_file_exists('test_legend.txt')
219226
if (val%passed) then
@@ -244,5 +251,18 @@ subroutine test_ascii_legend(failures)
244251
end if
245252

246253
end subroutine test_ascii_legend
254+
255+
subroutine windows_safe_delay(milliseconds)
256+
!! Platform-independent delay for Windows file system operations
257+
integer, intent(in) :: milliseconds
258+
real(wp) :: start_time, current_time, delay_seconds
259+
260+
delay_seconds = real(milliseconds, wp) / 1000.0_wp
261+
call cpu_time(start_time)
262+
do
263+
call cpu_time(current_time)
264+
if (current_time - start_time >= delay_seconds) exit
265+
end do
266+
end subroutine windows_safe_delay
247267

248268
end program test_legend_comprehensive

test/test_streamplot.f90

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ subroutine test_basic_streamplot()
2828
call fig%initialize(800, 600)
2929
call fig%streamplot(x, y, u, v)
3030

31-
if (fig%plot_count == 0) error stop "No plots generated from streamplot"
31+
if (fig%plot_count == 0) then
32+
print *, "ERROR: No plots generated from streamplot"
33+
stop 1
34+
end if
3235
! For now, just check that streamlines were allocated
3336
end subroutine
3437

@@ -73,7 +76,10 @@ subroutine test_streamplot_grid_validation()
7376
error_caught = .false.
7477
call fig%streamplot(x, y, u, v)
7578

76-
if (.not. fig%has_error) error stop "Should detect grid size mismatch"
79+
if (.not. fig%has_error) then
80+
print *, "ERROR: Should detect grid size mismatch"
81+
stop 1
82+
end if
7783
end subroutine
7884

7985
end program test_streamplot

0 commit comments

Comments
 (0)