Browse Source

intermediate changes
ref:12e4bb60d22b39f59691a28f7163b60cc32d9823

arcadia-devtools 3 years ago
parent
commit
6985cc4bc6
1 changed files with 12 additions and 10 deletions
  1. 12 10
      build/plugins/ytest.py

+ 12 - 10
build/plugins/ytest.py

@@ -378,20 +378,22 @@ def match_coverage_extractor_requirements(unit):
     ])
     ])
 
 
 
 
-def get_tidy_config_map(unit):
-    global tidy_config_map
-    if tidy_config_map is None:
-        config_map_path = unit.resolve(os.path.join("$S", PROJECT_TIDY_CONFIG_MAP_PATH))
+def get_tidy_config_map(unit, map_path):
+    config_map_path = unit.resolve(os.path.join("$S", map_path))
+    config_map = {}
+    try:
         with open(config_map_path, 'r') as afile:
         with open(config_map_path, 'r') as afile:
-            tidy_config_map = json.load(afile)
-    return tidy_config_map
+            config_map = json.load(afile)
+    except ValueError:
+        ymake.report_configure_error("{} is invalid json".format(map_path))
+    except Exception as e:
+        ymake.report_configure_error(str(e))
+    return config_map
 
 
 
 
 def get_default_tidy_config(unit):
 def get_default_tidy_config(unit):
     unit_path = get_norm_unit_path(unit)
     unit_path = get_norm_unit_path(unit)
-    default_config_map_path = unit.resolve(os.path.join("$S", DEFAULT_TIDY_CONFIG_MAP_PATH))
-    with open(default_config_map_path, 'r') as afile:
-        tidy_default_config_map = json.load(afile)
+    tidy_default_config_map = get_tidy_config_map(unit, DEFAULT_TIDY_CONFIG_MAP_PATH)
     for project_prefix, config_path in tidy_default_config_map.items():
     for project_prefix, config_path in tidy_default_config_map.items():
         if unit_path.startswith(project_prefix):
         if unit_path.startswith(project_prefix):
             return config_path
             return config_path
@@ -399,7 +401,7 @@ def get_default_tidy_config(unit):
 
 
 
 
 def get_project_tidy_config(unit):
 def get_project_tidy_config(unit):
-    tidy_map = get_tidy_config_map(unit)
+    tidy_map = get_tidy_config_map(unit, PROJECT_TIDY_CONFIG_MAP_PATH)
     unit_path = get_norm_unit_path(unit)
     unit_path = get_norm_unit_path(unit)
 
 
     for project_prefix, config_path in tidy_map.items():
     for project_prefix, config_path in tidy_map.items():