* echo green

* PR comment
This commit is contained in:
Haitham Shami 2021-05-19 09:43:11 -07:00 коммит произвёл GitHub
Родитель 033bb4d6b4
Коммит f822049d6b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 55 добавлений и 22 удалений

Просмотреть файл

@ -5,7 +5,7 @@
if [[ $EUID -ne 0 ]]; if [[ $EUID -ne 0 ]];
then then
echo "ERROR: $0 requires elevated privileges.. " echo "$(echo -en "\e[31m")ERROR: $(echo -en "\e[00m")$0 requires elevated privileges.. "
exit 1 exit 1
fi fi
@ -145,3 +145,5 @@ then
rm -rf iot-edge-installer rm -rf iot-edge-installer
log_info "Removed temporary directory files for iot-edge-installer." log_info "Removed temporary directory files for iot-edge-installer."
fi fi
announce_my_log_file "All logs were appended to" $OUTPUT_FILE

Просмотреть файл

@ -6,6 +6,14 @@
# create flag:variable_name dictionary # create flag:variable_name dictionary
declare -A flag_to_variable_dict declare -A flag_to_variable_dict
RED=$(echo -en "\e[31m")
GREEN=$(echo -en "\e[32m")
MAGENTA=$(echo -en "\e[35m")
DEFAULT=$(echo -en "\e[00m")
BOLD=$(echo -en "\e[01m")
BLINK=$(echo -en "\e[5m")
###################################### ######################################
# add_option_args # add_option_args
# #
@ -49,6 +57,20 @@ function clear_option_args() {
flag_to_variable_dict=() flag_to_variable_dict=()
} }
######################################
# cmd_parser
#
# populates a dictionary of arguments and values from
# a given command line
#
# ARGUMENTS:
# command line
# OUTPUTS:
#
# RETURN:
# dictionary
######################################
function cmd_parser() { function cmd_parser() {
# create flag:variable_name dictionary and initialize to empty string # create flag:variable_name dictionary and initialize to empty string
declare -A parsed_cmd declare -A parsed_cmd
@ -124,6 +146,11 @@ log() {
fi fi
} }
#
function announce_my_log_file() {
printf '\n------\n%s%s%s%s%s\n------\n\n' "$GREEN" "$BOLD" "$BLINK" "$1 '$2'" "$DEFAULT"
}
# #
# logger # logger
log_init() { log_init() {
@ -136,7 +163,7 @@ log_init() {
OUTPUT_FILE=$TD"/"$(echo ${BASE_NAME%.*})-$(echo `date '+%Y-%m-%d'`).log OUTPUT_FILE=$TD"/"$(echo ${BASE_NAME%.*})-$(echo `date '+%Y-%m-%d'`).log
touch $OUTPUT_FILE touch $OUTPUT_FILE
echo "All logs will be appended to this file '"$OUTPUT_FILE"'" announce_my_log_file "All logs will be appended to file" $OUTPUT_FILE
} }
# #
@ -159,7 +186,7 @@ log_debug() {
log "DEBUG" "$@" log "DEBUG" "$@"
} }
export -f log_init log_error log_info log_warn log_debug export -f announce_my_log_file log_init log_error log_info log_warn log_debug
###################################### ######################################
# prepare_apt # prepare_apt

Просмотреть файл

@ -3,27 +3,13 @@
# Copyright (c) Microsoft Corporation. # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License. # Licensed under the MIT License.
if command -v tput &>/dev/null && tty -s; then
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
MAGENTA=$(tput setaf 5)
NORMAL=$(tput sgr0)
BOLD=$(tput bold)
else
RED=$(echo -en "\e[31m")
GREEN=$(echo -en "\e[32m")
MAGENTA=$(echo -en "\e[35m")
NORMAL=$(echo -en "\e[00m")
BOLD=$(echo -en "\e[01m")
fi
# #
error_output() { error_output() {
printf "%b\n" "${RED:-}Error: $1${NORMAL:-}" >&2 printf "%b\n" "${RED:-}Error: $1${DEFAULT:-}" >&2
} }
output() { output() {
printf "%b\n" "${BOLD:-}${NORMAL:-} $1" >&2 printf "%b\n" "${BOLD:-}${DEFAULT:-} $1" >&2
} }
verbose_output() { verbose_output() {
@ -52,6 +38,20 @@ assert_eq() {
fi fi
} }
assert_not_eq() {
local expected=$1; shift
local actual=$1; shift
NR_TOTALS=$(bc <<< $NR_TOTALS+1)
if [ "$expected" != "$actual" ];
then
NR_PASSING=$(bc <<< $NR_PASSING+1)
else
NR_FAILING=$(bc <<< $NR_FAILING+1)
error_output "expected: $expected; actual: $actual"
fi
}
assert_file() { assert_file() {
local file_name=$1; shift local file_name=$1; shift
@ -74,4 +74,4 @@ show_test_totals() {
printf "\n\n" printf "\n\n"
} }
export -f assert_eq assert_file show_test_totals export -f assert_eq assert_not_eq assert_file show_test_totals

Просмотреть файл

@ -43,3 +43,5 @@ test_service_ready
test_service_not_running test_service_not_running
test_service_missing test_service_missing
test_service_casesensitive test_service_casesensitive
show_test_totals

Просмотреть файл

@ -32,3 +32,5 @@ test_tier2() {
test_ubuntu1804 test_ubuntu1804
test_raspbian test_raspbian
test_tier2 test_tier2
show_test_totals