mirror of
https://github.com/sstephenson/bats.git
synced 2026-02-25 17:28:11 +01:00
Print filenames relative to the working directory
This commit is contained in:
@@ -54,6 +54,7 @@ expand_path() {
|
||||
|
||||
BATS_LIBEXEC="$(abs_dirname "$0")"
|
||||
export BATS_PREFIX="$(abs_dirname "$BATS_LIBEXEC")"
|
||||
export BATS_CWD="$(abs_dirname .)"
|
||||
export PATH="$BATS_LIBEXEC:$PATH"
|
||||
|
||||
options=()
|
||||
|
||||
@@ -122,7 +122,7 @@ bats_print_stack_trace() {
|
||||
local count="${#@}"
|
||||
|
||||
for frame in "$@"; do
|
||||
local filename="$(bats_frame_filename "$frame")"
|
||||
local filename="$(bats_trim_filename "$(bats_frame_filename "$frame")")"
|
||||
local lineno="$(bats_frame_lineno "$frame")"
|
||||
|
||||
if [ $index -eq 1 ]; then
|
||||
@@ -199,6 +199,17 @@ bats_strip_string() {
|
||||
printf "%s" "$string" | sed -e "s/^[ "$'\t'"]*//" -e "s/[ "$'\t'"]*$//"
|
||||
}
|
||||
|
||||
bats_trim_filename() {
|
||||
local filename="$1"
|
||||
local length="${#BATS_CWD}"
|
||||
|
||||
if [ "${filename:0:length+1}" = "${BATS_CWD}/" ]; then
|
||||
echo "${filename:length+1}"
|
||||
else
|
||||
echo "$filename"
|
||||
fi
|
||||
}
|
||||
|
||||
bats_debug_trap() {
|
||||
if [ "$BASH_SOURCE" != "$1" ]; then
|
||||
bats_capture_stack_trace
|
||||
|
||||
Reference in New Issue
Block a user