Ultima attività 1 month ago

nuno ha revisionato questo gist 1 month ago. Vai alla revisione

1 file changed, 46 insertions

test.sh(file creato)

@@ -0,0 +1,46 @@
1 + #!/usr/bin/env bash
2 +
3 + # ============================================
4 + # Test Framework
5 + # ============================================
6 +
7 + TEST_PASS=0
8 + TEST_FAIL=0
9 + TEST_WARN=0
10 +
11 + function test::pass() {
12 + local desc="$1"
13 + printf " \033[1;32m✅\033[0m %s\n" "$desc"
14 + (( TEST_PASS++ )) || true
15 + }
16 +
17 + function test::fail() {
18 + local desc="$1"
19 + printf " \033[1;31m❌\033[0m %s\n" "$desc"
20 + (( TEST_FAIL++ )) || true
21 + }
22 +
23 + function test::warn() {
24 + local desc="$1"
25 + printf " \033[1;33m⚠️ \033[0m %s\n" "$desc"
26 + (( TEST_WARN++ )) || true
27 + }
28 +
29 + function test::section() {
30 + printf "\n \033[1;37m%s\033[0m\n" "$1"
31 + printf " %s\n" "$(printf '─%.0s' {1..50})"
32 + }
33 +
34 + function test::reset() {
35 + TEST_PASS=0
36 + TEST_FAIL=0
37 + TEST_WARN=0
38 + }
39 +
40 + function test::summary() {
41 + printf "\n"
42 + printf " \033[1;32m✅ %s passed\033[0m " "$TEST_PASS"
43 + printf "\033[1;31m❌ %s failed\033[0m " "$TEST_FAIL"
44 + printf "\033[1;33m⚠️ %s warnings\033[0m\n\n" "$TEST_WARN"
45 + [[ "$TEST_FAIL" -eq 0 ]]
46 + }
Più nuovi Più vecchi