This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Refactor System.exit
into return codes or exceptions
#27
Comments
cyrille-artho
added a commit
that referenced
this issue
Jan 31, 2019
modified: src/main/scala/modbat/mbt/Dotify.scala, src/main/scala/modbat/mbt/Main.scala, src/main/scala/modbat/mbt/Modbat.scala
cyrille-artho
added a commit
that referenced
this issue
Jan 31, 2019
…o return. modified: config/src/main/scala/modbat/config/ConfigMgr.scala, src/main/scala/modbat/mbt/Main.scala
Refactored some uses in the commits shown above. 8 instances left. |
cyrille-artho
added a commit
that referenced
this issue
Jan 31, 2019
modified: src/main/scala/modbat/mbt/Dotify.scala
9 tasks
System.exit
into return codesSystem.exit
into return codes or exceptions
For cases with deeply nested method calls, exceptions would be a better way of propagating error codes (as that would not require inserting "return" statements everywhere). |
I'll review the earlier changes w.r.t. that and convert return statements to exceptions if appropriate, and will then move on to the forked repo. |
Something was not done so well (my mistake...); check issue #45. |
AlexandreFournel
pushed a commit
to AlexandreFournel/modbat
that referenced
this issue
May 13, 2019
…so in Main) modified: src/main/scala/modbat/mbt/Dotify.scala modified: src/main/scala/modbat/mbt/Main.scala
cyrille-artho
pushed a commit
that referenced
this issue
May 14, 2019
cyrille-artho
pushed a commit
that referenced
this issue
May 15, 2019
* Issue #27: change return code in Dotify to exception (also in Main) modified: src/main/scala/modbat/mbt/Dotify.scala modified: src/main/scala/modbat/mbt/Main.scala * Line 45, I replaced return 1 by throw e in Main.scala * in file MBT.scala, severals System.exit(1) replaced by throw(error)
cyrille-artho
added a commit
that referenced
this issue
May 15, 2019
modified: src/main/scala/modbat/mbt/Main.scala: Updated comment.
AlexandreFournel
pushed a commit
to AlexandreFournel/modbat
that referenced
this issue
May 15, 2019
new file: src/main/java/modbat/mbt/NoTransitionException.java modified: src/main/scala/modbat/mbt/MBT.scala
Return codes left: ConfigMgr.scala (both 0 and 1): replace "return 1" with exception, remove "return 0", and make "run" have no return parameters; Main.scala: replace "return 1" with exceptions. |
System.exit: a couple left; try: |
cyrille-artho
pushed a commit
that referenced
this issue
May 15, 2019
* Issue #27: change return code in Dotify to exception (also in Main) * Line 45, I replaced return 1 by throw e in Main.scala * in file MBT.scala, several System.exit(1) replaced by throw(error) * in file MBT.scala, System.exit changed by throw new file: src/main/java/modbat/mbt/NoTransitionException.java modified: src/main/scala/modbat/mbt/MBT.scala modified: src/main/scala/modbat/mbt/Dotify.scala modified: src/main/scala/modbat/mbt/Main.scala
cyrille-artho
pushed a commit
that referenced
this issue
May 19, 2019
* Issue #27: change return code in Dotify to exception (also in Main) modified: src/main/scala/modbat/mbt/Dotify.scala modified: src/main/scala/modbat/mbt/Main.scala * Line 45, I replaced return 1 by throw e in Main.scala * in file MBT.scala, severals System.exit(1) replaced by throw(error) * in file MBT.scala, System.exit changed by throw * Issue #27: change exit to exception. new file: src/main/java/modbat/mbt/NoTransitionException.java modified: src/main/scala/modbat/mbt/MBT.scala * Remove return 1 replaced by throw exception.
cyrille-artho
pushed a commit
that referenced
this issue
May 20, 2019
…ala (#52) * Issue #27: change return code in Dotify to exception (also in Main) modified: src/main/scala/modbat/mbt/Dotify.scala modified: src/main/scala/modbat/mbt/Main.scala * in file MBT.scala, several System.exit(1) replaced by throw(error) * in file MBT.scala, System.exit changed by throw * Issue #27: change exit to exception. new file: src/main/java/modbat/mbt/NoTransitionException.java modified: src/main/scala/modbat/mbt/MBT.scala * New changes - in MBT.scala, but also in ModbatTestHarness.scala * New changes - no return 1 in ConfigMgr.scala, but now there are exceptions * New changes : add a try catch in ConfigMgr
Remaining open points:
|
AlexandreFournel
pushed a commit
to AlexandreFournel/modbat
that referenced
this issue
May 21, 2019
AlexandreFournel
pushed a commit
to AlexandreFournel/modbat
that referenced
this issue
May 21, 2019
cyrille-artho
pushed a commit
that referenced
this issue
May 21, 2019
…48) * Issue #27: change return code in Dotify to exception (also in Main) * Line 45, I replaced return 1 by throw e in Main.scala * in file MBT.scala, several System.exit(1) replaced by throw(error) * in file MBT.scala, System.exit changed by throw * Issue #27: change exit to exception. * New changes : add a try catch in ConfigMgr * new changes, I don't really know if it's correct because the number of wrong tests has increased (due to the number with . which are not understood as number by ma MacOS * Issue #27: remove return code in Main.run. * Issue #27: remove return code in explore.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
For being able to use a unit-test framework on some system tests, failing configurations have to avoid exiting the VM. Therefore, it is essential that the use of
System.exit
is minimized.This requires refactoring a lot of existing code:
main
cannot have a return value, so a different function (e.g.,run
) should provide the same functionality with a return value instead of exit code.main
continues to provide an exit code for system tests and production usage, callingrun
internally.System.exit
should be rewritten such that, at the top level,run
returns the status as an exit code, and onlymain
actually exits.As of now, there are 13 instances of
System.exit
in the code base.The text was updated successfully, but these errors were encountered: