Skip to content

Commit 7c70e3f

Browse files
committed
feat: add logs on dev_mode
1 parent 0f452a8 commit 7c70e3f

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

bashunit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ declare -r BASHUNIT_ROOT_DIR="$(dirname "${BASH_SOURCE[0]}")"
99
export BASHUNIT_ROOT_DIR
1010

1111
source "$BASHUNIT_ROOT_DIR/src/dev/debug.sh"
12+
source "$BASHUNIT_ROOT_DIR/src/check_os.sh"
1213
source "$BASHUNIT_ROOT_DIR/src/str.sh"
1314
source "$BASHUNIT_ROOT_DIR/src/globals.sh"
1415
source "$BASHUNIT_ROOT_DIR/src/dependencies.sh"
1516
source "$BASHUNIT_ROOT_DIR/src/io.sh"
1617
source "$BASHUNIT_ROOT_DIR/src/math.sh"
1718
source "$BASHUNIT_ROOT_DIR/src/parallel.sh"
1819
source "$BASHUNIT_ROOT_DIR/src/env.sh"
19-
source "$BASHUNIT_ROOT_DIR/src/check_os.sh"
2020
source "$BASHUNIT_ROOT_DIR/src/clock.sh"
2121
source "$BASHUNIT_ROOT_DIR/src/state.sh"
2222
source "$BASHUNIT_ROOT_DIR/src/colors.sh"

src/env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function env::find_terminal_width() {
7979
echo "${cols:-$_DEFAULT_TERMINAL_WIDTH}"
8080
}
8181

82-
TEMP_DIR_PARALLEL_TEST_SUITE="/tmp/bashunit/parallel"
82+
TEMP_DIR_PARALLEL_TEST_SUITE="/tmp/bashunit/parallel/${_OS:-Unknown}"
8383
TERMINAL_WIDTH="$(env::find_terminal_width)"
8484
FAILURES_OUTPUT_PATH=$(mktemp)
8585
CAT="$(which cat)"

src/runner.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ function runner::run_test() {
158158
# Closes FD 3, which was used temporarily to hold the original stdout.
159159
exec 3>&-
160160

161-
runner::parse_result "$function_name" "$test_execution_result" "$@"
162-
163161
local subshell_output=$(\
164162
echo "$test_execution_result" |\
165163
tail -n 1 |\
@@ -192,6 +190,8 @@ function runner::run_test() {
192190
fi
193191
done
194192

193+
runner::parse_result "$function_name" "$test_execution_result" "$@"
194+
195195
local total_assertions="$(state::calculate_total_assertions "$test_execution_result")"
196196

197197
local end_time=$(clock::now)
@@ -282,6 +282,15 @@ function runner::parse_result_parallel() {
282282
count=$((count + 1))
283283
done
284284

285+
if env::is_dev_mode_enabled; then
286+
local test_id=$(\
287+
echo "$execution_result" |\
288+
tail -n 1 |\
289+
sed -E -e 's/.*##TEST_ID=([0-9]*)##.*/\1/g'\
290+
)
291+
log "debug" "[PARA] test_id:$test_id" "function_name:$function_name" "execution_result:$execution_result"
292+
fi
293+
285294
echo "$execution_result" > "$unique_test_result_file"
286295
}
287296

@@ -326,7 +335,7 @@ function runner::parse_result_sync() {
326335
tail -n 1 |\
327336
sed -E -e 's/.*##TEST_ID=([0-9]*)##.*/\1/g'\
328337
)
329-
log "$test_id" "$function_name" "$execution_result"
338+
log "debug" "[SYNC] test_id:$test_id" "function_name:$function_name" "execution_result:$execution_result"
330339
fi
331340

332341
((_ASSERTIONS_PASSED += assertions_passed)) || true

src/state.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ function state::export_subshell_context() {
148148
encoded_test_output=$(echo -n "$_TEST_OUTPUT" | base64)
149149
fi
150150

151-
echo "##TEST_ID=$(random_str)\
151+
echo "##TEST_ID=$(random_str 8)\
152152
##ASSERTIONS_FAILED=$_ASSERTIONS_FAILED\
153153
##ASSERTIONS_PASSED=$_ASSERTIONS_PASSED\
154154
##ASSERTIONS_SKIPPED=$_ASSERTIONS_SKIPPED\

0 commit comments

Comments
 (0)