Thanks Mark

You're right, I will split the method in several methods, and make it work
under Windows. The test \== "Windows" was already used in this file for one
test, where chmod is used. I took it as a model, that was exactly what I
needed :-).

Under Windows, I don't think I can have vrite-only files. Attrib can make a
file read-only but not write-only. That doesnt forbid to run the test
cases, it's just that the conditions of the original defect are not met.

I played with the permissions settings from the file explorer where I can
set a directory write-only (by selecting "refuse read access").
With this setting, I can create a file like that :
echo "line" > write-only\file.txt
which cannot be read.
But I can't append datas :
echo "line" >> write-only\file.txt (access denied)
An open with ooRexx fails at first try (RW) and second try (W)

Regarding the logic of the tests, it's the good one for testing the fix (no
failure).
But when I asked the question, I was developing the tests with an ooRexx
not yet fixed. And I wanted confirmation of the workaround that I described
in a previous mail. Hence the need to continue despite the first failure.
In the test cases, there is a comment -- ko before fix
which indicates which assertions failed.

Thanks a lot for having taken time for your very detailled answer.

Jean Louis

2011/11/12 Mark Miesfeld <miesf...@gmail.com>

> On Sat, Nov 12, 2011 at 6:49 AM, Jean-Louis Faucher <jfaucher...@gmail.com
> > wrote:
>
>>
>> Is it possible to execute only a specific method in a testgroup ?
>> my command is : rexx Stream.testGroup, launched from ooRexx/base/class
>> With my debug version in sandbox, it takes about 10s. Not so long, but
>> when repeated several times, it counts :-)
>>
>
> There are several ways you could do it.  You could just add a temp change
> to the the test group file:
>
>   parse source . . s
>
>   group = .TestGroup~new(s)
>   --group~add(.Stream.testGroup)
>   --group~add(.StreamClassQualify_QueryExists)
>
>   group~addWithCollection(.Stream.testGroup,
> .array~of('test_open_write_only_3274050'))
>   if group~isAutomatedTest then return group
>   say "Executing small test"
>   testResult = group~suite~execute~~print
>
> return testResult
>
> Which is what I would do if I wanted to temporarily eliminate any excess
> time.  You could add more test case names (method names) to the array.
>
>
> E:\work.ooRexx\wc\ooTest\4.x>rexx ooRexx\base\class\Stream.testGroup
> Executing small test
> Executing test_open_write_only_3274050
> Interpreter:     REXX-ooRexx_4.2.0(MT) 6.04 7 Nov 2011
> Addressing Mode: 64
> ooRexxUnit:      2.0.0_3.2.0    ooTest: 1.0.0_4.0.0
> Tests ran:           3
> Assertions:          0
> Failures:            0
> Errors:              0
> Skipped files:       0
> Test execution:     00:00:00.016000
>
> You could also simply copy the Stream.testGroup file to a second file and
> delete all the excess tests from the second file and run that.  Just don't
> commit the second file.
>
> However, the first time I went to try my temp change above, it looked like
> nothing executed.  When I looked at the test case I saw:
>
> ::method test_open_write_only_3274050
>   if .ooRexxUnit.OSName \== "WINDOWS" then do
> That's sort of ... well I don't know exactly what to call it.
>
> Each test case (individual method) should be generic and run on all
> platforms (preferable.)  Or if it really is platform specific, it should be
> in a separate test group and marked that way.
>
> So, you should put your *nix only tests in a separate test group file and
> mark it as *nix only:
>
>
>   group = .TestGroup~new(s)
>   group~restrictOS('LINUX', 'SUNOS', 'AIX', 'MACOSX')
>
> Although, without giving a lot of thought to it, it seems better to me to
> make the test generic to all platforms.  Test for Windows and use attrib
> instead of chmod.
>
> You could also write a small program to just execute a few methods in the
> Stream.testGroup and execute that program only.  Something along the lines
> of:
>
> /* qTest.rex */
>
>   parse source . . s
>   s = s~left(s~lastPos('\'))
>   s ||= 'ooRexx\base\class\Stream.testGroup'
>
>   group = .TestGroup~new(s)
>
>   group~addWithCollection(.Stream.testGroup,
> .array~of('test_open_write_only_3274050'))
>
>   say "Executing small test"
>   group~suite~execute~~print
>
> ::requires 'ooRexx\base\class\Stream.testGroup'
> ::requires 'ooTest.frm'
> ::requires 'FileUtils.cls'
> Which produces for me, when run in the framework directory:
>
> E:\work.ooRexx\wc\ooTest\4.x>qTest.rex
> Executing small test
> Executing test_open_write_only_3274050
> Interpreter:     REXX-ooRexx_4.2.0(MT) 6.04 7 Nov 2011
> Addressing Mode: 64
> ooRexxUnit:      2.0.0_3.2.0    ooTest: 1.0.0_4.0.0
> Tests ran:           3
> Assertions:          0
> Failures:            0
> Errors:              0
> Skipped files:       0
> Test execution:     00:00:00.015000
> Executing small test
> Executing test_open_write_only_3274050
> Interpreter:     REXX-ooRexx_4.2.0(MT) 6.04 7 Nov 2011
> Addressing Mode: 64
> ooRexxUnit:      2.0.0_3.2.0    ooTest: 1.0.0_4.0.0
> Tests ran:           3
> Assertions:          0
> Failures:            0
> Errors:              0
> Skipped files:       0
> Test execution:     00:00:00.016000
>
> You could put the program in the same directory as Stream.testGroup and do
> away with some of the path manipulation.
>
>
>
>>
>> Is there an assert which allows to continue the current method, even if
>> failed ?
>> I use self~assertSame, and in my test case, I know I can continue even if
>> the assert failed.
>>
>
> No, there is no way to continue.  The framework is based on the theory
> that  you should have many small tests, not one long continuous test.  This:
>
> +    -- Implicit opening of a non empty file
> +    call deleteFile fileName
> +    fileName = createFile(.array~of("line1"), fileName)
> +    self~assertTrue(fileName \== "")
>      'chmod a+w,a-r' fileName
> +    fsObj = .stream~new(fileName)
> +    self~streamTestingFile = fsObj
> +    line = "line2"
> +    ret = fsObj~charout(line)
> +    self~assertSame(0, ret) -- ko before fix
> +    ret = fsObj~lineout(line)
> +    self~assertSame(0, ret)
> +    ret = fsObj~close
> +    self~assertSame("READY:", ret)
> +
> +    -- Explicit opening of an empty file, using ~open
> +    call deleteFile fileName
> +    fileName = createFile(.array~new, fileName)
> +    self~assertTrue(fileName \== "")
> +    'chmod a+w,a-r' fileName
> +    fsObj = .stream~new(fileName)
> +    self~streamTestingFile = fsObj
> +    ret = fsObj~open("write append")
> +    self~assertSame("READY:", ret) -- ko before fix
> +    line = "line1"
> +    ret = fsObj~charout(line)
> +    self~assertSame(0, ret)
> +    ret = fsObj~lineout(line)
> +    self~assertSame(0, ret)
> +    ret = fsObj~close
> +    self~assertSame("READY:", ret)
> should be at least 2 different tests, and really more like 5 o 6 tests (5
> or 6 separate methods.)
>
> The theory behind the implementation is also that this is an *automated*
> framework for running the tests.  Time shouldn't matter.  If you put 6
> tests into 1 test case (method) and the first test fails, the other 5 test
> cases don't execute.  You don't want that.  You want all 6 tests to execute
> and for the framework to report that 5 tests pass, 1 test fails.
>
>
>
>
>
>>  Currently, i put in comment the assert, when the fail is as expected,
>> and relaunch the script to test the next assert, etc...
>>
>>
>>
>
>
>
> That sounds like you have the logic of the test backwards.  You should
> write tests that are expected to pass.  Without knowing the details, (so
> maybe I'm wrong,) I would say you can always write the inverse of you
> current test.
>
> --
> Mark Miesfeld
>
>
> ------------------------------------------------------------------------------
> RSA(R) Conference 2012
> Save $700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> Oorexx-devel mailing list
> Oorexx-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/oorexx-devel
>
>
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to