From 6b7361a95d1d3e80a8029f8af08fa09c9e60a7d1 Mon Sep 17 00:00:00 2001 From: Chemaclass Date: Sat, 12 Oct 2024 22:02:19 +0200 Subject: [PATCH 1/6] feat: add caller_filename and caller_line globals --- .env.example | 3 ++- .gitignore | 2 +- CHANGELOG.md | 10 ++++++---- docs/configuration.md | 4 ++-- docs/globals.md | 2 +- src/env.sh | 4 ++-- src/globals.sh | 10 +++++++++- tests/unit/globals_test.sh | 34 +++++++++++++++++++++------------- 8 files changed, 44 insertions(+), 25 deletions(-) diff --git a/.env.example b/.env.example index 6e3108a6..5d454a26 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,8 @@ BASHUNIT_DEFAULT_PATH= +BASHUNIT_DEV_LOG= +BASHUNIT_LOAD_FILE= BASHUNIT_LOG_JUNIT= BASHUNIT_REPORT_HTML= -BASHUNIT_LOAD_FILE= # Booleans BASHUNIT_PARALLEL_RUN= diff --git a/.gitignore b/.gitignore index 2d402ece..f4c9adaf 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,4 @@ report.html # internal local/ -out.log +dev.log diff --git a/CHANGELOG.md b/CHANGELOG.md index d12d655d..6bfa08c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,12 @@ - Added `-p|--parallel` to enable running tests in parallel - Added `assert_file_contains` and `assert_file_not_contains` - Added `assert_true` and `assert_false` -- Added `BASHUNIT_LOG_PATH` +- Added `BASHUNIT_DEV_LOG` - Added global util functions - current_dir - current_filename + - caller_filename + - caller_line - current_timestamp - is_command_available - random_str @@ -17,9 +19,9 @@ - cleanup_temp_files - log - Add default env values: - - `DEFAULT_PATH="tests"` - - `LOG_PATH="out.log"` - - `LOAD_FILE="tests/bootstrap.sh"` + - `BASHUNIT_DEFAULT_PATH="tests"` + - `BASHUNIT_DEV_LOG="dev.log"` + - `BASHUNIT_LOAD_FILE="tests/bootstrap.sh"` - Add check that git is installed to `install.sh` - Fixed `-S|--stop-on-failure` behaviour - Improved time taken display diff --git a/docs/configuration.md b/docs/configuration.md index 32e409e3..5ff1b0c5 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -204,13 +204,13 @@ BASHUNIT_LOAD_FILE="tests/globals.sh" ## Log path -> `BASHUNIT_LOG_PATH=file` +> `BASHUNIT_DEV_LOG=file` > See: [Globals > log](/globals#log) ::: code-group ```bash [Setup] -BASHUNIT_LOG_PATH="out.log" +BASHUNIT_DEV_LOG="out.log" ``` ```bash [Usage] log "I am tracing something..." diff --git a/docs/globals.md b/docs/globals.md index 9261ccad..89e943bf 100644 --- a/docs/globals.md +++ b/docs/globals.md @@ -75,7 +75,7 @@ function test_globals_temp_dir() { ## log -Write into the `BASHUNIT_LOG_PATH` a log message. +Write into the `BASHUNIT_DEV_LOG` a log message. > See: [Log path](/configuration#log-path) diff --git a/src/env.sh b/src/env.sh index 3188eaf8..84a93516 100644 --- a/src/env.sh +++ b/src/env.sh @@ -8,14 +8,14 @@ set -o allexport set +o allexport _DEFAULT_DEFAULT_PATH="tests" -_DEFAULT_LOG_PATH="out.log" +_DEFAULT_DEV_LOG="dev.log" _DEFAULT_LOAD_FILE="tests/bootstrap.sh" _DEFAULT_LOG_JUNIT="" _DEFAULT_REPORT_HTML="" : "${BASHUNIT_DEFAULT_PATH:=${DEFAULT_PATH:=$_DEFAULT_DEFAULT_PATH}}" : "${BASHUNIT_LOG_JUNIT:=${LOG_JUNIT:=$_DEFAULT_LOG_JUNIT}}" -: "${BASHUNIT_LOG_PATH:=${LOG_PATH:=$_DEFAULT_LOG_PATH}}" +: "${BASHUNIT_DEV_LOG:=${DEV_LOG:=$_DEFAULT_DEV_LOG}}" : "${BASHUNIT_REPORT_HTML:=${REPORT_HTML:=$_DEFAULT_REPORT_HTML}}" : "${BASHUNIT_LOAD_FILE:=${LOAD_FILE:=$_DEFAULT_LOAD_FILE}}" diff --git a/src/globals.sh b/src/globals.sh index 515cd73c..4ff70e2c 100644 --- a/src/globals.sh +++ b/src/globals.sh @@ -11,6 +11,14 @@ function current_filename() { basename "${BASH_SOURCE[1]}" } +function caller_filename() { + dirname "${BASH_SOURCE[2]}" +} + +function caller_line() { + echo "${BASH_LINENO[1]}" +} + function current_timestamp() { date +"%Y-%m-%d %H:%M:%S" } @@ -54,5 +62,5 @@ function log() { *) set -- "$level $@"; level="INFO" ;; esac - echo "$(current_timestamp) [$level]: $@" >> "$BASHUNIT_LOG_PATH" + echo "$(current_timestamp) [$level]: $@" >> "$BASHUNIT_DEV_LOG" } diff --git a/tests/unit/globals_test.sh b/tests/unit/globals_test.sh index c3b59445..92224315 100644 --- a/tests/unit/globals_test.sh +++ b/tests/unit/globals_test.sh @@ -1,13 +1,13 @@ #!/bin/bash set -euo pipefail -function set_up_before_script() { - BASHUNIT_LOG_PATH=$(temp_file) - export BASHUNIT_LOG_PATH +function set_up() { + BASHUNIT_DEV_LOG=$(temp_file) + export BASHUNIT_DEV_LOG } -function tear_down_after_script() { - rm "$BASHUNIT_LOG_PATH" +function tear_down() { + rm "$BASHUNIT_DEV_LOG" } function test_globals_current_dir() { @@ -18,6 +18,14 @@ function test_globals_current_filename() { assert_same "globals_test.sh" "$(current_filename)" } +function test_globals_caller_filename() { + assert_same "./src" "$(caller_filename)" +} + +function test_globals_caller_line() { + assert_same 148 "$(caller_line)" +} + function test_globals_current_timestamp() { assert_matches \ "^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$" \ @@ -36,11 +44,11 @@ function test_globals_is_command_not_available() { assert_general_error "$(is_command_available non_existing_fn)" } -function test_globals_random_str_default() { +function test_globals_random_str_default_len() { assert_matches "^[A-Za-z0-9]{6}$" "$(random_str)" } -function test_globals_random_str_custom() { +function test_globals_random_str_custom_len() { assert_matches "^[A-Za-z0-9]{3}$" "$(random_str 3)" } @@ -63,35 +71,35 @@ function test_globals_temp_dir() { function test_globals_log_level_error() { log "error" "hello," "error" - assert_file_contains "$BASHUNIT_LOG_PATH" "[ERROR]: hello, error" + assert_file_contains "$BASHUNIT_DEV_LOG" "[ERROR]: hello, error" } function test_globals_log_level_warning() { log "warning" "hello," "warning" - assert_file_contains "$BASHUNIT_LOG_PATH" "[WARNING]: hello, warning" + assert_file_contains "$BASHUNIT_DEV_LOG" "[WARNING]: hello, warning" } function test_globals_log_level_debug() { log "debug" "hello," "debug" - assert_file_contains "$BASHUNIT_LOG_PATH" "[DEBUG]: hello, debug" + assert_file_contains "$BASHUNIT_DEV_LOG" "[DEBUG]: hello, debug" } function test_globals_log_level_critical() { log "critical" "hello," "critical" - assert_file_contains "$BASHUNIT_LOG_PATH" "[CRITICAL]: hello, critical" + assert_file_contains "$BASHUNIT_DEV_LOG" "[CRITICAL]: hello, critical" } function test_globals_log_level_info() { log "info" "hello," "info" - assert_file_contains "$BASHUNIT_LOG_PATH" "[INFO]: hello, info" + assert_file_contains "$BASHUNIT_DEV_LOG" "[INFO]: hello, info" } function test_globals_log_level_default() { log "hello," "info" - assert_file_contains "$BASHUNIT_LOG_PATH" "[INFO]: hello, info" + assert_file_contains "$BASHUNIT_DEV_LOG" "[INFO]: hello, info" } From f564e7a5ece0df9e72b32ada0d5d2592f2d37134 Mon Sep 17 00:00:00 2001 From: Chemaclass Date: Sat, 12 Oct 2024 22:08:38 +0200 Subject: [PATCH 2/6] feat: rename --verbose to --detailed --- CHANGELOG.md | 2 ++ bashunit | 2 +- docs/command-line.md | 4 ++-- docs/configuration.md | 2 +- tests/acceptance/bashunit_fail_test.sh | 4 ++-- tests/acceptance/bashunit_pass_test.sh | 4 ++-- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bfa08c8..5ff738e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,8 @@ - Improved clean up temporal files and directories - Improved CI test speed by running them in parallel - Removed git dependency for stable installations +- Rename option `--verbose` to `--detailed` + - which is the default display behaviour, the opposite as `--simple` ## [0.17.0](https://github.com/TypedDevs/bashunit/compare/0.16.0...0.17.0) - 2024-10-01 diff --git a/bashunit b/bashunit index 98d9a439..ec0410de 100755 --- a/bashunit +++ b/bashunit @@ -51,7 +51,7 @@ while [[ $# -gt 0 ]]; do -s|--simple) export BASHUNIT_SIMPLE_OUTPUT=true ;; - -vvv|--verbose) + --detailed) export BASHUNIT_SIMPLE_OUTPUT=false ;; --debug) diff --git a/docs/command-line.md b/docs/command-line.md index c228fc6c..b421408f 100644 --- a/docs/command-line.md +++ b/docs/command-line.md @@ -137,7 +137,7 @@ Creates a report HTML file that contains information about the test results of y > `bashunit -s|--simple` > -> `bashunit -vvv|--verbose` +> `bashunit -vvv|--detailed` Enables simplified or verbose output to the console. @@ -170,7 +170,7 @@ Running tests/functional/logic_test.sh ✓ Passed: Text should not match a regular expression ``` ```bash [Example] -./bashunit ./tests --verbose +./bashunit ./tests --detailed ``` ::: diff --git a/docs/configuration.md b/docs/configuration.md index 5ff1b0c5..3db6ea69 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -38,7 +38,7 @@ Enables simplified output to the console. `false` by default. Verbose is the default output, but it can be overridden by the environment configuration. -Similar as using `-s|--simple | -vvv|--verbose` option on the [command line](/command-line#output). +Similar as using `-s|--simple | -vvv|--detailed` option on the [command line](/command-line#output). ::: code-group ```bash [Simple output] diff --git a/tests/acceptance/bashunit_fail_test.sh b/tests/acceptance/bashunit_fail_test.sh index 08b23fec..03604036 100644 --- a/tests/acceptance/bashunit_fail_test.sh +++ b/tests/acceptance/bashunit_fail_test.sh @@ -16,8 +16,8 @@ function test_bashunit_when_a_test_fail_verbose_output_env() { function test_bashunit_when_a_test_fail_verbose_output_option() { local test_file=./tests/acceptance/fixtures/test_bashunit_when_a_test_fail.sh - assert_match_snapshot "$(./bashunit --no-parallel --env "$TEST_ENV_FILE_SIMPLE" "$test_file" --verbose)" - assert_general_error "$(./bashunit --no-parallel --env "$TEST_ENV_FILE_SIMPLE" "$test_file" --verbose)" + assert_match_snapshot "$(./bashunit --no-parallel --env "$TEST_ENV_FILE_SIMPLE" "$test_file" --detailed)" + assert_general_error "$(./bashunit --no-parallel --env "$TEST_ENV_FILE_SIMPLE" "$test_file" --detailed)" } function test_different_verbose_snapshots_matches() { diff --git a/tests/acceptance/bashunit_pass_test.sh b/tests/acceptance/bashunit_pass_test.sh index 4d71a6f3..2159ccf4 100644 --- a/tests/acceptance/bashunit_pass_test.sh +++ b/tests/acceptance/bashunit_pass_test.sh @@ -16,8 +16,8 @@ function test_bashunit_when_a_test_passes_verbose_output_env() { function test_bashunit_when_a_test_passes_verbose_output_option() { local test_file=./tests/acceptance/fixtures/test_bashunit_when_a_test_passes.sh - assert_match_snapshot "$(./bashunit --no-parallel --env "$TEST_ENV_FILE_SIMPLE" "$test_file" --verbose)" - assert_successful_code "$(./bashunit --no-parallel --env "$TEST_ENV_FILE_SIMPLE" "$test_file" --verbose)" + assert_match_snapshot "$(./bashunit --no-parallel --env "$TEST_ENV_FILE_SIMPLE" "$test_file" --detailed)" + assert_successful_code "$(./bashunit --no-parallel --env "$TEST_ENV_FILE_SIMPLE" "$test_file" --detailed)" } function test_different_verbose_snapshots_matches() { From 2e6d5def3dcb7d1ee6c2d65545fa9797f799d775 Mon Sep 17 00:00:00 2001 From: Chemaclass Date: Sat, 12 Oct 2024 22:13:54 +0200 Subject: [PATCH 3/6] feat: add --detailed [default] to console_headers.sh --- bashunit | 2 +- src/console_header.sh | 8 ++++---- ...h.test_bashunit_without_path_env_nor_argument.snapshot | 8 ++++---- ...nit_test_sh.test_bashunit_should_display_help.snapshot | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/bashunit b/bashunit index ec0410de..8714a3fd 100755 --- a/bashunit +++ b/bashunit @@ -91,7 +91,7 @@ while [[ $# -gt 0 ]]; do upgrade::upgrade trap '' EXIT && exit 0 ;; - --help) + -h|--help) console_header::print_help trap '' EXIT && exit 0 ;; diff --git a/src/console_header.sh b/src/console_header.sh index d7ff1472..8c78d1ab 100644 --- a/src/console_header.sh +++ b/src/console_header.sh @@ -79,14 +79,14 @@ Options: -p|--parallel Run each test in child process, randomizing the tests execution order. - --no-parallel + --no-parallel [default] Disable the --parallel option. Util to disable parallel tests from within another test. -r|--report-html Create a report HTML file that contains information about the test results. - -s|simple || -v|verbose - Enables simplified or verbose output to the console. + -s|--simple || --detailed [default] + Enables simple or detailed output to the console. -S|--stop-on-failure Force to stop the runner right after encountering one failing test. @@ -97,7 +97,7 @@ Options: --upgrade Upgrade to latest version of bashunit. - --help + -h|--help This message. See more: https://bashunit.typeddevs.com/command-line diff --git a/tests/acceptance/snapshots/bashunit_path_test_sh.test_bashunit_without_path_env_nor_argument.snapshot b/tests/acceptance/snapshots/bashunit_path_test_sh.test_bashunit_without_path_env_nor_argument.snapshot index c0945093..b4f80a3b 100644 --- a/tests/acceptance/snapshots/bashunit_path_test_sh.test_bashunit_without_path_env_nor_argument.snapshot +++ b/tests/acceptance/snapshots/bashunit_path_test_sh.test_bashunit_without_path_env_nor_argument.snapshot @@ -26,14 +26,14 @@ Options: -p|--parallel Run each test in child process, randomizing the tests execution order. - --no-parallel + --no-parallel [default] Disable the --parallel option. Util to disable parallel tests from within another test. -r|--report-html Create a report HTML file that contains information about the test results. - -s|simple || -v|verbose - Enables simplified or verbose output to the console. + -s|--simple || --detailed [default] + Enables simple or detailed output to the console. -S|--stop-on-failure Force to stop the runner right after encountering one failing test. @@ -44,7 +44,7 @@ Options: --upgrade Upgrade to latest version of bashunit. - --help + -h|--help This message. See more: https://bashunit.typeddevs.com/command-line diff --git a/tests/acceptance/snapshots/bashunit_test_sh.test_bashunit_should_display_help.snapshot b/tests/acceptance/snapshots/bashunit_test_sh.test_bashunit_should_display_help.snapshot index 76737976..90f3c70d 100644 --- a/tests/acceptance/snapshots/bashunit_test_sh.test_bashunit_should_display_help.snapshot +++ b/tests/acceptance/snapshots/bashunit_test_sh.test_bashunit_should_display_help.snapshot @@ -25,14 +25,14 @@ Options: -p|--parallel Run each test in child process, randomizing the tests execution order. - --no-parallel + --no-parallel [default] Disable the --parallel option. Util to disable parallel tests from within another test. -r|--report-html Create a report HTML file that contains information about the test results. - -s|simple || -v|verbose - Enables simplified or verbose output to the console. + -s|--simple || --detailed [default] + Enables simple or detailed output to the console. -S|--stop-on-failure Force to stop the runner right after encountering one failing test. @@ -43,7 +43,7 @@ Options: --upgrade Upgrade to latest version of bashunit. - --help + -h|--help This message. See more: https://bashunit.typeddevs.com/command-line From d251d4a489323ecf6e1538018c71824010dec173 Mon Sep 17 00:00:00 2001 From: Chemaclass Date: Sat, 12 Oct 2024 22:17:01 +0200 Subject: [PATCH 4/6] feat: improve --help message --- src/console_header.sh | 18 +++++++++--------- ...unit_without_path_env_nor_argument.snapshot | 18 +++++++++--------- ....test_bashunit_should_display_help.snapshot | 18 +++++++++--------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/console_header.sh b/src/console_header.sh index 8c78d1ab..f1d49d80 100644 --- a/src/console_header.sh +++ b/src/console_header.sh @@ -60,35 +60,35 @@ Arguments: If you use wildcards, bashunit will run any tests it finds. Options: - -a|--assert + -a, --assert Run a core assert function standalone without a test context. --debug Print all executed shell commands to the terminal. If a file-path is passed, it will redirect the output to that file. - -e|--env|--load + -e, --env, --load Load a custom file, overriding the existing .env variables or loading a file with global functions. - -f|--filter + -f, --filter Filters the tests to run based on the test name. - -l|--log-junit + -l, --log-junit Create a report JUnit XML file that contains information about the test results. - -p|--parallel + -p, --parallel Run each test in child process, randomizing the tests execution order. --no-parallel [default] Disable the --parallel option. Util to disable parallel tests from within another test. - -r|--report-html + -r, --report-html Create a report HTML file that contains information about the test results. - -s|--simple || --detailed [default] + -s, --simple || --detailed [default] Enables simple or detailed output to the console. - -S|--stop-on-failure + -S, --stop-on-failure Force to stop the runner right after encountering one failing test. --version @@ -97,7 +97,7 @@ Options: --upgrade Upgrade to latest version of bashunit. - -h|--help + -h, --help This message. See more: https://bashunit.typeddevs.com/command-line diff --git a/tests/acceptance/snapshots/bashunit_path_test_sh.test_bashunit_without_path_env_nor_argument.snapshot b/tests/acceptance/snapshots/bashunit_path_test_sh.test_bashunit_without_path_env_nor_argument.snapshot index b4f80a3b..8915da53 100644 --- a/tests/acceptance/snapshots/bashunit_path_test_sh.test_bashunit_without_path_env_nor_argument.snapshot +++ b/tests/acceptance/snapshots/bashunit_path_test_sh.test_bashunit_without_path_env_nor_argument.snapshot @@ -7,35 +7,35 @@ Arguments: If you use wildcards, bashunit will run any tests it finds. Options: - -a|--assert + -a, --assert Run a core assert function standalone without a test context. --debug Print all executed shell commands to the terminal. If a file-path is passed, it will redirect the output to that file. - -e|--env|--load + -e, --env, --load Load a custom file, overriding the existing .env variables or loading a file with global functions. - -f|--filter + -f, --filter Filters the tests to run based on the test name. - -l|--log-junit + -l, --log-junit Create a report JUnit XML file that contains information about the test results. - -p|--parallel + -p, --parallel Run each test in child process, randomizing the tests execution order. --no-parallel [default] Disable the --parallel option. Util to disable parallel tests from within another test. - -r|--report-html + -r, --report-html Create a report HTML file that contains information about the test results. - -s|--simple || --detailed [default] + -s, --simple || --detailed [default] Enables simple or detailed output to the console. - -S|--stop-on-failure + -S, --stop-on-failure Force to stop the runner right after encountering one failing test. --version @@ -44,7 +44,7 @@ Options: --upgrade Upgrade to latest version of bashunit. - -h|--help + -h, --help This message. See more: https://bashunit.typeddevs.com/command-line diff --git a/tests/acceptance/snapshots/bashunit_test_sh.test_bashunit_should_display_help.snapshot b/tests/acceptance/snapshots/bashunit_test_sh.test_bashunit_should_display_help.snapshot index 90f3c70d..8b02147d 100644 --- a/tests/acceptance/snapshots/bashunit_test_sh.test_bashunit_should_display_help.snapshot +++ b/tests/acceptance/snapshots/bashunit_test_sh.test_bashunit_should_display_help.snapshot @@ -6,35 +6,35 @@ Arguments: If you use wildcards, bashunit will run any tests it finds. Options: - -a|--assert + -a, --assert Run a core assert function standalone without a test context. --debug Print all executed shell commands to the terminal. If a file-path is passed, it will redirect the output to that file. - -e|--env|--load + -e, --env, --load Load a custom file, overriding the existing .env variables or loading a file with global functions. - -f|--filter + -f, --filter Filters the tests to run based on the test name. - -l|--log-junit + -l, --log-junit Create a report JUnit XML file that contains information about the test results. - -p|--parallel + -p, --parallel Run each test in child process, randomizing the tests execution order. --no-parallel [default] Disable the --parallel option. Util to disable parallel tests from within another test. - -r|--report-html + -r, --report-html Create a report HTML file that contains information about the test results. - -s|--simple || --detailed [default] + -s, --simple || --detailed [default] Enables simple or detailed output to the console. - -S|--stop-on-failure + -S, --stop-on-failure Force to stop the runner right after encountering one failing test. --version @@ -43,7 +43,7 @@ Options: --upgrade Upgrade to latest version of bashunit. - -h|--help + -h, --help This message. See more: https://bashunit.typeddevs.com/command-line From 92b7bdaa11ad16a4a44098efe39e76f05be80a9a Mon Sep 17 00:00:00 2001 From: Chemaclass Date: Sat, 12 Oct 2024 22:20:34 +0200 Subject: [PATCH 5/6] feat: group --no-parallel with --parallel on --help --- src/console_header.sh | 5 +---- src/env.sh | 4 ++-- ...t_sh.test_bashunit_without_path_env_nor_argument.snapshot | 5 +---- ...shunit_test_sh.test_bashunit_should_display_help.snapshot | 5 +---- tests/unit/globals_test.sh | 2 +- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/console_header.sh b/src/console_header.sh index f1d49d80..62133528 100644 --- a/src/console_header.sh +++ b/src/console_header.sh @@ -76,12 +76,9 @@ Options: -l, --log-junit Create a report JUnit XML file that contains information about the test results. - -p, --parallel + -p, --parallel || --no-parallel [default] Run each test in child process, randomizing the tests execution order. - --no-parallel [default] - Disable the --parallel option. Util to disable parallel tests from within another test. - -r, --report-html Create a report HTML file that contains information about the test results. diff --git a/src/env.sh b/src/env.sh index 84a93516..33f0a354 100644 --- a/src/env.sh +++ b/src/env.sh @@ -14,10 +14,10 @@ _DEFAULT_LOG_JUNIT="" _DEFAULT_REPORT_HTML="" : "${BASHUNIT_DEFAULT_PATH:=${DEFAULT_PATH:=$_DEFAULT_DEFAULT_PATH}}" -: "${BASHUNIT_LOG_JUNIT:=${LOG_JUNIT:=$_DEFAULT_LOG_JUNIT}}" : "${BASHUNIT_DEV_LOG:=${DEV_LOG:=$_DEFAULT_DEV_LOG}}" -: "${BASHUNIT_REPORT_HTML:=${REPORT_HTML:=$_DEFAULT_REPORT_HTML}}" : "${BASHUNIT_LOAD_FILE:=${LOAD_FILE:=$_DEFAULT_LOAD_FILE}}" +: "${BASHUNIT_LOG_JUNIT:=${LOG_JUNIT:=$_DEFAULT_LOG_JUNIT}}" +: "${BASHUNIT_REPORT_HTML:=${REPORT_HTML:=$_DEFAULT_REPORT_HTML}}" # Booleans _DEFAULT_PARALLEL_RUN="false" diff --git a/tests/acceptance/snapshots/bashunit_path_test_sh.test_bashunit_without_path_env_nor_argument.snapshot b/tests/acceptance/snapshots/bashunit_path_test_sh.test_bashunit_without_path_env_nor_argument.snapshot index 8915da53..15790555 100644 --- a/tests/acceptance/snapshots/bashunit_path_test_sh.test_bashunit_without_path_env_nor_argument.snapshot +++ b/tests/acceptance/snapshots/bashunit_path_test_sh.test_bashunit_without_path_env_nor_argument.snapshot @@ -23,12 +23,9 @@ Options: -l, --log-junit Create a report JUnit XML file that contains information about the test results. - -p, --parallel + -p, --parallel || --no-parallel [default] Run each test in child process, randomizing the tests execution order. - --no-parallel [default] - Disable the --parallel option. Util to disable parallel tests from within another test. - -r, --report-html Create a report HTML file that contains information about the test results. diff --git a/tests/acceptance/snapshots/bashunit_test_sh.test_bashunit_should_display_help.snapshot b/tests/acceptance/snapshots/bashunit_test_sh.test_bashunit_should_display_help.snapshot index 8b02147d..aa4902b9 100644 --- a/tests/acceptance/snapshots/bashunit_test_sh.test_bashunit_should_display_help.snapshot +++ b/tests/acceptance/snapshots/bashunit_test_sh.test_bashunit_should_display_help.snapshot @@ -22,12 +22,9 @@ Options: -l, --log-junit Create a report JUnit XML file that contains information about the test results. - -p, --parallel + -p, --parallel || --no-parallel [default] Run each test in child process, randomizing the tests execution order. - --no-parallel [default] - Disable the --parallel option. Util to disable parallel tests from within another test. - -r, --report-html Create a report HTML file that contains information about the test results. diff --git a/tests/unit/globals_test.sh b/tests/unit/globals_test.sh index 92224315..cf879169 100644 --- a/tests/unit/globals_test.sh +++ b/tests/unit/globals_test.sh @@ -23,7 +23,7 @@ function test_globals_caller_filename() { } function test_globals_caller_line() { - assert_same 148 "$(caller_line)" + assert_matches "[0-9]*" "$(caller_line)" } function test_globals_current_timestamp() { From 380257fb57af5d492badf72544826fc3c898dc92 Mon Sep 17 00:00:00 2001 From: Chemaclass Date: Sat, 12 Oct 2024 22:28:48 +0200 Subject: [PATCH 6/6] feat: improve --help message --- src/console_header.sh | 8 ++++---- ...h.test_bashunit_without_path_env_nor_argument.snapshot | 8 ++++---- ...nit_test_sh.test_bashunit_should_display_help.snapshot | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/console_header.sh b/src/console_header.sh index 62133528..3b35cdea 100644 --- a/src/console_header.sh +++ b/src/console_header.sh @@ -63,10 +63,6 @@ Options: -a, --assert Run a core assert function standalone without a test context. - --debug - Print all executed shell commands to the terminal. - If a file-path is passed, it will redirect the output to that file. - -e, --env, --load Load a custom file, overriding the existing .env variables or loading a file with global functions. @@ -88,6 +84,10 @@ Options: -S, --stop-on-failure Force to stop the runner right after encountering one failing test. + --debug + Print all executed shell commands to the terminal. + If a file-path is passed, it will redirect the output to that file. + --version Displays the current version of bashunit. diff --git a/tests/acceptance/snapshots/bashunit_path_test_sh.test_bashunit_without_path_env_nor_argument.snapshot b/tests/acceptance/snapshots/bashunit_path_test_sh.test_bashunit_without_path_env_nor_argument.snapshot index 15790555..195b3b8b 100644 --- a/tests/acceptance/snapshots/bashunit_path_test_sh.test_bashunit_without_path_env_nor_argument.snapshot +++ b/tests/acceptance/snapshots/bashunit_path_test_sh.test_bashunit_without_path_env_nor_argument.snapshot @@ -10,10 +10,6 @@ Options: -a, --assert Run a core assert function standalone without a test context. - --debug - Print all executed shell commands to the terminal. - If a file-path is passed, it will redirect the output to that file. - -e, --env, --load Load a custom file, overriding the existing .env variables or loading a file with global functions. @@ -35,6 +31,10 @@ Options: -S, --stop-on-failure Force to stop the runner right after encountering one failing test. + --debug + Print all executed shell commands to the terminal. + If a file-path is passed, it will redirect the output to that file. + --version Displays the current version of bashunit. diff --git a/tests/acceptance/snapshots/bashunit_test_sh.test_bashunit_should_display_help.snapshot b/tests/acceptance/snapshots/bashunit_test_sh.test_bashunit_should_display_help.snapshot index aa4902b9..b870750f 100644 --- a/tests/acceptance/snapshots/bashunit_test_sh.test_bashunit_should_display_help.snapshot +++ b/tests/acceptance/snapshots/bashunit_test_sh.test_bashunit_should_display_help.snapshot @@ -9,10 +9,6 @@ Options: -a, --assert Run a core assert function standalone without a test context. - --debug - Print all executed shell commands to the terminal. - If a file-path is passed, it will redirect the output to that file. - -e, --env, --load Load a custom file, overriding the existing .env variables or loading a file with global functions. @@ -34,6 +30,10 @@ Options: -S, --stop-on-failure Force to stop the runner right after encountering one failing test. + --debug + Print all executed shell commands to the terminal. + If a file-path is passed, it will redirect the output to that file. + --version Displays the current version of bashunit.