Skip to content

Commit

Permalink
Add an external tool tester
Browse files Browse the repository at this point in the history
This will collect example outputs of externals tools that Liquidprompt
uses, so that we can build integration tests for these tools.

This does not include VCS providers, since without a repository, most of
the commands will simply error out. Deeper integration tests will need
to be written for VCS providers. And while most of these tools here are
packaged with an OS and therefore are OS version dependent, VCS
providers are often updated to the latest version regardless of OS.
  • Loading branch information
Rycieos committed Dec 17, 2020
1 parent 298693e commit b699dea
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions tools/external-tool-tester.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/sh

# Do NOT error on failed commands
set +e

test_tool() {
local stderr
printf '\nCommand: "%s"\n--------stdout--------\n' "$*"
{ stderr="$( { "$@"; } 2>&1 1>&3 3>&- )"; } 3>&1
printf '\n--------stderr--------\n%s\n----------------------\nReturn code: "%s"\n' "$stderr" "$?"
}

# Export needed variables
export LC_ALL=C

# Print uname
printf 'Uname:\n'
uname -a

test_tool uname

hostname_cksum() {
hostname | cksum
}
test_tool hostname_cksum

test_tool tput sgr0
test_tool tput me
test_tool tput bold
test_tool tput md
test_tool tput smul
test_tool tput us
test_tool tput colors
test_tool tput setaf 0
test_tool tput AF 0
test_tool tput AF 0 0 0
test_tool tput setab 0
test_tool tput AB 0
test_tool tput AB 0 0 0

test_tool who am i
test_tool ps -o comm= -p "$PPID"
test_tool logname

test_tool screen -ls
test_tool tmux list-sessions

test_tool acpi --battery
test_tool pmset -g batt

test_tool nproc
# Not actually a command used, we read directly from the file
test_tool cat /proc/loadavg
test_tool sysctl -n hw.ncpu
test_tool sysctl -n vm.loadavg
test_tool kstat -m cpu_info
test_tool uptime

test_tool sensors -u
test_tool acpi -t

test_tool date '+%I %M'
test_tool tty
test_tool basename -- /dev/pts/0

0 comments on commit b699dea

Please sign in to comment.