Skip to content

Commit

Permalink
further config segregation
Browse files Browse the repository at this point in the history
  • Loading branch information
andrecostea committed Aug 6, 2021
1 parent ff4a983 commit 1755175
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
3 changes: 2 additions & 1 deletion APP_CONFIG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"infer": "/Users/andrea/git/infer-clean/infer/infer/bin/infer",
"infer_options": ["--racerdfix-only", "--starvation", "--no-deduplicate"]
"infer_options": ["--racerdfix-only", "--starvation", "--no-deduplicate"],
"json_path": "./infer-out/"
}
1 change: 0 additions & 1 deletion CONFIG.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"json_path": "./infer-out/",
"target_options": ["--", "javac", "src/test/java/datarace/CustomerInfo.java","src/test/java/datarace/Account.java", "-d", "target"],
"prio_files": [],
"iterations": 5,
Expand Down
5 changes: 3 additions & 2 deletions src/main/scala/FixConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import org.racerdfix.utils.FileManipulation


class ToolConfig(
val infer: String,
val infer_opt: Seq[String],
val infer: String, // path to infer
val infer_opt: Seq[String], // the options infer is executed with
val json_path: String, // path to the files in which infer stores its summaries and reports
)

class Config(val infer: String,
Expand Down
4 changes: 3 additions & 1 deletion src/main/scala/Hippodrome.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ object Hippodrome {
val jsonTranslator = new InterpretJson(config)
val toolConfig = jsonTranslator.getJsonToolConfig()
/** the `infer` in file-config overwrites the `infer` in the tool-config which overwrites the `Globals.def_infer` */
val iConfig = if (config.infer == "") config.copy(infer = toolConfig.infer) else config
val iConfig0 = if (config.infer == "") config.copy(infer = toolConfig.infer) else config
/** the `json_path` in file-config overwrites the `json_path` in the tool-config which overwrites the `Globals.results_out_dir` */
val iConfig = if (iConfig0.json_path == "") iConfig0.copy(json_path = toolConfig.json_path) else iConfig0
val inferOptions = toolConfig.infer_opt diff iConfig.infer_opt
if (inferOptions.isEmpty) iConfig else iConfig.copy(infer_opt = iConfig.infer_opt.concat(inferOptions))
}
Expand Down
22 changes: 14 additions & 8 deletions src/main/scala/inferAPI/InterpretJson.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object ConfigProtocol extends DefaultJsonProtocol {
case JsObject(fields) => {
val options = fields.get("options").map(w => w.asInstanceOf[JsArray].elements.map(v => jsonToString(v)).toList).getOrElse[List[String]](Nil)
val files = fields.get("target_options").map(w => w.asInstanceOf[JsArray].elements.map(v => jsonToString(v)).toList).getOrElse[List[String]](Nil)
val prio_files = fields.get("prio_files").map(w => w.asInstanceOf[JsArray].elements.map(f => jsonToString(f)).toList).getOrElse[List[String]](Nil)
val prioFiles = fields.get("prio_files").map(w => w.asInstanceOf[JsArray].elements.map(f => jsonToString(f)).toList).getOrElse[List[String]](Nil)
val iterations = fields.get("iterations") match {
case None => Globals.no_iter
case Some(value) => value.toString().toInt
Expand All @@ -46,22 +46,22 @@ object ConfigProtocol extends DefaultJsonProtocol {
case None => ""
case Some (JsString(infer)) => infer
}
val json_path = fields.get("json_path") match {
val jsonPath = fields.get("json_path") match {
case None => Globals.results_out_dir
case Some (JsString(json_path)) => json_path
case Some (JsString(jsonPath)) => jsonPath
}
val racerdfix_config = fields.get("hippodrome_options") match {
val racerdfixConfig = fields.get("hippodrome_options") match {
case None => Seq.empty[String]
case Some (JsArray(vect)) => vect.map(jsonToString(_))
}
new Config(
infer,
options,
json_path,
jsonPath,
files,
prio_files,
prioFiles,
iterations,
racerdfix_config)
racerdfixConfig)
}
}
}
Expand All @@ -79,6 +79,7 @@ object ToolConfigProtocol extends DefaultJsonProtocol {
JsObject(
"infer" -> JsString(configInfer.infer),
"infer_options" -> JsArray(configInfer.infer_opt.map(f => JsString(f)).toVector),
"json_path" -> JsString(configInfer.json_path),
)
}

Expand All @@ -96,10 +97,15 @@ object ToolConfigProtocol extends DefaultJsonProtocol {
case None => Globals.def_infer
case Some (JsString(infer)) => infer
}
val jsonPath = fields.get("json_path") match {
case None => Globals.results_out_dir
case Some (JsString(jsonPath)) => jsonPath
}
val options = fields.get("infer_options").map(w => w.asInstanceOf[JsArray].elements.map(v => jsonToString(v)).toList).getOrElse[List[String]](Nil)
new ToolConfig(
infer,
options)
options,
jsonPath)
}
}
}
Expand Down

0 comments on commit 1755175

Please sign in to comment.