bugGNU Octave - Bugs: bug #42150, [N,MAX] = test(...) always returns...

 
 

bug #42150: [N,MAX] = test(...) always returns [0,0] if a test fails

Submitter:  Colin Macdonald <cbm>
Submitted:  Sun 20 Apr 2014 03:02:07 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 29 May 2014 07:34:54 AM UTC, comment #3: 

Yes!  Sorry for not replying.  Meant to submit patch for the doc text but didn't get around to it.

Colin Macdonald <cbm>
Thu 29 May 2014 02:15:12 AM UTC, comment #2: 

Closing as invalid with no reply from OP. Assuming that my comment #1 is a reasonable workaround to get the requested behavior.

Mike Miller <mtmiller>
Group Member
Wed 23 Apr 2014 11:15:35 PM UTC, comment #1: 

Thanks for the report. I think you do misunderstand though. The first paragraph of the help for test says:

> the tests are run interactively and stop
> after the first error is encountered.


It doesn't explicitly say this, but the return values seem to always be zero if the test function is not run in "batch" mode, meaning you have given it a file descriptor as the third argument. But since test stops on the first failing test, there's no point in reporting the number of tests passed or the total number, since it may not have run all of them.

If you want to run all tests in a function, try


octave:1> [n, max] = test ("myfunc", [], stdout)


It's a little clunky, but that forces it into batch mode and runs all tests, not stopping at the first failure. Does that do what you want?

Mike Miller <mtmiller>
Group Member
Sun 20 Apr 2014 03:02:07 PM UTC, original submission:  

doc text sounds like it should be number passed and total number, unless I misunderstand?

Testing on 3.6.4, 3.8.1 and recent hg (yesterday-ish).

minimal examples attached.



octave:4> test_return_works
N =  2
M =  2
octave:5>
octave:5>
octave:5> test_return_bug
  ***** assert(false)
!!!!! test failed
assert (false) failed
N = 0
M = 0
octave:6>


Colin Macdonald <cbm>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #31217:  test_return_works.m added by cbm (65B - text/x-objcsrc)
file #31218:  test_return_bug.m added by cbm (64B - text/x-objcsrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by cbm (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-05-29 mtmiller StatusNeed Info Invalid / Not an Octave Bug
        Open/ClosedOpen Closed
    2014-04-23 mtmiller StatusNone Need Info
    2014-04-20 cbm Attached File- Added test_return_works.m, #31217
        Attached File- Added test_return_bug.m, #31218

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code