Skip to content

Commit 0bc1fda

Browse files
committed
fix(test_os): handle get_terminal_size error
1 parent b61538c commit 0bc1fda

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

test/system/test_os.f90

+16-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module test_os
22
use testdrive, only : new_unittest, unittest_type, error_type, check, skip_test
33
use stdlib_system, only: get_runtime_os, OS_WINDOWS, OS_UNKNOWN, OS_TYPE, is_windows, null_device, &
44
get_terminal_size
5+
use stdlib_error, only: state_type
56
implicit none
67

78
contains
@@ -22,14 +23,25 @@ end subroutine collect_suite
2223
subroutine test_get_terminal_size(error)
2324
type(error_type), allocatable, intent(out) :: error
2425
integer :: columns, lines
26+
type(state_type) :: err
2527

2628
!> Get terminal size
27-
call get_terminal_size(columns, lines)
29+
call get_terminal_size(columns, lines, err)
2830

29-
call check(error, columns > 0, "Terminal width is not positive")
30-
if (allocated(error)) return
31+
if (err%ok()) then
32+
call check(error, columns > 0, "Terminal width is not positive")
33+
if (allocated(error)) return
34+
35+
call check(error, lines > 0, "Terminal height is not positive")
36+
37+
!> In Github Actions, the terminal size is not available, standard output is redirected to a file
38+
else
39+
call check(error, columns, -1)
40+
if (allocated(error)) return
41+
42+
call check(error, lines, -1)
3143

32-
call check(error, lines > 0, "Terminal height is not positive")
44+
end if
3345

3446
end subroutine test_get_terminal_size
3547

0 commit comments

Comments
 (0)