11#! /bin/bash
22
3- VERSION=" 1.6.2 "
3+ VERSION=" 1.7.0 "
44
55# Dependencies
66
@@ -52,7 +52,7 @@ parse_yaml() {
5252# for tested program
5353
5454function shortname {
55- short_name=$( basename " $1 " | awk -F. ' {print $1"_"$2} ' )
55+ short_name=$( basename " $1 " | tr . _ )
5656 printf " $short_name "
5757}
5858
@@ -113,7 +113,8 @@ function _spinner() {
113113 sp=' \|/-'
114114 delay=${SPINNER_DELAY:- 0.15}
115115
116- echo -ne " "
116+ # echo -ne " "
117+ printf " \n "
117118 while :
118119 do
119120 printf " \b${sp: i++% ${# sp} : 1} "
@@ -128,21 +129,23 @@ function _spinner() {
128129 if [[ -z ${3} ]]; then
129130 # echo "spinner is not running.."
130131 # exit 1
131- # echo -e ""
132- sleep 0
133- else
134- kill -9 $3 > /dev/null 2>&1
135- while kill -0 $3 2> /dev/null; do sleep 0.005; done
136- # inform the user upon success or failure
137- echo -ne " \b"
138- # if [[ $2 -eq 0 ]]; then
139- # echo -en "${green}${on_success}${nc}"
140- # else
141- # echo -en "${red}${on_fail}${nc}"
142- # fi
143- # echo -e ""
144- fi
145- ;;
132+ # echo -e ""
133+ sleep 0
134+ else
135+ kill -9 $3 > /dev/null 2>&1
136+ while kill -0 $3 2> /dev/null; do sleep 0.005; done
137+ sleep 0.005
138+ printf " \b\b\b \b\b\b"
139+ # inform the user upon success or failure
140+ # echo -ne "\b"
141+ # if [[ $2 -eq 0 ]]; then
142+ # echo -en "${green}${on_success}${nc}"
143+ # else
144+ # echo -en "${red}${on_fail}${nc}"
145+ # fi
146+ # echo -e ""
147+ fi
148+ ;;
146149 * )
147150 echo " invalid argument, try {start/stop}"
148151 exit 1
@@ -151,7 +154,7 @@ function _spinner() {
151154}
152155
153156spinner_is_running=false
154- flag_use_spinner=false
157+ flag_use_spinner=true
155158
156159function start_spinner {
157160 if [[ " $flag_use_spinner " = " true" ]]; then
@@ -235,7 +238,8 @@ flag_additional_test_name_info=
235238flag_pipe_input=()
236239flag_pipe_output=()
237240flag_pipe_err_output=()
238- flag_no_pipes=" true"
241+ # Should be changed
242+ flag_no_pipes=" false"
239243flag_full_in_path_in_desc=" false"
240244
241245flag_override_good_out_file=
@@ -267,6 +271,10 @@ E_OK=
267271
268272TEXT_OK=" OK"
269273
274+ # TODO REMOVE
275+ # sleep 1
276+ # sready
277+ # exit 22
270278
271279function clean_temp_content {
272280 if [[ ${flag_out_temp} = ' true' ]]; then
@@ -775,21 +783,59 @@ function evalspecplain {
775783}
776784
777785#
778- # Usage: load_prop_variable <variable_prefix> <variable_name> <output_variable>
786+ # Usage: load_prop_variable <variable_prefix> <variable_name> <output_variable> <false_to_disable_parsing>
779787#
780788function load_prop_variable {
781789 input_var_name=" ${1}${2} "
782790 output_var_name=" ${3} "
783- input_var_value=" ${! input_var_name} "
791+ input_var_value_raw=" ${! input_var_name} "
792+ input_var_value=" $input_var_value_raw "
793+ if [[ " $4 " != " false" ]]; then
794+ input_var_value=$( evalspecplain " $input_var_value_raw " )
795+ fi
784796 output_var_value=" ${! output_var_name} "
785797
786798 if [[ " ${input_var_value} " != ' ' ]]; then
787- return_buffer=" ${return_buffer}${output_var_name} =\" ${output_var_value} \" \n"
799+ return_buffer=" ${output_var_name} =\" ${output_var_value} \" \n${return_buffer} "
800+ # printf "load_prop_variable ${output_var_name} -> ${input_var_value}\n"
801+ eval $output_var_name =" \$ input_var_value"
802+ fi
803+ }
804+
805+ #
806+ # Usage: load_prop_value <value> <output_variable> <false_to_disable_parsing>
807+ #
808+ function load_prop_value {
809+ temp_prop_variable_cap=" ${1} "
810+ load_prop_variable " " " temp_prop_variable_cap" " ${2} " " {3}"
811+ temp_prop_variable_cap=" "
812+ }
813+
814+ #
815+ # Usage: load_prop_variable_arr <variable_prefix> <variable_name> <output_variable>
816+ #
817+ function load_prop_variable_arr {
818+ input_var_name=" ${1}${2} "
819+ output_var_name=" ${3} "
820+ input_var_value_raw=$( eval echo " \"\$ {${input_var_name} [@]}\" " )
821+ # printf "_name => $input_var_name\n"
822+ # printf "_raw => $input_var_value_raw\n"
823+ input_var_value=" $input_var_value_raw "
824+ # input_var_value=$(evalspecplain "$input_var_value_raw")
825+ output_var_value=" ${! output_var_name} "
826+
827+ if [[ " ${input_var_value} " != ' ' ]]; then
828+ return_buffer=" ${output_var_name} =\" ${output_var_value} \" \n${return_buffer} "
788829 # printf "load_prop_variable ${output_var_name} -> ${input_var_value}\n"
789- eval $output_var_name =\$ input_var_value
830+
831+ # eval $output_var_name=\$input_var_value
832+ eval $output_var_name =' $input_var_value'
833+
834+ # printf "cur val => ${!output_var_name}\n"
790835 fi
791836}
792837
838+
793839function load_global_configuration_file {
794840 return_buffer=" "
795841 global_configuration_file_path=" ./utest.yaml"
@@ -801,8 +847,20 @@ function load_global_configuration_file {
801847 # printf "LOAD GLOBAL CONFIURATION FILE ${global_configuration_file_path}\n"
802848 configuration_parsed_setup=$( parse_yaml " ${global_configuration_file_path} " " global_config_" " false" )
803849
804- evalspec " $configuration_parsed_setup "
805-
850+ # printf "Global setup file contents:\n$configuration_parsed_setup\n"
851+ eval " $configuration_parsed_setup "
852+
853+ load_prop_variable " global_config_" " input" " param_dir" " false"
854+ load_prop_variable " global_config_" " good_output" " flag_good_out_path" " false"
855+ load_prop_variable " global_config_" " good_err" " flag_good_err_path" " false"
856+
857+ load_prop_variable " global_config_" " need_error_files" " flag_always_need_good_err" " false"
858+
859+ load_prop_variable " global_config_" " testing_script_out" " flag_test_out_script"
860+ load_prop_variable " global_config_" " testing_script_err" " flag_test_err_script"
861+
862+
863+ # printf "HERE flag_good_out_path => ${flag_good_out_path}\n"
806864
807865 if [[ " $global_config_executions_ " != " " ]]; then
808866 prog_arr_parser_acc=" "
@@ -825,24 +883,54 @@ function load_global_configuration_file {
825883
826884function load_single_test_configuration_file {
827885 return_buffer=" "
886+
887+ short_name=$( shortname " $param_prog " )
888+ if [[ " $param_prog_call_name " != " " ]]; then
889+ short_name=$( shortname " $param_prog_call_name " )
890+ fi
891+ # printf "short_name :=> $short_name\n"
892+
893+ config_prefix=" test_config_${short_name} __"
894+ global_config_prefix=" global_config_${short_name} __"
895+
896+ # printf "glob config prefix: ${global_config_prefix}test\n"
897+
898+ # Load global config
899+ load_prop_variable " ${global_config_prefix} " " command" " param_prog"
900+ load_prop_variable " ${global_config_prefix} " " args" " input_prog_flag_acc"
901+ load_prop_variable " ${global_config_prefix} " " in" " input_file_path"
902+
903+ load_prop_variable_arr " ${global_config_prefix} " " pipes_out_" " flag_pipe_output"
904+ load_prop_variable_arr " ${global_config_prefix} " " pipes_out_err_" " flag_pipe_err_output"
905+ load_prop_variable_arr " ${global_config_prefix} " " pipes_in_" " flag_pipe_input"
906+
907+ # load_prop_variable "${global_config_prefix}" "testing_script_out" "flag_test_out_script"
908+ # load_prop_variable "${global_config_prefix}" "testing_script_err" "flag_test_err_script"
909+
910+
911+ # flag_test_out_script
912+
828913 if [ -f " $single_test_configuration_file_path " ]; then
829914 #
830915 # Load configuration file for single test execution
831916 #
832917
833- short_name=$( shortname " $param_prog " )
834- config_prefix=" test_config_${short_name} __"
835-
836918 # printf "LOAD CONFIURATION FILE ${single_test_configuration_file_path}\n"
837919 configuration_parsed_setup=$( parse_yaml " ${single_test_configuration_file_path} " " test_config_" " false" | grep " $short_name " )
838920
839921 # printf "CONFIG:\n"
840922 # printf "$configuration_parsed_setup\n"
841923
842- evalspec " $configuration_parsed_setup "
924+ eval " $configuration_parsed_setup "
843925
844926 load_prop_variable " ${config_prefix} " " args" " input_prog_flag_acc"
845- load_prop_variable " ${config_prefix} " " executable" " param_prog"
927+
928+ # printf "input_prog_flag_acc ==> ${input_prog_flag_acc}\n"
929+
930+ # Sotre call name of prog
931+ load_prop_variable " " " param_prog" " param_prog_call_name" " false"
932+ load_prop_variable " ${config_prefix} " " command" " param_prog"
933+
846934 load_prop_variable " ${config_prefix} " " in" " input_file_path"
847935
848936
@@ -854,13 +942,18 @@ function load_single_test_configuration_file {
854942}
855943
856944function unload_single_test_configuration_file {
945+
946+ # Backup pre-global settings
947+ backup_global_config_script=$( printf " $return_buffer " )
948+ eval " $backup_global_config_script "
949+
857950 if [ -f " $single_test_configuration_file_path " ]; then
858951 #
859952 # Unload configuration file for single test execution
860953 #
861954 configuration_parsed_teardown=$( parse_yaml " ${single_test_configuration_file_path} " " test_config_" " true" )
862955
863- backup_config_script=$( printf " $configuration_parsed_teardown \n $return_buffer \n " )
956+ backup_config_script=$( printf " $configuration_parsed_teardown " )
864957
865958 # printf "backup config:\n"
866959 # printf "$backup_config_script"
@@ -933,6 +1026,7 @@ function push_test_message_next_program {
9331026}
9341027
9351028function flush_test_messages {
1029+ sready
9361030 echo -en " ${message_accumulator} "
9371031 message_accumulator=" "
9381032 message_last_file_head=" "
@@ -972,7 +1066,7 @@ function abort_if_too_many_errors {
9721066 if [[ " $err_index " -gt 5 ]]; then
9731067 if [[ $flag_always_continue = ' false' ]]; then
9741068 sready
975- printf " \n${B_WARN} [!] Abort testing +5 errors.${E_WARN} \nDo not use --ta flag to always continue."
1069+ printf " \n${B_WARN} [!] Abort testing +5 errors.${E_WARN} \nDo not use --ta flag to always continue."
9761070 clean_temp
9771071 close 1
9781072 fi
@@ -1084,7 +1178,7 @@ function check_testing_script {
10841178 fi
10851179 if [[ $test_not_exists = ' true' ]]; then
10861180 sready
1087- printf " %-35s %s\n" " ${B_DEBUG} [$file_index /$file_count ]${E_DEBUG} $input_file $flag_additional_test_name_info " " ${B_ERR} [ERR] Testing script does not exists or is invalid command (--tscript). Abort.${E_ERR} "
1181+ printf " %-35s %s\n" " ${B_DEBUG} [$file_index /$file_count ]${E_DEBUG} $input_file $flag_additional_test_name_info " " ${B_ERR} [ERR] Testing script does not exists or is invalid command (--tscript). Abort.${E_ERR} "
10881182 printf " %-30s %s\n" " " " ${B_ERR} Used command: $flag_test_out_script ${E_ERR} "
10891183
10901184 clean_temp
@@ -1170,7 +1264,7 @@ function print_tooling_additional_test_info {
11701264 if [[ $tooling_additional_test_info != ' ' ]]; then
11711265 tooling_message=$( echo -en " $tooling_additional_test_info " | sed " s/^/ /g" )
11721266 sready
1173- printf " ${B_DEBUG}${tooling_message}${E_DEBUG} \n"
1267+ printf " ${B_DEBUG}${tooling_message}${E_DEBUG} \n"
11741268 fi
11751269}
11761270
14901584 #
14911585 flag_good_out_path_unparsed=$flag_good_out_path
14921586 flag_good_err_path_unparsed=$flag_good_err_path
1587+
14931588 flag_good_out_path=$( evalspecplain " $flag_good_out_path " )
14941589 flag_good_err_path=$( evalspecplain " $flag_good_err_path " )
14951590
0 commit comments