Skip to content

Commit

Permalink
Merge pull request #369 from TypedDevs/feat/rename-verbose-to-detailed
Browse files Browse the repository at this point in the history
Rename verbose to detailed
  • Loading branch information
Chemaclass authored Oct 12, 2024
2 parents 98c326b + 380257f commit c36515a
Show file tree
Hide file tree
Showing 15 changed files with 98 additions and 86 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -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=
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ report.html

# internal
local/
out.log
dev.log
12 changes: 8 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,15 +19,17 @@
- 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
- 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

Expand Down
4 changes: 2 additions & 2 deletions bashunit
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ while [[ $# -gt 0 ]]; do
-s|--simple)
export BASHUNIT_SIMPLE_OUTPUT=true
;;
-vvv|--verbose)
--detailed)
export BASHUNIT_SIMPLE_OUTPUT=false
;;
--debug)
Expand Down Expand Up @@ -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
;;
Expand Down
4 changes: 2 additions & 2 deletions docs/command-line.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
```
:::

Expand Down
6 changes: 3 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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..."
Expand Down
2 changes: 1 addition & 1 deletion docs/globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
31 changes: 14 additions & 17 deletions src/console_header.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,44 +60,41 @@ Arguments:
If you use wildcards, bashunit will run any tests it finds.
Options:
-a|--assert <function ...args>
-a, --assert <function ...args>
Run a core assert function standalone without a test context.
--debug <?file-path>
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 <file-path>
-e, --env, --load <file-path>
Load a custom file, overriding the existing .env variables or loading a file with global functions.
-f|--filter <filter>
-f, --filter <filter>
Filters the tests to run based on the test name.
-l|--log-junit <out.xml>
-l, --log-junit <out.xml>
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
Disable the --parallel option. Util to disable parallel tests from within another test.
-r|--report-html <out.html>
-r, --report-html <out.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
-S, --stop-on-failure
Force to stop the runner right after encountering one failing test.
--debug <?file-path>
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.
--upgrade
Upgrade to latest version of bashunit.
--help
-h, --help
This message.
See more: https://bashunit.typeddevs.com/command-line
Expand Down
6 changes: 3 additions & 3 deletions src/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ 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_DEV_LOG:=${DEV_LOG:=$_DEFAULT_DEV_LOG}}"
: "${BASHUNIT_LOAD_FILE:=${LOAD_FILE:=$_DEFAULT_LOAD_FILE}}"
: "${BASHUNIT_LOG_JUNIT:=${LOG_JUNIT:=$_DEFAULT_LOG_JUNIT}}"
: "${BASHUNIT_LOG_PATH:=${LOG_PATH:=$_DEFAULT_LOG_PATH}}"
: "${BASHUNIT_REPORT_HTML:=${REPORT_HTML:=$_DEFAULT_REPORT_HTML}}"
: "${BASHUNIT_LOAD_FILE:=${LOAD_FILE:=$_DEFAULT_LOAD_FILE}}"

# Booleans
_DEFAULT_PARALLEL_RUN="false"
Expand Down
10 changes: 9 additions & 1 deletion src/globals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down Expand Up @@ -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"
}
4 changes: 2 additions & 2 deletions tests/acceptance/bashunit_fail_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/bashunit_pass_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,41 @@ Arguments:
If you use wildcards, bashunit will run any tests it finds.

Options:
-a|--assert <function ...args>
-a, --assert <function ...args>
Run a core assert function standalone without a test context.

--debug <?file-path>
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 <file-path>
-e, --env, --load <file-path>
Load a custom file, overriding the existing .env variables or loading a file with global functions.

-f|--filter <filter>
-f, --filter <filter>
Filters the tests to run based on the test name.

-l|--log-junit <out.xml>
-l, --log-junit <out.xml>
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
Disable the --parallel option. Util to disable parallel tests from within another test.

-r|--report-html <out.html>
-r, --report-html <out.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
-S, --stop-on-failure
Force to stop the runner right after encountering one failing test.

--debug <?file-path>
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.

--upgrade
Upgrade to latest version of bashunit.

--help
-h, --help
This message.

See more: https://bashunit.typeddevs.com/command-line
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,41 @@ Arguments:
If you use wildcards, bashunit will run any tests it finds.

Options:
-a|--assert <function ...args>
-a, --assert <function ...args>
Run a core assert function standalone without a test context.

--debug <?file-path>
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 <file-path>
-e, --env, --load <file-path>
Load a custom file, overriding the existing .env variables or loading a file with global functions.

-f|--filter <filter>
-f, --filter <filter>
Filters the tests to run based on the test name.

-l|--log-junit <out.xml>
-l, --log-junit <out.xml>
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
Disable the --parallel option. Util to disable parallel tests from within another test.

-r|--report-html <out.html>
-r, --report-html <out.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
-S, --stop-on-failure
Force to stop the runner right after encountering one failing test.

--debug <?file-path>
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.

--upgrade
Upgrade to latest version of bashunit.

--help
-h, --help
This message.

See more: https://bashunit.typeddevs.com/command-line
Loading

0 comments on commit c36515a

Please sign in to comment.