This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Idea for testing


Sorry for the delayed reply…

On Jul 16, 2012, at 11:51 AM, Charles Turner wrote:

After the RunTestScript patches the other day, the following occurred to me:
---
After I've written or modified some code, my first testing strategy is
typically to sit down and hit the code will all kinds of
input. I then use the result of these interactions as a start for
writing test cases. What if you had a program that watched the
terminal as you were typing. It would generate RunTestScript-esqe code
automatically for you. I'd like it to work along these lines


(some expression)
; ouput1
(testscript:log) ; the above assume wasn't horrid error output, and
                   ; instead expected behaviour I'd like to test in
		    ; the future, so log it.
(some expression)
; horrid error output
(some other expression) ; must explicity log the previous I/O if you
; want to generate the test

Lots of details to be worked out, but what do think of it as a possibility?


That does sound like it could be a handy tool, and not solely for using
RunTestScript -- you could imagine wanting to take a bunch of interaction
at the REPL and turning it into a script [0]. In that case you wouldn't
necessarily need to save the output, but it could provide some useful
documentation for what the script is doing.


There are two parts to it that I see:
1. Adjusting output to match the expected format of RunTestScript.
2. Recording all input and output to a file.

1. Adjusting the output formatting: at its most basic this would entail
prepending ";; Output: " to each line of stdout and ";; Diagnostic: "
to each line of stderr, right? From that you could copy/paste from the
REPL window to a text editor and you'd be mostly there.


Some Schemes already do something like this: MIT Scheme, for instance,
writes ";Value: 3" if you evaluate "(+ 1 2)". That way, you can just
save your REPL session to a file and everything other than user input
is already a comment. (It helps that MIT Scheme's interaction environment,
Edwin, is a stripped-down Emacs clone which knows how to do file I/ O.)


We could do this perhaps at the level of the pretty printer with some
parameters controlling it, or maybe it would be another --output- format
option.


2. Recording I/O to a file: there are a few ways this could be done, which
probably fall into the general categories of (a) writing to a file as
you go, and (b) dumping everything to a file at the end.


If I'm reading correctly, your example assumed (a), with (testscript:log)
opening the file and logging all subsequent I/O. Maybe have it swap out
the current InPort and OutPorts with ones that tee their data to a file,
or have hooks into Shell.java? Not sure what the best way is.


The other option would be to save the file after the fact like Edwin does.
Perhaps jemacs could help here.


tl;dr: Yup, sounds like an interesting project. For later. :-)

[0] By which I mean these http://www.gnu.org/software/kawa/Scripts.html

--
Jamison Hope
The PTR Group
www.theptrgroup.com




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]