[aklug] Re: Simplest way to do this in bash?

From: Piet van Weel <pmvw@outwardfocus.net>
Date: Fri Jan 15 2010 - 04:01:00 AKST

Awww, man. I can't believe you didn't say RTFM... ;)

No, in reality Bryan... thank you for not saying that.
It's been a pain always hearing that from more experienced linux users.

On the flip side of the development circle Christopher...
Try creating your software this way...

1. Requirements
2. Design
3. Program Test for Class 1
4. Program Class 1
5. Run Test
6. Move onto next Class

This way when you're done, you've got a full set of tests developed
along with your software.

Piet

On 1/15/2010 2:47 AM, bryanm@acsalaska.net wrote:
> On Fri, January 15, 2010 1:11 am, Christopher Howard wrote:
>
>> My bash skills are a little weak. Okay, they are pretty much
>> non-existent past the common one-liners I use every day. So I would
>> appreciate any general suggestions or code:
>>
>> Basic idea: I'm writing some tests for my Java class to make sure that,
>> as I continue to develop the codebase, my methods are still giving the
>> output I expect. So I want to write a bash script that executes a test
>> class, and then compares STDOUT to the contents of a file (which
>> contains the output I expect). If the two are exactly the same, then
>> script moves on to the next test, otherwise echoes a failure message and
>> dies with a bad return value.
>>
>> Like so
>>
>> #
>> # ... compiles all the code ...
>> # ... I can write that part ...
>> #
>>
>> # execute java test program
>> java -cp ".;../" TestMyClass
>>
>> # then compare STDOUT of previous cmd
>> # to contents of file TestMyClass.dat
>>
>> # If contents are different then
>> echo "TestMyClass failed!"
>> # then die with bad return value
>>
>> # If contents are the same
>> # continue script...
>>
> This is not difficult. First, redirect output to a file:
> java -cp ".;../" TestMyClass>MyClass.out
>
> Then, use diff(1) to do the comparison:
> diff MyClass.expected MyClass.out
>
> I won't spoil the fun by quoting the man page here. :)
>
> --
> Bryan Medsker
> bryanm@acsalaska.net
>
> ---------
> To unsubscribe, send email to<aklug-request@aklug.org>
> with 'unsubscribe' in the message body.
>
>

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Fri Jan 15 04:01:38 2010

This archive was generated by hypermail 2.1.8 : Fri Jan 15 2010 - 04:01:38 AKST