OCaml: Add debug logging tests

This commit is contained in:
Juno Takano 2025-04-21 21:30:59 -03:00
commit f3557d5bb4
5 changed files with 39 additions and 7 deletions

View file

@ -1,5 +1,13 @@
This file tests this tori implementation against the Iganaq Napkin Spec v0
A2. 'log' MUST print only if DEBUG is set and MUST be preceded by ' [log] '
$ without_debug=$(tori os 2>&1)
$ with_debug=$(DEBUG=1 tori os 2>&1)
$ test "$without_debug" != "$with_debug"
$ echo "$with_debug" | grep -Fq " [log] "
$ echo "$without_debug" | grep -Fqv " [log] "
B2.1. version | -v | --version -> MUST print the version as in v0.8.0
$ tori version
@ -22,13 +30,19 @@ B2.2. help | -h | --help -> MUST print '<long help>'
$ tori --help
<long help>
B2.3. os -> MUST print the contents of /etc/os-release
B2.3. os -> MUST print the os name
$ os_release=$(cat /etc/os-release)
$ os_name=$(cat /etc/os-release | grep '^NAME=' | cut -d = -f 2 | sed 's/"//g')
$ tori_os=$(tori os)
$ test -n "$os_release"
$ test -n "$os_name"
$ test -n "$tori_os"
$ test "$os_release" = "$tori_os"
$ test "$os_name" = "$tori_os"
B2.3. os -> MUST log the contents of /etc/os-release
$ tori_os=$(DEBUG=1 tori os 2>&1)
$ test -n "$tori_os"
$ echo "$tori_os" | grep -qFf /etc/os-release
B2.4. user -> MUST print the output of the 'whoami' command
@ -58,3 +72,4 @@ a newline, '<short help>' and exit with status code 1
Unrecognized command: unrecognized_command
<short help>
[1]