OCaml Integration tests for all commands but pkg, update TODO.md and root README

This commit is contained in:
Juno Takano 2025-04-13 16:40:44 -03:00
commit a45420dd1e
3 changed files with 95 additions and 19 deletions

View file

@ -18,11 +18,11 @@ As a program that can brick your system if something goes wrong, it's really imp
Each language will be used to implement a simple command-line interface that fulfills the specification below. "Simple" means the goal is not to cover corner cases, but to prototype and make a decision based on language syntax, ergonomics, expressiveness, documentation, ecosystem, tooling and overall experience.
Iganaq Napkin Spec
Iganaq Napkin Spec v0
A1. 'print' refers to messages for users. They MUST always be printed.
A2. 'log' refers to messages for programmers. They MUST be printed only if
DEBUG is set in the environment and MUST be preceded by ' [log] '.
A2. 'log' refers to messages for programmers. They MUST be printed only
if DEBUG is set in the environment and MUST be preceded by ' [log] '.
A3.1. Before parsing the user arguments, a configuration file at
$XDG_CONFIG_DIR/tori/tori.conf MUST be read for a line such as:

View file

@ -1,18 +1,34 @@
- [ ] Match test coverage with spec requirements
- [ ] Add log function
- [ ] Output begins with ' [log] '
- [ ] Only prints if DEBUG is set
- [ ] Get su command from $XDG_CONFIG_HOME/tori/tori.conf and use it for pkg
- [ ] Default to 'su -c'
- [ ] Valid path or in $PATH, executability, 'true' exits with status 0
- [ ] Unrecognized command: exit code 1
- [ ] Package.merge should print each command executed, not just package names
- [ ] Spec requirements integration test coverage
- [ ] Add log function
- [ ] Output begins with ' [log] '
- [ ] Only prints if DEBUG is set
- [ ] Add interactive pkg tests (INS v0 B2.5)
- [ ] Get su command from $XDG_CONFIG_HOME/tori/tori.conf
- [ ] Default to 'su -c'
- [ ] Validation
- [ ] Valid path or in $PATH
- [ ] Executability
- [ ] 'true' exits with status 0
- [ ] Add logging
- [ ] Print each command executed, not just package names
- [ ] Case with no packages provided
- [ ] Prints a message
- [ ] MUST NOT run any system commands
- [x] Unrecognized command: exit code 1
- [x] Command 'user': print the output of 'whoami'
- [ ] Simplify Reader
- [ ] Create interface files
- [ ] Move comment on top of Parsers.Argument.say to the interface doc file
- [ ] Try out doc generation
- [ ] Simplify and analyze System.File
- [ ] Refactorings
- [ ] Simplify and analyze System.File
- [ ] Simplify Reader
- [x] Command 'user': print the output of 'whoami'
- [x] Command 'host': drop
- [ ] Additionals
- [ ] Create interface files
- [ ] Expand unit tests coverage
- [ ] Try out doc generation
## Notes
- INS = Iganaq Napkin Spec: <https://brew.bsd.cafe/tori/iganaq#specification>
- Spec v0 requirement B2.5 "MUST NOT run any system commands" is only testable
if we wrap command execution properly in e.g. a list containing all executed
commands and ensure no command is ever executed without being appended to it

60
ocaml/test/cram.t Normal file
View file

@ -0,0 +1,60 @@
This file tests this tori implementation against the Iganaq Napkin Spec v0
B2.1. version | -v | --version -> MUST print the version as in v0.8.0
$ tori version
v0.8.0
$ tori -v
v0.8.0
$ tori --version
v0.8.0
B2.2. help | -h | --help -> MUST print '<long help>'
$ tori help
<long help>
$ tori -h
<long help>
$ tori --help
<long help>
B2.3. os -> MUST print the contents of /etc/os-release
$ os_release=$(cat /etc/os-release)
$ tori_os=$(tori os)
$ test -n "$os_release"
$ test -n "$tori_os"
$ test "$os_release" = "$tori_os"
B2.4. user -> MUST print the output of the 'whoami' command
$ whoami=$(whoami)
$ tori_user=$(tori user)
$ test -n "$whoami"
$ test -n "$tori_user"
$ test "$whoami" = "$tori_user"
B2.6. echo x y z -> MUST print x y z
$ tori echo x y z
x y z
B2.7. echo -> MUST NOT print any output and exit with status code 0
$ tori echo
B2.8. [no input] -> MUST NOT print any output and exit with status code 0
$ tori
B2.9. [any other input] -> MUST print 'Unrecognized command: [command]',
a newline, '<short help>' and exit with status code 1
$ tori unrecognized_command
Unrecognized command: unrecognized_command
<short help>
[1]