[plt-scheme] Command Line Processing

From: Noel Welsh (noelwelsh at gmail.com)
Date: Mon Jun 22 08:38:17 EDT 2009

On Mon, Jun 22, 2009 at 1:27 PM, Matthew Flatt<mflatt at cs.utah.edu> wrote:
> At Fri, 19 Jun 2009 09:53:57 -0600, Doug Williams wrote:
>> What is the best way to test programs using command-line during development?
...
> More often, my programs are either
>
>  * mostly in a library, and the executable is a thin wrapper to parse
>   command-line flags, so I mostly experiment (or really test) by using
>   the library directly; or

I would use this style.

Then, I would either:

1. Bundle up the library's API into a unit, and parameterise the
command line wrapper by a unit with the appropriate sig. Then write an
implementation of the sig that would be used just for testing. E.g. if
when I invoked at the command line

  my-program -foo foo -bar bar

I expected my library to be called as

  (foo 'foo #:bar 'bar)

I would write, within my "mock" unit a test like

 (define (foo x #:bar y)
    (check-eq? x 'foo)
    (check-eq? y 'bar))

The idea here is that I just want to test the command line parsing;
other tests will have ascertained if the library functionality
actually works.

2. Write a bunch of scripts that invoke the command line app and check
the output is as expected. This is the lazy option.

N.


Posted on the users mailing list.