Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Fixing installation on MacOSX Mojave with forbids writing to /usr/local #266

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,17 @@ if [ -z "$1" ]; then
fi

BATS_ROOT="$(abs_dirname "$0")"
mkdir -p "$PREFIX"/{bin,libexec,share/man/man{1,7}}
cp -R "$BATS_ROOT"/bin/* "$PREFIX"/bin
cp -R "$BATS_ROOT"/libexec/* "$PREFIX"/libexec
cp "$BATS_ROOT"/man/bats.1 "$PREFIX"/share/man/man1
cp "$BATS_ROOT"/man/bats.7 "$PREFIX"/share/man/man7
echo "Installing binaries..."

echo "Installed Bats to $PREFIX/bin/bats"
[[ -d "$PREFIX"/share/bats ]] || mkdir -p "$PREFIX"/share/bats
[[ -d "$PREFIX"/bin ]] || mkdir -p "$PREFIX"/bin

cp -Rv "$BATS_ROOT"/libexec/* "$PREFIX"/share/bats

for binary in $(ls -1 libexec); do
ln -svf "$PREFIX"/share/bats/${binary} "$PREFIX"/bin/${binary}
done

echo "Installed bats into ${PREFIX}/bin:"

ls -al ${PREFIX}/bin/bats*
14 changes: 11 additions & 3 deletions libexec/bats-exec-test
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,25 @@ load() {
}

run() {
local e E T oldIFS
local e E T oldIFS
[[ ! "$-" =~ e ]] || e=1
[[ ! "$-" =~ E ]] || E=1
[[ ! "$-" =~ T ]] || T=1
set +e
set +E
set +T
output="$("$@" 2>&1)"
status="$?"

eval "$({ t_sdterr=$({ t_stdout=$("$@"); t_ret=$?; } 2>&1; declare -p t_stdout >&2; declare -pi t_ret >&2); declare -p t_sdterr; } 2>&1)"

status=$t_ret
output="${t_stdout}${t_sdterr}"
stdout=$t_stdout
stderr=$t_sdterr

oldIFS=$IFS
IFS=$'\n' lines=($output)
IFS=$'\n' stdlines=($t_stdout)
IFS=$'\n' errlines=($t_sdterr)
[ -z "$e" ] || set -e
[ -z "$E" ] || set -E
[ -z "$T" ] || set -T
Expand Down
2 changes: 1 addition & 1 deletion libexec/bats-format-tap-stream
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ begin() {

pass() {
go_to_column 0
printf " %s" "$name"
printf " $(set_color 2)✓$(clear_color) %s" "$name"
advance
}

Expand Down
5 changes: 5 additions & 0 deletions test/bats.bats
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,8 @@ fixtures bats
[ $status -eq 0 ]
[ "${lines[1]}" = "ok 1 loop_func" ]
}

@test "testing stdout and stderr are separated" {
run bats "$FIXTURE_ROOT/stdout_stderr_separate.bats"
[ $status -eq 0 ]
}
14 changes: 14 additions & 0 deletions test/fixtures/bats/stdout_stderr_separate.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# see issue #89
echo_std_err() {
echo "std output"
(>&2 echo "err output")
return 0
}

@test "std err" {
run echo_std_err
[ $status -eq 0 ]
[ "${stdout}" = "std output" ]
[ "${stderr}" = "err output" ]
[ "${output}" = "std outputerr output" ]
}