OCaml: Add tests for su_command default fallback

This commit is contained in:
Juno Takano 2025-05-17 00:54:29 -03:00
commit caafbed5a5
2 changed files with 14 additions and 3 deletions

View file

@ -23,7 +23,7 @@ In this grammar, `digit` implies `decimal digit`. Spaces between the key and the
## Task list
- [ ] Spec requirements
- [x] Spec requirements
- [x] Add log function
- [x] Output begins with ` [log] `
- [x] Only prints if `DEBUG` is set
@ -34,7 +34,7 @@ In this grammar, `digit` implies `decimal digit`. Spaces between the key and the
- [x] Properly handle a compose `su_command` such as `su -c` in `System.Package`
- [x] Properly handle dependent options
- [x] Implement log levels
- [ ] Write tests
- [x] Write tests
- [x] Validation
- [x] Valid path or in `PATH`
- [x] Executability

View file

@ -8,6 +8,17 @@ A2. 'log' MUST print only if DEBUG is set and MUST be preceded by ' [log] '
$ echo "$with_debug" | grep -Fq " [log] "
$ echo "$without_debug" | grep -Fqv " [log] "
A3.2. if su_command is unset, the default must be 'su -c'
$ echo 'simulate=true' > $HOME/.config/tori/tori.conf
$ DEBUG=1 tori pkg xterm 2>&1 | grep -Fq 'su -c'
A3.3. if su_command is set, su_command must be the set value
$ echo 'simulate=true' > $HOME/.config/tori/tori.conf
$ echo 'su_command=doas' >> $HOME/.config/tori/tori.conf
$ DEBUG=1 tori pkg xterm 2>&1 | grep -Fq 'doas'
A3.4. [config] su_command must be validated for presence at the provided path
or a path obtained from $PATH and filesystem permission to execute
@ -40,7 +51,7 @@ B2.2. help | -h | --help -> MUST print '<long help>'
B2.3. os -> MUST print the os name
$ os_name=$(cat /etc/os-release | grep '^NAME=' | cut -d = -f 2 | sed 's/"//g')
$ os_name=$(cat /etc/os-release | grep '^NAME=' | cut -d= -f 2 | sed 's/"//g')
$ tori_os=$(tori os)
$ test -n "$os_name"
$ test -n "$tori_os"