wgctl/core/test/test.sh

46 lines
No EOL
977 B
Bash
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# ============================================
# Test Framework
# ============================================
TEST_PASS=0
TEST_FAIL=0
TEST_WARN=0
function test::pass() {
local desc="$1"
printf " \033[1;32m✅\033[0m %s\n" "$desc"
(( TEST_PASS++ )) || true
}
function test::fail() {
local desc="$1"
printf " \033[1;31m❌\033[0m %s\n" "$desc"
(( TEST_FAIL++ )) || true
}
function test::warn() {
local desc="$1"
printf " \033[1;33m⚠ \033[0m %s\n" "$desc"
(( TEST_WARN++ )) || true
}
function test::section() {
printf "\n \033[1;37m%s\033[0m\n" "$1"
printf " %s\n" "$(printf '─%.0s' {1..50})"
}
function test::reset() {
TEST_PASS=0
TEST_FAIL=0
TEST_WARN=0
}
function test::summary() {
printf "\n"
printf " \033[1;32m✅ %s passed\033[0m " "$TEST_PASS"
printf "\033[1;31m❌ %s failed\033[0m " "$TEST_FAIL"
printf "\033[1;33m⚠ %s warnings\033[0m\n\n" "$TEST_WARN"
[[ "$TEST_FAIL" -eq 0 ]]
}