diff --git a/legacy/helper/posix-shell/log.sh b/legacy/helper/posix-shell/log.sh index 461f5ba..ff1934a 100644 --- a/legacy/helper/posix-shell/log.sh +++ b/legacy/helper/posix-shell/log.sh @@ -20,11 +20,11 @@ # When you use NC to reset terminal colors inside log output, # it resets back to the log level’s color instead of the terminal default. -: "${HLOG_NAMESPACE:="$(basename "$0")"}" -: "${HLOG_LEVEL:=trace}" # e.g. "info;ns1=debug;ns2=trace" +: "${HECTIC_NAMESPACE="$(basename "$0")"}" +: "${HECTIC_LOG:=trace}" # e.g. "info;ns1=debug;ns2=trace" validate_log_level_spec() { - spec=$HLOG_LEVEL + spec=$HECTIC_LOG levels="trace debug info notice warn error" @@ -58,7 +58,7 @@ validate_log_level_spec() { return 0 } -validate_log_level_spec || { printf "%b%b\n" "${BBLACK}${HLOG_NAMESPACE}> " "${color}invalid HLOG_LEVEL syntax${NC}" "$@" >&2; exit 1; } +validate_log_level_spec || { printf "%b%b\n" "${BBLACK}${HECTIC_NAMESPACE}> " "${color}invalid HECTIC_LOG syntax${NC}" "$@" >&2; exit 1; } log_level_num() { case $1 in @@ -74,8 +74,8 @@ log_level_num() { log_effective_level() { - spec=$HLOG_LEVEL - ns=$HLOG_NAMESPACE + spec=$HECTIC_LOG + ns=$HECTIC_NAMESPACE default_level= ns_level= @@ -133,5 +133,5 @@ log() { # shellcheck disable=SC1003 fmt="$(printf "%s$delimetr" "$@" | sed 's/\\033\[0m/''\'"$color"'/g')" shift - printf "%b%b\n" "${BBLACK}${HLOG_NAMESPACE}> " "$color$fmt$NC" >&2 + printf "%b%b\n" "${BBLACK}${HECTIC_NAMESPACE}> " "$color$fmt$NC" >&2 } diff --git a/package/migrator/migrator.sh b/package/migrator/migrator.sh index a28ac23..d034043 100644 --- a/package/migrator/migrator.sh +++ b/package/migrator/migrator.sh @@ -1,5 +1,7 @@ #!/bin/dash +set -eu + if ! command -v psql >/dev/null; then log error "Required tool (psql) are not installed." exit 127 @@ -17,6 +19,8 @@ sha256sum() { cksum --algorithm=sha256 --untagged "$file" | awk '{printf $1}' } +INHERITS_LIST= + while [ $# -gt 0 ]; do log debug "$1" case $1 in diff --git a/test/package/migrator/lauch.sh b/test/package/migrator/lauch.sh index d187e3e..2e47d42 100644 --- a/test/package/migrator/lauch.sh +++ b/test/package/migrator/lauch.sh @@ -3,6 +3,9 @@ # $out - nix derivation output # $test - test and assertion file +HECTIC_NAMESPACE=test-laucher +export HECTIC_LOG=trace + test_derivation="$(basename "$test")" test_name="${test_derivation#*-*-}" @@ -61,6 +64,8 @@ log info "run test ${WHITE}${test_name}${NC}" # run test . "${test}/run.sh" +HECTIC_NAMESPACE=test-laucher + log info "finish test pipeline" # success marker for Nix diff --git a/test/package/migrator/test/create-migration.sh b/test/package/migrator/test/create-migration.sh index 50cf4ab..c125194 100644 --- a/test/package/migrator/test/create-migration.sh +++ b/test/package/migrator/test/create-migration.sh @@ -1,7 +1,8 @@ -# -# first migration -# +#!/bin/dash +HECTIC_NAMESPACE=test-create-migration + +log notice "case: ${WHITE}first migration" if ! migrator create; then log error "test failed: error on migration creation" exit 1 @@ -17,10 +18,7 @@ if [ "$(find ./migration -maxdepth 1 -type f | wc -l)" -eq 0 ]; then exit 1 fi -# -# next migration -# - +log notice "case: ${WHITE}next migration" if ! migrator create; then log error "test failed: error on migration creation" exit 1 @@ -31,10 +29,7 @@ if [ "$(find ./migration -maxdepth 1 -type f | wc -l)" -eq 1 ]; then exit 1 fi -# -# migration with custom name -# - +log notice "case: ${WHITE}migration with custom name" if ! migrator create --name test; then log error "test failed: error on migration creation" exit 1 @@ -50,10 +45,7 @@ if ! find ./migration -maxdepth 1 -type f -name '*test.sql' \ log eror "test failed: migration have unexpected name" fi -# -# migration with custom name that contains space -# - +log notice "case: ${WHITE}migration with custom name that contains space" if ! migrator create --name 'test name'; then log error "test failed: error on migration creation" exit 1 diff --git a/test/package/migrator/test/init-migrations.sh b/test/package/migrator/test/init-migrator.sh similarity index 94% rename from test/package/migrator/test/init-migrations.sh rename to test/package/migrator/test/init-migrator.sh index 22d94e0..5b6d20f 100644 --- a/test/package/migrator/test/init-migrations.sh +++ b/test/package/migrator/test/init-migrator.sh @@ -1,5 +1,7 @@ #!/bin/dash +HECTIC_NAMESPACE=test-init-migrator + log info "hectic.migration table inheritance" if ! migration_table_sql="$(migrator --inherits tablename --inherits 'table name' init --dry-run)"; then log error "test failed: error on migration table init dry run" diff --git a/test/package/migrator/test/migrate-up/run.sh b/test/package/migrator/test/migrate-up/run.sh index f847ef0..e02f2de 100644 --- a/test/package/migrator/test/migrate-up/run.sh +++ b/test/package/migrator/test/migrate-up/run.sh @@ -1,3 +1,7 @@ +#!/bin/dash + +HECTIC_NAMESPACE=test-migration-list + psql "$DATABASE_URL" 'CREATE TABLE profile ( id INTEGER, username TEXT diff --git a/test/package/migrator/test/migrations-list/run.sh b/test/package/migrator/test/migrations-list/run.sh index 4bf39b5..f0a8d6c 100644 --- a/test/package/migrator/test/migrations-list/run.sh +++ b/test/package/migrator/test/migrations-list/run.sh @@ -1 +1,5 @@ +#!/bin/dash + +HECTIC_NAMESPACE=test-migration-list + #migrator list diff --git a/test/package/migrator/test/mising-psql.sh b/test/package/migrator/test/missing-psql.sh similarity index 91% rename from test/package/migrator/test/mising-psql.sh rename to test/package/migrator/test/missing-psql.sh index aecf016..cb17ada 100644 --- a/test/package/migrator/test/mising-psql.sh +++ b/test/package/migrator/test/missing-psql.sh @@ -1,3 +1,7 @@ +#!/bin/dash + +HECTIC_NAMESPACE=test-missing-psql + # remove psql from $PATH dir=$(dirname -- "$(command -v psql)") PATH=$(printf '%s' "$PATH" | awk -v RS=: -v ORS=: -v d="$dir" '$0!=d{print}')