ceremonyclient/client/test/test_utils.sh
Tyler Sturos 9cfbdef12c
Feat/2.1 qclient refactor and node install (#429)
* initial auto-update

* working link, update, and testing docker container and scripts

* refactor packages/folders

* move files to proper folders

* fix typos

Closes #421

* optimize rpm imports

* optimize channel imports

* Refactor split command to allow testing of split operations

Closes #338

* modify split and test for folder changes

* remove alias

* fix docker warning about FROM and AS being in different letter case

Closes #422

* QClient Account Command

* Display transaction details and confirmation prompts for transfer and merge commands

* build qclient docker improvements

* update build args for mpfr.so.6

* update install and node commands

* remove NodeConfig check for qclient node commands

* udpate

* working node commands

* update commands

* move utils and rename package

---------

Co-authored-by: Vasyl Tretiakov <vasyl.tretiakov@gmail.com>
Co-authored-by: littleblackcloud <163544315+littleblackcloud@users.noreply.github.com>
Co-authored-by: 0xOzgur <29779769+0xOzgur@users.noreply.github.com>
Co-authored-by: Cassandra Heart <7929478+CassOnMars@users.noreply.github.com>
2025-04-11 21:43:20 -05:00

49 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# ANSI color codes
GREEN='\033[0;32m'
BLUE='\033[0;34m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Function to run a test command and format its output
run_test_with_format() {
local test_cmd="$1"
local indent=" " # 4 spaces for indentation
echo -e "${BLUE}Running test: $test_cmd${NC}"
echo "----------------------------------------"
# Run the command and capture stdout and stderr separately
local stdout
local stderr
stdout=$(eval "$test_cmd" 2> >(tee /dev/stderr))
exit_code=$?
stderr=$(cat)
# Format and print the stdout with indentation
if [ -n "$stdout" ]; then
echo "$stdout" | while IFS= read -r line; do
echo -e "${GREEN}$indent$line${NC}"
done
fi
# Check for stderr output and exit code
if [ -n "$stderr" ] || [ $exit_code -ne 0 ]; then
echo -e "${RED}${indent}Test failed:${NC}"
if [ -n "$stderr" ]; then
echo "$stderr" | while IFS= read -r line; do
echo -e "${RED}${indent}$line${NC}"
done
fi
if [ $exit_code -ne 0 ]; then
echo -e "${RED}${indent}Exit code: $exit_code${NC}"
fi
echo "----------------------------------------"
return 1
fi
echo -e "${GREEN}${indent}Test completed successfully${NC}"
echo "----------------------------------------"
return 0
}