From 075e6c07651e3e9b268d8d6fc8c1767306cf05ca Mon Sep 17 00:00:00 2001 From: Chemaclass Date: Fri, 12 Jul 2024 23:10:39 +0200 Subject: [PATCH 1/3] feat: generate checksum on build.sh for macOS --- build.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 022c324b..e345293d 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,8 @@ #!/bin/bash -mkdir -p bin +source src/check_os.sh +mkdir -p bin output_file="bin/bashunit" echo '#!/usr/bin/env bash' > bin/temp.sh @@ -13,4 +14,10 @@ grep -v '^source' bin/temp.sh > "$output_file" rm bin/temp.sh chmod u+x "$output_file" +if [[ "$_OS" == "OSX" ]]; then + checksum=$(shasum -a 256 $output_file) + echo "$checksum" > bin/checksum + echo "$checksum" +fi + echo "⚡️Build completed⚡️" From f065672076dea19ad9ff458dd7c233c548a29a27 Mon Sep 17 00:00:00 2001 From: Chemaclass Date: Fri, 12 Jul 2024 23:17:57 +0200 Subject: [PATCH 2/3] feat: generate_checksum with Linux And refactor build.sh: extract code to functions --- build.sh | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/build.sh b/build.sh index e345293d..7400aa49 100755 --- a/build.sh +++ b/build.sh @@ -2,22 +2,42 @@ source src/check_os.sh -mkdir -p bin -output_file="bin/bashunit" +function generate_bin() { + local output_file=$1 + echo '#!/usr/bin/env bash' > bin/temp.sh -echo '#!/usr/bin/env bash' > bin/temp.sh + echo "Generating bashunit in the 'bin' folder..." + cat src/*.sh >> bin/temp.sh + cat bashunit >> bin/temp.sh + grep -v '^source' bin/temp.sh > "$output_file" + rm bin/temp.sh + chmod u+x "$output_file" +} -echo "Generating bashunit in the 'bin' folder..." -cat src/*.sh >> bin/temp.sh -cat bashunit >> bin/temp.sh -grep -v '^source' bin/temp.sh > "$output_file" -rm bin/temp.sh -chmod u+x "$output_file" +function generate_checksum() { + if [[ "$_OS" == "Windows" ]]; then + return + fi + + local file=$1 + if [[ "$_OS" == "OSX" ]]; then + checksum=$(shasum -a 256 "$file") + elif [[ "$_OS" == "Linux" ]]; then + checksum=$(sha256sum "$file") + fi -if [[ "$_OS" == "OSX" ]]; then - checksum=$(shasum -a 256 $output_file) echo "$checksum" > bin/checksum echo "$checksum" -fi +} + +######################## +######### MAIN ######### +######################## + +mkdir -p bin +output_file="bin/bashunit" + +generate_bin "$output_file" +generate_checksum "$output_file" echo "⚡️Build completed⚡️" From 1f87959ad56d33a7f1db41c4fcc59607cc312a36 Mon Sep 17 00:00:00 2001 From: Chemaclass Date: Fri, 12 Jul 2024 23:21:50 +0200 Subject: [PATCH 3/3] docs: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9014ba7b..2bc4f520 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Fix echo does not break test execution results - Add bashunit facade to enable custom assertions - Document how to verify the `sha256sum` of the final executable +- Generate checksum on build - Enable display execution time on macOS with `SHOW_EXECUTION_TIME` - Support for displaying the clock without `perl` (for non-macOS) - Add `-l|--log-junit ` option