Compare commits
4 commits
Author | SHA1 | Date | |
---|---|---|---|
|
92bf7da15a | ||
|
5fb3ab6ee3 | ||
|
3b57104997 | ||
|
fbc029b1b1 |
5 changed files with 52 additions and 1 deletions
|
@ -20,3 +20,4 @@ script:
|
|||
# Check for lines longer than 100 chars.
|
||||
# There are 3 lines that must be longer than 100 chars.
|
||||
- if (("$(grep '.\{101\}' neofetch | wc -l)" > 3)); then (exit 1); else (exit 0); fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cd tests && ./test.sh; fi
|
||||
|
|
2
neofetch
2
neofetch
|
@ -8724,4 +8724,4 @@ main() {
|
|||
return 0
|
||||
}
|
||||
|
||||
main "$@"
|
||||
[[ "$0" == "${BASH_SOURCE[0]}" ]] && main "$@"
|
||||
|
|
7
tests/test.sh
Executable file
7
tests/test.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Run all tests.
|
||||
|
||||
./test_misc.sh
|
||||
|
||||
[[ -f /tmp/err ]] || exit 0 && { rm /tmp/err; exit 1; }
|
32
tests/test_misc.sh
Executable file
32
tests/test_misc.sh
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Test misc functions.
|
||||
|
||||
source test_util.sh
|
||||
source ../neofetch
|
||||
|
||||
# Tests only work on Linux for now.
|
||||
os="Linux"
|
||||
|
||||
|
||||
test_convert_time() {
|
||||
# 24 hour time.
|
||||
result="$(convert_time "2016" "04" "14" "23:50")"
|
||||
assert_equals "$result" "Thu 14 Apr 2016 23:50"
|
||||
|
||||
# 12 hour time.
|
||||
install_time_format="12h"
|
||||
result="$(convert_time "2016" "04" "14" "23:50")"
|
||||
assert_equals "$result" "Thu 14 Apr 2016 11:50 PM"
|
||||
}
|
||||
|
||||
test_get_ppid() {
|
||||
result="$(trim "$(get_ppid "1")")"
|
||||
assert_equals "$result" "0"
|
||||
}
|
||||
|
||||
|
||||
printf "%s\\n" "Test MISC functions."
|
||||
|
||||
test_convert_time
|
||||
test_get_ppid
|
11
tests/test_util.sh
Executable file
11
tests/test_util.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Test util functions.
|
||||
|
||||
assert_equals() {
|
||||
# Test equality.
|
||||
local status
|
||||
[[ "$1" == "$2" ]] && status="✔"
|
||||
printf "%s\\n" " ${status:-✖} : ${FUNCNAME[1]}"
|
||||
[[ "$1" == "$2" ]] || { :>/tmp/err; return 1; } && return 0
|
||||
}
|
Loading…
Reference in a new issue