Skip to content

Commit f38ed1a

Browse files
committed
✅ fixed tests
1 parent e4e2131 commit f38ed1a

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

tests.d/cli-logging/01.logging.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ function test_logLevelOptions() {
1313
test::title "✅ Logging level through an environment variable"
1414
test::exec VALET_LOG_LEVEL=success "${GLOBAL_INSTALLATION_DIRECTORY}/valet" self mock1 logging-level
1515

16-
1716
test::title "✅ Logging level with --log-level option"
1817
test::exec "${GLOBAL_INSTALLATION_DIRECTORY}/valet" --log-level warning self mock1 logging-level
1918

@@ -31,34 +30,30 @@ function test_logLevelOptions() {
3130
test::title "✅ Logging level with --verbose option"
3231
test::exec "${GLOBAL_INSTALLATION_DIRECTORY}/valet" -v self mock1 logging-level
3332

34-
3533
test::title "✅ Logging level with DEBUG set (also activates profiling)"
3634
test::exec DEBUG=1 "${GLOBAL_INSTALLATION_DIRECTORY}/valet" self mock1 logging-level
3735

3836
unset -f test::scrubOutput
3937
}
4038

41-
4239
function test_logDisplayOptions() {
4340
test::title "✅ Testing that we can change the log display options"
4441
export VALET_CONFIG_LOG_PATTERN='<level>_<message>'
4542
test::exec VALET_CONFIG_LOG_COLUMNS=40 VALET_CONFIG_ENABLE_COLORS=true VALET_CONFIG_ENABLE_NERDFONT_ICONS=true VALET_CONFIG_LOG_DISABLE_WRAP=false VALET_CONFIG_LOG_DISABLE_HIGHLIGHT=false "${GLOBAL_INSTALLATION_DIRECTORY}/valet" self mock1 logging-level
4643
export VALET_CONFIG_LOG_PATTERN="<level> <message>"
4744
}
4845

49-
5046
function test_logOutputOptions() {
5147
fs::createTempDirectory
5248
local logDir="${REPLY}"
5349

5450
test::title "✅ Testing that we can output the logs to a directory additionally to console"
5551
test::exec VALET_CONFIG_LOG_TO_DIRECTORY="${logDir}" "${GLOBAL_INSTALLATION_DIRECTORY}/valet" self mock1 logging-level
5652
# shellcheck disable=SC2317
57-
function test::scrubOutput() { GLOBAL_TEST_OUTPUT_CONTENT="${GLOBAL_TEST_OUTPUT_CONTENT//????-??-??T??-??-??+????--PID_??????.log/2025-02-12T21-57-29+0000.log}" ; }
53+
function test::scrubOutput() { GLOBAL_TEST_OUTPUT_CONTENT="${GLOBAL_TEST_OUTPUT_CONTENT//????-??-??T??-??-??+????--PID_??????.log/2025-02-12T21-57-29+0000.log}"; }
5854
test::func fs::listFiles "${logDir}"
5955
unset -f test::scrubOutput
6056

61-
6257
test::title "✅ Testing that we can output the logs to a specific file name additionally to console"
6358
test::exec VALET_CONFIG_LOG_FILENAME_PATTERN='logFile=test.log' VALET_CONFIG_LOG_TO_DIRECTORY="true" "${GLOBAL_INSTALLATION_DIRECTORY}/valet" self mock1 logging-level
6459
core::getUserStateDirectory
@@ -71,7 +66,8 @@ function test_logOutputOptions() {
7166
test::title "✅ Testing that we can output the logs to a specific numbered fd"
7267
local myFd
7368
exec {myFd}>>"${logDir}/test3.log"
74-
test::exec VALET_CONFIG_LOG_FD="${myFd}" "${GLOBAL_INSTALLATION_DIRECTORY}/valet" self mock1 logging-level
69+
test::prompt export VALET_CONFIG_LOG_FD=11
70+
VALET_CONFIG_LOG_FD="${myFd}" test::exec "${GLOBAL_INSTALLATION_DIRECTORY}/valet" self mock1 logging-level
7571
test::exec fs::cat "${logDir}/test3.log"
7672
}
7773

tests.d/lib-log/00.log.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ function main() {
1818
test::exec styles::init
1919
test_log
2020

21-
2221
test::title "✅ Testing with full formatting"
2322
VALET_CONFIG_ENABLE_COLORS=true
2423
VALET_CONFIG_ENABLE_NERDFONT_ICONS=true
@@ -57,6 +56,11 @@ function test_log::printCallStack() {
5756
function test_log::init() {
5857
test::title "✅ Testing log::init"
5958

59+
# shellcheck disable=SC2317
60+
function test::scrubOutput() {
61+
GLOBAL_TEST_OUTPUT_CONTENT="${GLOBAL_TEST_OUTPUT_CONTENT//" 1>&"[0-9][0-9]/" 1>&11"}"
62+
}
63+
6064
# test bad descriptors
6165
test::exit VALET_CONFIG_LOG_FD=5 log::init
6266
test::exit VALET_CONFIG_LOG_FD=/unknown/file/path log::init
@@ -81,6 +85,8 @@ function test_log::init() {
8185

8286
test::exec VALET_CONFIG_LOG_FD="${GLOBAL_TEST_TEMP_FILE}" VALET_CONFIG_LOG_TO_DIRECTORY=true VALET_CONFIG_LOG_FILENAME_PATTERN="logFile=a" log::init
8387
test::printVars GLOBAL_LOG_PRINT_STATEMENT_FORMATTED_LOG GLOBAL_LOG_PRINT_STATEMENT_STANDARD GLOBAL_LOG_WRAP_PADDING
88+
89+
unset -f test::scrubOutput
8490
}
8591

8692
function test_log::parseLogPattern() {

version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.37.8
1+
0.37.11

0 commit comments

Comments
 (0)