|
From: Fintan F. <fi...@gm...> - 2009-04-07 10:54:31
|
I created a small dsl for creating unit tests for clops.
The idea being that we can write sample inputs for a given clops spec file,
indicating whether they should be deemed valid or not. These are turned into
unit tests against the generated parser.
I have created an ant target unit-tests that currently does the following:
-Reads the dsl file (test/tests)
-Generates the code for all the mentioned clops spec files
-Generates a unit test for every provided valid/invalid input
-Runs the unit tests
Here's an example of the format of the dsl:
file: dsl/svn.clo
name: SVN
valid: { update }
invalid: { sadfadsd }
valid: { diff -r 3456 }
...
file: dsl/gzip.clo
name: Gzip
...
Each valid/invalid line results in a unit test. You can see the few actual
tests I've written so far in "test/tests" in the repository.
One special feature of the input string is the ability to provide
existing/non-existing files or directories. For this the tokens
${existing-file}, ${existing-dir} and ${non-existant-file} will be
substituted with appropriate paths to ensure file existence checks etc run
correctly.
The process can be streamlined and improved to facilitate the testing of
individual clops specifications more efficiently. I could see this method of
unit testing as being very useful when trying to specify tools with existing
complex command line interfaces.
Feedback and suggestions welcome. I'd encourage those who are responsible
for any of our existing .clo(ps) files to start to write some tests in the
file "test/tests", as this will be useful for regression testing and testing
future changes like the infinite lookahead parser that Radu has been working
on.
-F
|