mirror of
https://github.com/sstephenson/bats.git
synced 2024-11-17 11:42:33 +01:00
bats: Convert abs_dirname to use printf -v
Under Bash 3.2.57(1)-release and 4.4.12(1)-release on a MacBook Pro with a 2.9GHz Intel Core i5 CPU and 8GB 1867MHz DDR3 RAM, this shaves off O(0.1s) from the current test suite. Before the change: 46 tests, 0 failures real 0m3.983s user 0m2.320s sys 0m1.241s After the change: real 0m3.861s user 0m2.276s sys 0m1.174s
This commit is contained in:
parent
cdc55ad7ea
commit
daf76c27c1
11
libexec/bats
11
libexec/bats
|
@ -51,7 +51,7 @@ abs_dirname() {
|
|||
path="$(resolve_link "$name")"
|
||||
done
|
||||
|
||||
pwd
|
||||
printf -v "$2" -- '%s' "$PWD"
|
||||
cd "$cwd"
|
||||
}
|
||||
|
||||
|
@ -63,9 +63,12 @@ expand_path() {
|
|||
} || echo "$1"
|
||||
}
|
||||
|
||||
BATS_LIBEXEC="$(abs_dirname "$0")"
|
||||
export BATS_PREFIX="$(abs_dirname "$BATS_LIBEXEC")"
|
||||
export BATS_CWD="$(abs_dirname .)"
|
||||
abs_dirname "$0" 'BATS_LIBEXEC'
|
||||
abs_dirname "$BATS_LIBEXEC" 'BATS_PREFIX'
|
||||
abs_dirname '.' 'BATS_CWD'
|
||||
|
||||
export BATS_PREFIX
|
||||
export BATS_CWD
|
||||
export PATH="$BATS_LIBEXEC:$PATH"
|
||||
|
||||
options=()
|
||||
|
|
Loading…
Reference in New Issue
Block a user