Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
Refactoring (issue #27): provide Main.run, refactor System.exit usage.
Browse files Browse the repository at this point in the history
	modified:   src/main/scala/modbat/mbt/Dotify.scala, src/main/scala/modbat/mbt/Main.scala, src/main/scala/modbat/mbt/Modbat.scala
  • Loading branch information
cyrille-artho committed Jan 31, 2019
1 parent 601c962 commit 14c1fe8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/main/scala/modbat/mbt/Dotify.scala
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class Dotify(val model: MBT, outFile: String = "") {
}
}

def dotify(coverage: Boolean = false) {
def dotify(coverage: Boolean = false) = {
out.println("digraph model {")
out.println(" orientation = landscape;")
out.println(" graph [ rankdir = \"TB\", ranksep=\"0.4\", nodesep=\"0.2\" ];")
Expand All @@ -199,5 +199,6 @@ class Dotify(val model: MBT, outFile: String = "") {
}
}
out.println("}")
0 // TODO (issue #27): replace interal System.exit usage with error code
}
}
11 changes: 8 additions & 3 deletions src/main/scala/modbat/mbt/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ object Main {
val config = new Configuration()

def main(args: Array[String]) {
System.exit(run(args))
}

def run(args: Array[String]): Int = {
var modelClassName: String = null
val c = new ConfigMgr("scala modbat.jar", "CLASSNAME",
config, new Version ("modbat.mbt"))
Expand All @@ -17,18 +21,18 @@ object Main {
if (!remainingArgs.hasNext) {
Log.error(c.header)
Log.error("Model class argument missing. Try --help.")
System.exit(1)
return 1
}
modelClassName = remainingArgs.next
if (remainingArgs.hasNext) {
Log.error("Extra arguments starting at \"" + remainingArgs.next() +
"\" are not supported.")
System.exit(1)
return 1
}
} catch {
case e: IllegalArgumentException => {
Log.error(e.getMessage())
System.exit(1)
return 1
}
}

Expand All @@ -40,6 +44,7 @@ object Main {
new Dotify(MBT.launch(null), modelClassName + ".dot").dotify()
case _ => Modbat.explore(config.nRuns)
}
// TODO (issue #27): Dotify.dotify() and Modbat.explore() should use return code
}

def setup(modelClassName: String) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/modbat/mbt/Modbat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ object Modbat {
appState = AppShutdown
shutdown
Runtime.getRuntime().removeShutdownHook(ShutdownHandler)
// TODO (issue #27): Replace internal System.exit usage with return code
0
}

def getRandomSeed = {
Expand Down

0 comments on commit 14c1fe8

Please sign in to comment.