File tree Expand file tree Collapse file tree 7 files changed +34
-17
lines changed Expand file tree Collapse file tree 7 files changed +34
-17
lines changed Original file line number Diff line number Diff line change @@ -548,7 +548,7 @@ function assert_line_count() {
548548 local actual
549549 actual=$( echo " $input_str " | wc -l | tr -d ' [:blank:]' )
550550 local additional_new_lines
551- additional_new_lines=$( grep -o ' \\n' <<< " $input_str " | wc -l | tr -d ' [:blank:]' )
551+ additional_new_lines=$( echo " $input_str " | grep -o ' \\n' | wc -l | tr -d ' [:blank:]' )
552552 (( actual+= additional_new_lines))
553553 fi
554554
Original file line number Diff line number Diff line change @@ -61,7 +61,8 @@ function benchmark::run_function() {
6161 local revs=$2
6262 local its=$3
6363 local max_ms=$4
64- local durations=()
64+ local durations
65+ durations=()
6566
6667 for (( i= 1 ; i<= its; i++ )) ; do
6768 local start_time=$( clock::now)
@@ -135,13 +136,15 @@ function benchmark::print_results() {
135136
136137 if (( $(echo "$avg <= $max_ms " | bc - l) )) ; then
137138 local raw=" ≤ ${max_ms} "
138- printf -v padded " %14s" " $raw "
139+ local padded
140+ padded=$( printf " %14s" " $raw " )
139141 printf ' %-40s %6s %6s %10s %12s\n' " $name " " $revs " " $its " " $avg " " $padded "
140142 continue
141143 fi
142144
143145 local raw=" > ${max_ms} "
144- printf -v padded " %12s" " $raw "
146+ local padded
147+ padded=$( printf " %12s" " $raw " )
145148 printf ' %-40s %6s %6s %10s %s%s%s\n' \
146149 " $name " " $revs " " $its " " $avg " \
147150 " $_COLOR_FAILED " " $padded " " ${_COLOR_DEFAULT} "
Original file line number Diff line number Diff line change @@ -4,7 +4,8 @@ _CLOCK_NOW_IMPL=""
44
55function clock::_choose_impl() {
66 local shell_time
7- local attempts=()
7+ local attempts
8+ attempts=()
89
910 # 1. Try Perl with Time::HiRes
1011 attempts+=(" Perl" )
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ function helper::normalize_test_function_name() {
3333 # Replace underscores with spaces
3434 result=" ${result// _/ } "
3535 # Capitalize the first letter
36- result=" $( tr ' [:lower:]' ' [:upper:]' <<< " ${result:0:1} " ) ${result: 1} "
36+ result=" $( echo " ${result : 0 : 1} " | tr ' [:lower:]' ' [:upper:]' ) ${result: 1} "
3737
3838 echo " $result "
3939}
@@ -271,7 +271,8 @@ function helper::find_total_tests() {
271271 # shellcheck disable=SC2207
272272 local functions_to_run=($filtered_functions )
273273 for fn_name in " ${functions_to_run[@]} " ; do
274- local provider_data=()
274+ local provider_data
275+ provider_data=()
275276 while IFS=" " read -r line; do
276277 provider_data+=(" $line " )
277278 done <<< " $(helper::get_provider_data " $fn_name " " $file " )"
@@ -297,7 +298,8 @@ function helper::load_test_files() {
297298 local filter=$1
298299 local files=(" ${@: 2} " )
299300
300- local test_files=()
301+ local test_files
302+ test_files=()
301303
302304 if [[ " ${# files[@]} " -eq 0 ]]; then
303305 if [[ -n " ${BASHUNIT_DEFAULT_PATH} " ]]; then
@@ -316,7 +318,8 @@ function helper::load_bench_files() {
316318 local filter=$1
317319 local files=(" ${@: 2} " )
318320
319- local bench_files=()
321+ local bench_files
322+ bench_files=()
320323
321324 if [[ " ${# files[@]} " -eq 0 ]]; then
322325 if [[ -n " ${BASHUNIT_DEFAULT_PATH} " ]]; then
Original file line number Diff line number Diff line change @@ -4,7 +4,8 @@ function main::exec_tests() {
44 local filter=$1
55 local files=(" ${@: 2} " )
66
7- local test_files=()
7+ local test_files
8+ test_files=()
89 while IFS= read -r line; do
910 test_files+=(" $line " )
1011 done < <( helper::load_test_files " $filter " " ${files[@]} " )
@@ -82,7 +83,8 @@ function main::exec_benchmarks() {
8283 local filter=$1
8384 local files=(" ${@: 2} " )
8485
85- local bench_files=()
86+ local bench_files
87+ bench_files=()
8688 while IFS= read -r line; do
8789 bench_files+=(" $line " )
8890 done < <( helper::load_bench_files " $filter " " ${files[@]} " )
Original file line number Diff line number Diff line change @@ -5,7 +5,8 @@ function runner::load_test_files() {
55 local filter=$1
66 shift
77 local files=(" ${@ } " )
8- local scripts_ids=()
8+ local scripts_ids
9+ scripts_ids=()
910
1011 for test_file in " ${files[@]} " ; do
1112 if [[ ! -f $test_file ]]; then
@@ -189,7 +190,8 @@ function runner::call_test_functions() {
189190 break
190191 fi
191192
192- local provider_data=()
193+ local provider_data
194+ provider_data=()
193195 while IFS=" " read -r line; do
194196 provider_data+=(" $line " )
195197 done <<< " $(helper::get_provider_data " $fn_name " " $script " )"
@@ -203,7 +205,8 @@ function runner::call_test_functions() {
203205
204206 # Execute the test function for each line of data
205207 for data in " ${provider_data[@]} " ; do
206- local parsed_data=()
208+ local parsed_data
209+ parsed_data=()
207210 while IFS= read -r line; do
208211 parsed_data+=( " $( helper::decode_base64 " ${line} " ) " )
209212 done <<< " $(runner::parse_data_provider_args " $data " )"
@@ -236,7 +239,12 @@ function runner::call_bench_functions() {
236239 fi
237240
238241 for fn_name in " ${functions_to_run[@]} " ; do
239- read -r revs its max_ms <<< " $(benchmark::parse_annotations " $fn_name " " $script " )"
242+ local annotation_result
243+ annotation_result=" $( benchmark::parse_annotations " $fn_name " " $script " ) "
244+ set -- $annotation_result
245+ revs=" $1 "
246+ its=" $2 "
247+ max_ms=" $3 "
240248 benchmark::run_function " $fn_name " " $revs " " $its " " $max_ms "
241249 unset fn_name
242250 done
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22
3- declare -a MOCKED_FUNCTIONS=()
3+ MOCKED_FUNCTIONS=()
44
55function unmock() {
66 local command=$1
@@ -116,7 +116,7 @@ function assert_have_been_called_with() {
116116 fi
117117
118118 local raw
119- IFS= ' | ' read -r raw _ <<< " $line"
119+ raw= $( echo " $line " | cut -d ' | ' -f1 )
120120
121121 if [[ " $expected " != " $raw " ]]; then
122122 state::add_assertions_failed
You can’t perform that action at this time.
0 commit comments