octave-patch-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-patch-tracker] [patch #9633] Add test for correct exit status be


From: Karl Wette
Subject: [Octave-patch-tracker] [patch #9633] Add test for correct exit status behaviour
Date: Tue, 8 May 2018 04:08:29 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0

URL:
  <http://savannah.gnu.org/patch/?9633>

                 Summary: Add test for correct exit status behaviour
                 Project: GNU Octave
            Submitted by: kwwette
            Submitted on: Tue 08 May 2018 08:08:27 AM UTC
                Category: Core : other
                Priority: 7 - High
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

I use Octave primarily as a command-line script interpreter (i.e. I run
executable scripts with #!/usr/bin/octave to invoke Octave) for scientific
applications on computer clusters. It is important for this application that
Octave conform to standard exit status behaviour:

* zero exit status is returned on success, either through normal completion
or
  by calling exit(0), and

* non-zero exit status is returned on failure, either through raising an
error()
  or by calling exit(n) with n != 0.

In Octave 4.2.2 the standard exit status behaviour was broken:

----------------------------------------------------------------

$ octave --version
GNU Octave, version 4.2.2
...

$ echo '0;' > script.m; octave script.m; echo $?
0   # ok

$ echo 'error("msg");' > script.m; octave script.m; echo $?
error: msg
error: called from
    script at line 1 column 1
0   # should return not 0

$ echo 'exit(0);' > script.m; octave script.m; echo $?
terminate called after throwing an instance of 'octave::exit_exception'
panic: Aborted -- stopping myself...
Aborted
134   # should return 0

$ echo 'exit(1);' > script.m; octave script.m; echo $?
terminate called after throwing an instance of 'octave::exit_exception'
panic: Aborted -- stopping myself...
Aborted
134   # should return 1

----------------------------------------------------------------

However it seems to have been fixed recently in development:

----------------------------------------------------------------

$ cat ./HG-ID 
3d5f953e2ef6

$ echo '0;' > script.m; ./run-octave script.m; echo $?
0   # ok

$ echo 'error("msg");' > script.m; ./run-octave script.m; echo $?
error: msg
error: called from
    script at line 1 column 1
1   # ok

$ echo 'exit(0);' > script.m; ./run-octave script.m; echo $?
0   # ok

$ echo 'exit(1);' > script.m; ./run-octave script.m; echo $?
1   # ok

----------------------------------------------------------------

I was unable to find a unit test for Octave's exit status behaviour, so the
attached patch adds such a unit test to ensure the exit status behaviour is
not
broken in future. The patch adds a script ./test-octave-exit-status.sh which
runs Octave code snippets either as a script or using --eval, and then tests
Octave's exit status for the standard behaviour given above.

The script ./test-octave-exit-status.sh is called from "make check" before
the
rest of the Octave test suite; a failed test in ./test-octave-exit-status.sh
will cause "make check" to fail; since the exit status tests are separate
from
the rest of the Octave test suite, a silent test failure might otherwise go
unnoticed.




    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Tue 08 May 2018 08:08:27 AM UTC  Name: test-octave-exit-status.patch 
Size: 4KiB   By: kwwette

<http://savannah.gnu.org/patch/download.php?file_id=44118>

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/patch/?9633>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]