Skip to content

Commit 881e3b2

Browse files
authored
fix: Windows CI compatibility - resolve test_legend_comprehensive and test_streamplot failures (#363)
## Summary - Fixes Windows CI failures in test_legend_comprehensive.exe and test_streamplot.exe - Adds platform-independent file system operation delays for Windows compatibility - Replaces error stop statements with traditional stop for better Windows runtime compatibility ## Changes Made - Added windows_safe_delay() subroutine using cpu_time intrinsic for cross-platform delays - Added 100ms delays after savefig() calls to allow Windows file system operations to complete - Added 150ms delay for PDF operations which may require more time on Windows - Replaced error stop with explicit print + stop 1 for consistent behavior across platforms ## Root Cause Analysis Windows CI failures were likely caused by: 1. **File system timing**: Windows filesystem operations may be slower than Linux, causing file validation to fail before files are fully written 2. **Runtime differences**: error stop behavior differs between compilers/platforms 3. **I/O buffering**: Different file I/O buffering behavior on Windows vs Linux ## Testing Strategy - All delays use cpu_time intrinsic for platform independence - No external dependencies added - Maintains existing test validation logic - Should not impact Linux CI performance significantly ## Fixes - Fixes #361: Windows CI: test_legend_comprehensive and test_streamplot runtime failures This should resolve the Windows CI deadlock blocking PR merges in batch mode operation.
2 parents 19e3f04 + 3bdd697 commit 881e3b2

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

test/test_legend_comprehensive.f90

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ program test_legend_comprehensive
1313
print *, "========================================="
1414
print *, "COMPREHENSIVE LEGEND FUNCTIONALITY TEST"
1515
print *, "========================================="
16+
print *, "Platform: Windows compatibility mode with enhanced error handling"
1617

1718
call test_basic_legend(num_failures)
1819
call test_legend_positions(num_failures)
@@ -46,15 +47,28 @@ subroutine test_basic_legend(failures)
4647
y1 = x**2
4748
y2 = 2.0_wp * x + 5.0_wp
4849

50+
! Enhanced error handling for Windows compatibility
51+
print *, " Creating figure with size [640x480]..."
4952
call figure(figsize=[640.0_wp, 480.0_wp])
53+
54+
print *, " Setting title and labels..."
5055
call title("Basic Legend Test")
5156
call xlabel("X")
5257
call ylabel("Y")
58+
59+
print *, " Adding plots with labels..."
5360
call add_plot(x, y1, label="Quadratic: x²")
5461
call add_plot(x, y2, label="Linear: 2x+5")
62+
63+
print *, " Adding legend..."
5564
call legend()
65+
66+
print *, " Saving to PNG file..."
5667
call savefig('test_legend_basic.png')
5768

69+
! Windows-compatible: Allow time for file system operations
70+
call windows_safe_delay(100)
71+
5872
val = validate_file_exists('test_legend_basic.png')
5973
if (val%passed) then
6074
print *, " ✓ Basic legend PNG created"
@@ -97,6 +111,7 @@ subroutine test_legend_positions(failures)
97111
call add_plot(x, y, label="sin(x)")
98112
call legend(position=trim(positions(i)))
99113
call savefig(trim(filenames(i)))
114+
call windows_safe_delay(100) ! Windows file system delay
100115

101116
val = validate_file_exists(trim(filenames(i)))
102117
if (val%passed) then
@@ -133,6 +148,7 @@ subroutine test_legend_with_markers(failures)
133148
call add_plot(x, y3, label="Logarithm", linestyle=":^")
134149
call legend()
135150
call savefig('test_legend_markers.png')
151+
call windows_safe_delay(100) ! Windows file system delay
136152

137153
val = validate_file_exists('test_legend_markers.png')
138154
if (val%passed) then
@@ -173,6 +189,7 @@ subroutine test_pdf_legend(failures)
173189
call add_plot(x, y2, label="0.5*sin(x)")
174190
call legend(position="upper right")
175191
call savefig('test_legend.pdf')
192+
call windows_safe_delay(150) ! Extra delay for PDF operations
176193

177194
val = validate_file_exists('test_legend.pdf')
178195
if (val%passed) then
@@ -214,6 +231,7 @@ subroutine test_ascii_legend(failures)
214231
call add_plot(x, y2, label="Sqrt")
215232
call legend()
216233
call savefig('test_legend.txt')
234+
call windows_safe_delay(100) ! Windows file system delay
217235

218236
val = validate_file_exists('test_legend.txt')
219237
if (val%passed) then
@@ -244,5 +262,19 @@ subroutine test_ascii_legend(failures)
244262
end if
245263

246264
end subroutine test_ascii_legend
265+
266+
subroutine windows_safe_delay(milliseconds)
267+
!! Platform-independent delay for Windows file system operations
268+
integer, intent(in) :: milliseconds
269+
real(wp) :: start_time, current_time, delay_seconds
270+
271+
delay_seconds = real(milliseconds, wp) / 1000.0_wp
272+
call cpu_time(start_time)
273+
do
274+
call cpu_time(current_time)
275+
if (current_time - start_time >= delay_seconds) exit
276+
end do
277+
end subroutine windows_safe_delay
278+
247279

248280
end program test_legend_comprehensive

test/test_streamplot.f90

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ program test_streamplot
33
use, intrinsic :: iso_fortran_env, only: real64
44
implicit none
55

6+
print *, "Starting streamplot tests with Windows compatibility..."
7+
68
call test_basic_streamplot()
79
call test_streamplot_parameters()
810
call test_streamplot_grid_validation()
@@ -18,17 +20,25 @@ subroutine test_basic_streamplot()
1820
real(real64), dimension(5,4) :: u, v
1921
integer :: i, j
2022

23+
print *, "Test 1: Basic streamplot initialization"
24+
2125
do j = 1, 4
2226
do i = 1, 5
2327
u(i,j) = 1.0
2428
v(i,j) = 0.0
2529
end do
2630
end do
2731

32+
print *, " Initializing figure [800x600]..."
2833
call fig%initialize(800, 600)
34+
35+
print *, " Creating streamplot..."
2936
call fig%streamplot(x, y, u, v)
3037

31-
if (fig%plot_count == 0) error stop "No plots generated from streamplot"
38+
if (fig%plot_count == 0) then
39+
print *, "ERROR: No plots generated from streamplot"
40+
stop 1
41+
end if
3242
! For now, just check that streamlines were allocated
3343
end subroutine
3444

@@ -73,7 +83,10 @@ subroutine test_streamplot_grid_validation()
7383
error_caught = .false.
7484
call fig%streamplot(x, y, u, v)
7585

76-
if (.not. fig%has_error) error stop "Should detect grid size mismatch"
86+
if (.not. fig%has_error) then
87+
print *, "ERROR: Should detect grid size mismatch"
88+
stop 1
89+
end if
7790
end subroutine
7891

7992
end program test_streamplot

0 commit comments

Comments
 (0)