Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tr warning on ubuntu's CI #373

Merged
merged 3 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/globals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ function is_command_available() {

function random_str() {
local length=${1:-6}
LC_ALL=C tr -dc A-Za-z0-9 </dev/urandom | head -c "$length"
local chars='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
local str=''
for (( i=0; i<length; i++ )); do
str+="${chars:RANDOM%${#chars}:1}"
done
echo "$str"
}

function temp_file() {
Expand Down
20 changes: 3 additions & 17 deletions src/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function runner::run_test() {
subshell_output=$line
fi

local runtime_output="${test_execution_result%%##TEST_ID=*}"
local runtime_output="${test_execution_result%%##ASSERTIONS_=*}"

local runtime_error=""
for error in "command not found" "unbound variable" "permission denied" \
Expand Down Expand Up @@ -281,14 +281,7 @@ function runner::parse_result_parallel() {
count=$((count + 1))
done

if env::is_dev_mode_enabled; then
local test_id=$(\
echo "$execution_result" |\
tail -n 1 |\
sed -E -e 's/.*##TEST_ID=([a-zA-Z0-9]*)##.*/\1/g'\
)
log "debug" "[PARA] test_id:$test_id" "function_name:$function_name" "execution_result:$execution_result"
fi
log "debug" "[PARA]" "function_name:$function_name" "execution_result:$execution_result"

runner::parse_result_sync "$function_name" "$execution_result"

Expand Down Expand Up @@ -329,14 +322,7 @@ function runner::parse_result_sync() {
sed -E -e 's/.*##ASSERTIONS_SNAPSHOT=([0-9]*)##.*/\1/g'\
)

if env::is_dev_mode_enabled; then
local test_id=$(\
echo "$execution_result" |\
tail -n 1 |\
sed -E -e 's/.*##TEST_ID=([a-zA-Z0-9]*)##.*/\1/g'\
)
log "debug" "[SYNC] test_id:$test_id" "function_name:$function_name" "execution_result:$execution_result"
fi
log "debug" "[SYNC]" "function_name:$function_name" "execution_result:$execution_result"

((_ASSERTIONS_PASSED += assertions_passed)) || true
((_ASSERTIONS_FAILED += assertions_failed)) || true
Expand Down
4 changes: 0 additions & 4 deletions src/state.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,7 @@ function state::export_subshell_context() {
encoded_test_output=$(echo -n "$_TEST_OUTPUT" | base64)
fi

local test_id
test_id=$(LC_ALL=C tr -dc A-Za-z0-9 </dev/urandom | head -c 8)

cat <<EOF
##TEST_ID=$test_id\
##ASSERTIONS_FAILED=$_ASSERTIONS_FAILED\
##ASSERTIONS_PASSED=$_ASSERTIONS_PASSED\
##ASSERTIONS_SKIPPED=$_ASSERTIONS_SKIPPED\
Expand Down
9 changes: 3 additions & 6 deletions tests/unit/state_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ function test_initialize_assertions_count() {
)

assert_same\
"##TEST_ID=abc123\
##ASSERTIONS_FAILED=0\
"##ASSERTIONS_FAILED=0\
##ASSERTIONS_PASSED=0\
##ASSERTIONS_SKIPPED=0\
##ASSERTIONS_INCOMPLETE=0\
Expand All @@ -277,8 +276,7 @@ function test_export_assertions_count() {
)

assert_same\
"##TEST_ID=abc123\
##ASSERTIONS_FAILED=5\
"##ASSERTIONS_FAILED=5\
##ASSERTIONS_PASSED=10\
##ASSERTIONS_SKIPPED=42\
##ASSERTIONS_INCOMPLETE=12\
Expand All @@ -288,8 +286,7 @@ function test_export_assertions_count() {
}

function test_calculate_total_assertions() {
local input="##TEST_ID=abc123\
##ASSERTIONS_FAILED=1\
local input="##ASSERTIONS_FAILED=1\
##ASSERTIONS_PASSED=2\
##ASSERTIONS_SKIPPED=3\
##ASSERTIONS_INCOMPLETE=4\
Expand Down
Loading