Skip to content
Closed
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
20 changes: 17 additions & 3 deletions bash_unit
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,22 @@ GREEN="${ESCAPE}[92m"
YELLOW="${ESCAPE}[93m"
BLUE="${ESCAPE}[94m"

FAILED="${ESCAPE}${RED}\u2717"
SUCCESS="${ESCAPE}${GREEN}\u2714"

# Could be TEXT or UNICODE
OUTPUT=${OUTPUT:="TEXT"}

fail() {
local message=$1
local stdout=$2
local stderr=$3

format "$RED" "FAILURE"
if [ ${OUTPUT} == "TEXT" ]; then
format "$RED" "FAILURE"
else
echo -e "$FAILED"
fi
[[ -z $message ]] || printf -- "$message\n"
[[ ! -z $stdout ]] && [ -s $stdout ] && cat $stdout | sed 's:^:out> :' | format $GREEN
[[ ! -z $stderr ]] && [ -s $stderr ] && cat $stderr | sed 's:^:err> :' | format $RED
Expand Down Expand Up @@ -91,7 +101,7 @@ assert_equals() {
local actual=$2
local message=$3
[[ -z $message ]] || message="$message\n"

if [ "$expected" != "$actual" ]
then
fail "$message expected [$expected] but was [$actual]"
Expand Down Expand Up @@ -140,7 +150,11 @@ run_test() {
set -e
local TEST=$1
echo -n "Running $TEST... " | format "$BLUE"
$TEST && format "$GREEN" "SUCCESS"
if [ ${OUTPUT} == "TEXT" ]; then
$TEST && format "$GREEN" "SUCCESS"
else
$TEST && echo -e "$SUCCESS"
fi
}

print_stack() {
Expand Down
26 changes: 26 additions & 0 deletions tests/test_bash_unicode_output.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, you added tests/test_bash_unicode_output.sh just to run (manually) it with bash_unit and check if you can see the bullets.

If that is correct, I suggest you just remove this file and relies on the ones already existing in the getting_started directory.

Regards,


test_can_fail() {
fail "this test failed on purpose"
}

test_is_correct() {
assert true
}

code() {
touch /tmp/the_file
}

test_code_creates_the_file() {
code
assert "test -e /tmp/the_file"
}

code2() {
exit 25
}

test_code_with_code_25() {
assert_status_code 25 code2
}