diff --git a/README.md b/README.md index d4cde54..de9fdf9 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/ocaml/TODO.md b/ocaml/TODO.md index 7538941..ec8a483 100644 --- a/ocaml/TODO.md +++ b/ocaml/TODO.md @@ -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: +- 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 diff --git a/ocaml/test/cram.t b/ocaml/test/cram.t new file mode 100644 index 0000000..c8af3d2 --- /dev/null +++ b/ocaml/test/cram.t @@ -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 '' + + $ tori help + + + $ tori -h + + + $ tori --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, '' and exit with status code 1 + + $ tori unrecognized_command + Unrecognized command: unrecognized_command + + [1]