Skip to content

Commit 0767f49

Browse files
committed
Fix skipped CI tests
1 parent 9ac2e48 commit 0767f49

File tree

5 files changed

+52
-14
lines changed

5 files changed

+52
-14
lines changed

filter

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,25 @@
22

33
set -eo pipefail
44

5-
source "/usr/local/lib/fs/functions/_filter"
5+
# Determine script location and set fs_dir
6+
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
if [ -d "$script_dir/fs" ]; then
8+
# Development mode - fs directory is relative to script
9+
fs_dir="$script_dir/fs"
10+
elif [ -d "$HOME/.local/lib/fs" ]; then
11+
# Local install mode - use ~/.local/lib/fs
12+
fs_dir="$HOME/.local/lib/fs"
13+
else
14+
# System install mode - use /usr/local/lib/fs
15+
fs_dir="/usr/local/lib/fs"
16+
fi
617

7-
source "/usr/local/lib/fs/operations/arithmetic"
8-
source "/usr/local/lib/fs/operations/file_and_dir"
9-
source "/usr/local/lib/fs/operations/comparison"
10-
source "/usr/local/lib/fs/operations/string"
11-
source "/usr/local/lib/fs/operations/logical"
18+
source "$fs_dir/functions/_filter"
19+
20+
source "$fs_dir/operations/arithmetic"
21+
source "$fs_dir/operations/file_and_dir"
22+
source "$fs_dir/operations/comparison"
23+
source "$fs_dir/operations/string"
24+
source "$fs_dir/operations/logical"
1225

1326
_filter "$@"

fs/functions/_filter

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ function _filter {
5959
local old_ifs=$IFS
6060
IFS=''
6161

62+
local has_input=false
6263
local filter_res
6364
while read -r line; do
65+
has_input=true
6466
# Use safer function call instead of eval
6567
if filter_res=$("$fn_arg" "$line" "$args"); then
6668
if [ "$filter_res" == "true" ]; then
@@ -69,6 +71,11 @@ function _filter {
6971
fi
7072
done < /dev/stdin
7173

74+
# If no input was provided, exit with 1
75+
if [ "$has_input" = "false" ]; then
76+
exit 1
77+
fi
78+
7279
IFS=$old_ifs
7380
}
7481

fs/functions/_map

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,18 @@ function _map {
2727
local old_ifs=$IFS
2828
IFS=''
2929

30+
local has_input=false
3031
while read -r line; do
32+
has_input=true
3133
# Use safer function call instead of eval
3234
"$fn_arg" "$line" "$args"
3335
done < /dev/stdin
3436

37+
# If no input was provided, exit with 1
38+
if [ "$has_input" = "false" ]; then
39+
exit 1
40+
fi
41+
3542
IFS=$old_ifs
3643
}
3744

map

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,25 @@
22

33
set -eo pipefail
44

5-
source "/usr/local/lib/fs/functions/_map"
5+
# Determine script location and set fs_dir
6+
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
if [ -d "$script_dir/fs" ]; then
8+
# Development mode - fs directory is relative to script
9+
fs_dir="$script_dir/fs"
10+
elif [ -d "$HOME/.local/lib/fs" ]; then
11+
# Local install mode - use ~/.local/lib/fs
12+
fs_dir="$HOME/.local/lib/fs"
13+
else
14+
# System install mode - use /usr/local/lib/fs
15+
fs_dir="/usr/local/lib/fs"
16+
fi
617

7-
source "/usr/local/lib/fs/operations/arithmetic"
8-
source "/usr/local/lib/fs/operations/file_and_dir"
9-
source "/usr/local/lib/fs/operations/comparison"
10-
source "/usr/local/lib/fs/operations/string"
11-
source "/usr/local/lib/fs/operations/other"
18+
source "$fs_dir/functions/_map"
19+
20+
source "$fs_dir/operations/arithmetic"
21+
source "$fs_dir/operations/file_and_dir"
22+
source "$fs_dir/operations/comparison"
23+
source "$fs_dir/operations/string"
24+
source "$fs_dir/operations/other"
1225

1326
_map "$@"

tests/integration-tests/tests.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def test_map__exits_w_code_1__when_no_function_provided():
1818
code, _, _ = run(["map"])
1919
assert code == 1
2020

21-
@pytest.mark.skip(reason="Doesn't pass on CI for unknown reason")
2221
def test_map__exits_w_code_1__when_no_input():
2322
code, _, _ = run(["map", "add"])
2423
assert code == 1
@@ -37,7 +36,6 @@ def test_filter__exits_w_code_1__when_no_function_provided():
3736
code, _, _ = run(["filter"])
3837
assert code == 1
3938

40-
@pytest.mark.skip(reason="Doesn't pass on CI for unknown reason")
4139
def test_filter__exits_w_code_1__when_no_input():
4240
code, _, _ = run(["filter", "is_file"])
4341
assert code == 1

0 commit comments

Comments
 (0)