Skip to content

Commit 049866e

Browse files
committed
fix: alpine failing tests
1 parent edd9685 commit 049866e

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

src/env.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,19 @@ function env::active_internet_connection() {
7979
function env::find_terminal_width() {
8080
local cols=""
8181

82-
if [[ -z "$cols" ]] && command -v stty > /dev/null; then
82+
if command -v tput >/dev/null; then
8383
cols=$(tput cols 2>/dev/null)
8484
fi
85-
if [[ -n "$TERM" ]] && command -v tput > /dev/null; then
85+
86+
if [[ -n "$TERM" ]] && command -v stty >/dev/null; then
8687
cols=$(stty size 2>/dev/null | cut -d' ' -f2)
8788
fi
8889

89-
# Directly echo the value with fallback
90-
echo "${cols:-100}"
90+
if [[ -z "$cols" || "$cols" == "0" ]]; then
91+
cols=100
92+
fi
93+
94+
echo "$cols"
9195
}
9296

9397
function env::print_verbose() {

tests/unit/directory_test.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function test_unsuccessful_assert_is_directory_readable_when_a_file_is_given() {
111111
}
112112

113113
function test_unsuccessful_assert_is_directory_readable_without_execution_permission() {
114-
if [[ "$_OS" == "Windows" || $_DISTRO = "Alpine" ]]; then
114+
if [[ "$EUID" -eq 0 || "$_OS" == "Windows" || $_DISTRO = "Alpine" ]]; then
115115
return
116116
fi
117117

@@ -126,7 +126,7 @@ function test_unsuccessful_assert_is_directory_readable_without_execution_permis
126126
}
127127

128128
function test_unsuccessful_assert_is_directory_readable_without_read_permission() {
129-
if [[ "$_OS" == "Windows" || $_DISTRO = "Alpine" ]]; then
129+
if [[ "$EUID" -eq 0 || "$_OS" == "Windows" || $_DISTRO = "Alpine" ]]; then
130130
return
131131
fi
132132

@@ -141,7 +141,7 @@ function test_unsuccessful_assert_is_directory_readable_without_read_permission(
141141
}
142142

143143
function test_successful_assert_is_directory_not_readable_without_read_permission() {
144-
if [[ "$_OS" == "Windows" || $_DISTRO = "Alpine" ]]; then
144+
if [[ "$EUID" -eq 0 || "$_OS" == "Windows" || $_DISTRO = "Alpine" ]]; then
145145
return
146146
fi
147147

@@ -152,7 +152,7 @@ function test_successful_assert_is_directory_not_readable_without_read_permissio
152152
}
153153

154154
function test_successful_assert_is_directory_not_readable_without_execution_permission() {
155-
if [[ "$_OS" == "Windows" || $_DISTRO = "Alpine" ]]; then
155+
if [[ "$EUID" -eq 0 || "$_OS" == "Windows" || $_DISTRO = "Alpine" ]]; then
156156
return
157157
fi
158158

@@ -178,7 +178,7 @@ function test_successful_assert_is_directory_writable() {
178178
}
179179

180180
function test_unsuccessful_assert_is_directory_writable() {
181-
if [[ "$_OS" == "Windows" || $_DISTRO = "Alpine" ]]; then
181+
if [[ "$EUID" -eq 0 || "$_OS" == "Windows" || $_DISTRO = "Alpine" ]]; then
182182
return
183183
fi
184184

@@ -202,7 +202,7 @@ function test_unsuccessful_assert_is_directory_writable_when_a_file_is_given() {
202202
}
203203

204204
function test_successful_assert_is_directory_not_writable() {
205-
if [[ "$_OS" == "Windows" || $_DISTRO = "Alpine" ]]; then
205+
if [[ "$EUID" -eq 0 || "$_OS" == "Windows" || $_DISTRO = "Alpine" ]]; then
206206
return
207207
fi
208208

0 commit comments

Comments
 (0)