From 8dd05f05ab5e7b30b18c4904d6bf103927df1d44 Mon Sep 17 00:00:00 2001 From: katarn Date: Thu, 19 Oct 2023 20:12:03 +0200 Subject: [PATCH 1/2] chore: update vitepress version --- package.json | 2 +- yarn.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index abd9741c..d0213084 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "vanilla-tilt": "^1.8.1" }, "devDependencies": { - "vitepress": "^1.0.0-rc.21", + "vitepress": "^1.0.0-rc.22", "vue": "^3.3.4" } } diff --git a/yarn.lock b/yarn.lock index c01e011c..77fd672f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -488,7 +488,7 @@ estree-walker@^2.0.2: resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac" integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w== -focus-trap@^7.5.3: +focus-trap@^7.5.4: version "7.5.4" resolved "https://registry.yarnpkg.com/focus-trap/-/focus-trap-7.5.4.tgz#6c4e342fe1dae6add9c2aa332a6e7a0bbd495ba2" integrity sha512-N7kHdlgsO/v+iD/dMoJKtsSqs5Dz/dXZVebRgJw23LDk+jMi/974zyiOYDziY2JPp8xivq9BmUGwIJMiuSBi7w== @@ -589,10 +589,10 @@ vite@^4.4.11: optionalDependencies: fsevents "~2.3.2" -vitepress@^1.0.0-rc.21: - version "1.0.0-rc.21" - resolved "https://registry.yarnpkg.com/vitepress/-/vitepress-1.0.0-rc.21.tgz#fbe1a63db86a37729c554048e4df3c606ba0d803" - integrity sha512-eHX057NgAqmrj6FIqh7Sqsbk/kftrFMBUpCKjuQIZ+c+bYTbmzXsXrHSbT5b4WWy4vLx1993a+H3wIRy2dHi8g== +vitepress@^1.0.0-rc.22: + version "1.0.0-rc.22" + resolved "https://registry.yarnpkg.com/vitepress/-/vitepress-1.0.0-rc.22.tgz#9855edc0991a57cf88561e790b0b35ddc447fbf0" + integrity sha512-n7le5iikCFgWMuX7sKfzDGJGlrsYQ5trG3S97BghNz2alOTr4Xp+GrB6ShwogUTX9gNgeNmrACjokhW55LNeBA== dependencies: "@docsearch/css" "^3.5.2" "@docsearch/js" "^3.5.2" @@ -600,7 +600,7 @@ vitepress@^1.0.0-rc.21: "@vue/devtools-api" "^6.5.1" "@vueuse/core" "^10.5.0" "@vueuse/integrations" "^10.5.0" - focus-trap "^7.5.3" + focus-trap "^7.5.4" mark.js "8.11.1" minisearch "^6.1.0" shiki "^0.14.5" From 8ee4ea5da8a98a25fe8f87f7fa98ecf2233a8623 Mon Sep 17 00:00:00 2001 From: katarn Date: Thu, 19 Oct 2023 20:22:18 +0200 Subject: [PATCH 2/2] feat: add SHOW_EXECUTION_TIME to environment config --- .env.example | 1 + CHANGELOG.md | 1 + src/console_results.sh | 4 ++++ src/default_env_config.sh | 1 + src/env_configuration.sh | 4 ++++ tests/unit/console_results_test.sh | 25 ++++++++++++++++++++++++- 6 files changed, 35 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index b3351d9f..0a5bfce3 100644 --- a/.env.example +++ b/.env.example @@ -2,3 +2,4 @@ SHOW_HEADER= HEADER_ASCII_ART= SIMPLE_OUTPUT= STOP_ON_FAILURE= +SHOW_EXECUTION_TIME= diff --git a/CHANGELOG.md b/CHANGELOG.md index dff42676..4f31d636 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Installer no longer needs git - Add `assert_contains_ignore_case` - Add `assert_equals_ignore_colors` +- Add `SHOW_EXECUTION_TIME` to environment config ## [0.9.0](https://github.com/TypedDevs/bashunit/compare/0.8.0...0.9.0) - 2023-10-15 diff --git a/src/console_results.sh b/src/console_results.sh index 25403006..3038c610 100644 --- a/src/console_results.sh +++ b/src/console_results.sh @@ -77,6 +77,10 @@ function console_results::render_result() { } function console_results::print_execution_time() { + if [[ $SHOW_EXECUTION_TIME == false ]]; then + return + fi + if [[ "$_OS" != "OSX" ]]; then _EXECUTION_TIME=$((($(date +%s%N) - "$_START_TIME") / 1000000)) printf "${_COLOR_BOLD}%s${_COLOR_DEFAULT}\n" "Time taken: ${_EXECUTION_TIME} ms" diff --git a/src/default_env_config.sh b/src/default_env_config.sh index 45dd4a31..01b1b0e3 100644 --- a/src/default_env_config.sh +++ b/src/default_env_config.sh @@ -6,4 +6,5 @@ _DEFAULT_SHOW_HEADER=true _DEFAULT_HEADER_ASCII_ART=false _DEFAULT_SIMPLE_OUTPUT=false _DEFAULT_STOP_ON_FAILURE=false +_DEFAULT_SHOW_EXECUTION_TIME=true CAT="$(which cat)" diff --git a/src/env_configuration.sh b/src/env_configuration.sh index 5a119650..d28626da 100644 --- a/src/env_configuration.sh +++ b/src/env_configuration.sh @@ -24,3 +24,7 @@ fi if [[ -z "$STOP_ON_FAILURE" ]]; then STOP_ON_FAILURE=$_DEFAULT_STOP_ON_FAILURE fi + +if [[ -z "$SHOW_EXECUTION_TIME" ]]; then + SHOW_EXECUTION_TIME=$_DEFAULT_SHOW_EXECUTION_TIME +fi diff --git a/tests/unit/console_results_test.sh b/tests/unit/console_results_test.sh index 33b94c6f..e3987a9e 100644 --- a/tests/unit/console_results_test.sh +++ b/tests/unit/console_results_test.sh @@ -223,7 +223,30 @@ function test_render_execution_time() { return fi - assert_matches "Time taken: [[:digit:]]+ ms" "$(console_results::render_result)" + local render_result + render_result=$( + # shellcheck disable=SC2034 + SHOW_EXECUTION_TIME=true + + console_results::render_result + ) + assert_matches "Time taken: [[:digit:]]+ ms" "$render_result" +} + +function test_not_render_execution_time() { + if [[ $_OS == "OSX" ]]; then + skip "Skipping in OSX" + return + fi + + local render_result + render_result=$( + # shellcheck disable=SC2034 + SHOW_EXECUTION_TIME=false + + console_results::render_result + ) + assert_not_matches "Time taken" "$render_result" } function test_not_render_execution_time_on_osx() {