-
-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathconsole_header.sh
More file actions
119 lines (94 loc) · 3.16 KB
/
console_header.sh
File metadata and controls
119 lines (94 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env bash
function console_header::print_version_with_env() {
local filter=${1:-}
local category=${2:-}
shift 2
local files=("$@")
if ! env::is_show_header_enabled; then
return
fi
console_header::print_version "$filter" "$category" "${files[@]}"
}
function console_header::print_version() {
local filter=${1:-}
local category=${2:-}
if [[ -n "$filter" ]]; then
shift
fi
local files=("$@")
local total_tests
if [[ ${#files[@]} -eq 0 ]]; then
total_tests=0
else
total_tests=$(helpers::find_total_tests "$filter" "${files[@]}")
fi
if env::is_header_ascii_art_enabled; then
cat <<EOF
_ _ _
| |__ __ _ ___| |__ __ __ ____ (_) |_
| '_ \ / _' / __| '_ \| | | | '_ \| | __|
| |_) | (_| \__ \ | | | |_| | | | | | |_
|_.__/ \__,_|___/_| |_|\___/|_| |_|_|\__|
EOF
if [ "$total_tests" -eq 0 ]; then
printf "%s\n" "$BASHUNIT_VERSION"
else
printf "%s | Tests: ~%s\n" "$BASHUNIT_VERSION" "$total_tests"
fi
return
fi
if [ "$total_tests" -eq 0 ]; then
printf "${_COLOR_BOLD}${_COLOR_PASSED}bashunit${_COLOR_DEFAULT} - %s\n" "$BASHUNIT_VERSION"
else
if [ -n "$category" ]; then
printf "${_COLOR_BOLD}${_COLOR_PASSED}bashunit${_COLOR_DEFAULT} - %s | Tests: ~%s | Category: %s\n"\
"$BASHUNIT_VERSION"\
"$total_tests"\
"$category"
else
printf "${_COLOR_BOLD}${_COLOR_PASSED}bashunit${_COLOR_DEFAULT} - %s | Tests: ~%s\n"\
"$BASHUNIT_VERSION"\
"$total_tests"
fi
fi
}
function console_header::print_help() {
cat <<EOF
bashunit [arguments] [options]
Arguments:
Specifies the directory or file containing the tests to run.
If a directory is specified, it will execute the tests within files ending with test.sh.
If you use wildcards, bashunit will run any tests it finds.
Options:
-a, --assert <function ...args>
Run a core assert function standalone without a test context.
-e, --env, --boot <file-path>
Load a custom file, overriding the existing .env variables or loading a file with global functions.
-f, --filter <filter>
Filters the tests to run based on the test name.
-c, --category <name>
Filters the tests to run based on @category tags.
-l, --log-junit <out.xml>
Create a report JUnit XML file that contains information about the test results.
-p, --parallel || --no-parallel [default]
Run each test in child process, randomizing the tests execution order.
-r, --report-html <out.html>
Create a report HTML file that contains information about the test results.
-s, --simple || --detailed [default]
Enables simple or detailed output to the console.
-S, --stop-on-failure
Force to stop the runner right after encountering one failing test.
--debug <?file-path>
Print all executed shell commands to the terminal.
If a file-path is passed, it will redirect the output to that file.
-vvv, --verbose
Display internal details for each test.
--version
Displays the current version of bashunit.
--upgrade
Upgrade to latest version of bashunit.
-h, --help
This message.
See more: https://bashunit.typeddevs.com/command-line
EOF
}