From 1755175c0d636cbc61ea35b387fef0991b39dc3f Mon Sep 17 00:00:00 2001 From: Andreea Date: Fri, 6 Aug 2021 15:49:32 +0800 Subject: [PATCH] further config segregation --- APP_CONFIG.json | 3 ++- CONFIG.json | 1 - src/main/scala/FixConfig.scala | 5 +++-- src/main/scala/Hippodrome.scala | 4 +++- src/main/scala/inferAPI/InterpretJson.scala | 22 +++++++++++++-------- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/APP_CONFIG.json b/APP_CONFIG.json index 7885de5..592d19b 100644 --- a/APP_CONFIG.json +++ b/APP_CONFIG.json @@ -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/" } \ No newline at end of file diff --git a/CONFIG.json b/CONFIG.json index fa13b57..5f051a4 100644 --- a/CONFIG.json +++ b/CONFIG.json @@ -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, diff --git a/src/main/scala/FixConfig.scala b/src/main/scala/FixConfig.scala index 196fcb8..a570fee 100644 --- a/src/main/scala/FixConfig.scala +++ b/src/main/scala/FixConfig.scala @@ -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, diff --git a/src/main/scala/Hippodrome.scala b/src/main/scala/Hippodrome.scala index 05acc59..debc5e4 100644 --- a/src/main/scala/Hippodrome.scala +++ b/src/main/scala/Hippodrome.scala @@ -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)) } diff --git a/src/main/scala/inferAPI/InterpretJson.scala b/src/main/scala/inferAPI/InterpretJson.scala index 48c5ac5..bdab9a3 100644 --- a/src/main/scala/inferAPI/InterpretJson.scala +++ b/src/main/scala/inferAPI/InterpretJson.scala @@ -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 @@ -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) } } } @@ -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), ) } @@ -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) } } }