mirror of
https://github.com/sstephenson/bats.git
synced 2025-03-03 23:39:48 +01:00
exec-test: Use printf -v in bats_trim_filename
This commit is contained in:
parent
39440c5782
commit
eaa151fb69
|
@ -127,7 +127,7 @@ bats_print_stack_trace() {
|
||||||
|
|
||||||
for frame in "$@"; do
|
for frame in "$@"; do
|
||||||
bats_frame_filename "$frame" 'filename'
|
bats_frame_filename "$frame" 'filename'
|
||||||
filename="$(bats_trim_filename "$filename")"
|
bats_trim_filename "$filename" 'filename'
|
||||||
bats_frame_lineno "$frame" 'lineno'
|
bats_frame_lineno "$frame" 'lineno'
|
||||||
|
|
||||||
if [ $index -eq 1 ]; then
|
if [ $index -eq 1 ]; then
|
||||||
|
@ -203,13 +203,10 @@ bats_strip_string() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bats_trim_filename() {
|
bats_trim_filename() {
|
||||||
local filename="$1"
|
if [[ "$1" =~ ^${BATS_CWD}/ ]]; then
|
||||||
local length="${#BATS_CWD}"
|
printf -v "$2" '%s' "${1#$BATS_CWD/}"
|
||||||
|
|
||||||
if [ "${filename:0:length+1}" = "${BATS_CWD}/" ]; then
|
|
||||||
echo "${filename:length+1}"
|
|
||||||
else
|
else
|
||||||
echo "$filename"
|
printf -v "$2" '%s' "$1"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
fixtures() {
|
fixtures() {
|
||||||
FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures/$1"
|
FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures/$1"
|
||||||
RELATIVE_FIXTURE_ROOT="$(bats_trim_filename "$FIXTURE_ROOT")"
|
bats_trim_filename "$FIXTURE_ROOT" 'RELATIVE_FIXTURE_ROOT'
|
||||||
}
|
}
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user