summaryrefslogtreecommitdiff
path: root/nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/stick20_commands.h
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2019-01-05 21:41:22 -0800
committerDaniel Mueller <deso@posteo.net>2019-01-05 21:41:22 -0800
commit6d07a0c9d9a9b39247a9727dea2d90eba4e1fe9e (patch)
tree843fb189a543e6bc95ff9e5498f5ca2d09bc67a0 /nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/stick20_commands.h
parentb750c4b13272908a51b85072008554c344b25016 (diff)
downloadnitrocli-6d07a0c9d9a9b39247a9727dea2d90eba4e1fe9e.tar.gz
nitrocli-6d07a0c9d9a9b39247a9727dea2d90eba4e1fe9e.tar.bz2
Supply customizable stdio channels to argparse
In order to properly test the program we need to have a way to intercept data printed to the stdio channels. There are different ways to accomplish that task. While it is reasonably easy to just start the program as a dedicated process doing so properly may be problematic from inside a test because either the path to the binary has to be retrieved or cargo -- the entity which knows the path -- be invoked. None of these approaches is very appealing from a testing and code complexity point of view: an additional fork means additional sources of errors and flakiness, executing cargo has the potential to even cause rebuilds of parts of the program, and while we are already testing against a slow I/O device this additional code running is unlikely to go unnoticed in the long-term. Lastly, doing so also means that we leave Rust's type safety behind when dealing with errors that could be nicely match'ed on when the test invocation is just a function call. To avoid all this complexity we instead strive for basically just running the main function. This patch marks a first step towards achieving this goal. It introduces the infrastructure to supply custom Write objects to the argument parsing functionality. Once more we piggy-back on the command execution context and add objects representing stdout and stderr to it. We further ensure that this context is passed to the argument parser invocations.
Diffstat (limited to 'nitrokey-sys/libnitrokey-v3.4.1/libnitrokey/stick20_commands.h')
0 files changed, 0 insertions, 0 deletions