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 ## Task list
- [ ] Spec requirements - [x] Spec requirements
- [x] Add log function - [x] Add log function
- [x] Output begins with ` [log] ` - [x] Output begins with ` [log] `
- [x] Only prints if `DEBUG` is set - [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 a compose `su_command` such as `su -c` in `System.Package`
- [x] Properly handle dependent options - [x] Properly handle dependent options
- [x] Implement log levels - [x] Implement log levels
- [ ] Write tests - [x] Write tests
- [x] Validation - [x] Validation
- [x] Valid path or in `PATH` - [x] Valid path or in `PATH`
- [x] Executability - [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 "$with_debug" | grep -Fq " [log] "
$ echo "$without_debug" | grep -Fqv " [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 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 or a path obtained from $PATH and filesystem permission to execute