Skip to content

Commit e834616

Browse files
committed
feat(steps-lib): add is_executable function & test
1 parent 3e07544 commit e834616

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

ci/steps/steps-lib.sh

+10
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,13 @@ file_exists() {
3535
echo 1
3636
fi
3737
}
38+
39+
# Checks whether a file is executable.
40+
is_executable() {
41+
local file="${1:-}"
42+
if [ -f "${file}" ] && [ -r "${file}" ] && [ -x "${file}" ]; then
43+
echo 0
44+
else
45+
echo 1
46+
fi
47+
}

test/scripts/steps-lib.bats

+10
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,14 @@ source "$SCRIPT"
3333
@test "file_exists should 0 if file exists" {
3434
run file_exists "steps-lib.bats"
3535
[ "$output" = 0 ]
36+
}
37+
38+
@test "is_executable should 1 if file isn't executable" {
39+
run is_executable "hello-asfd.sh"
40+
[ "$output" = 1 ]
41+
}
42+
43+
@test "is_executable should 0 if file is executable" {
44+
run is_executable "$SCRIPT"
45+
[ "$output" = 0 ]
3646
}

0 commit comments

Comments
 (0)