ソースを参照

suppressions per file metrics. and more tests

avkonst 11 年 前
コミット
68e3a33158

+ 2 - 2
mainline/core/api.py

@@ -30,7 +30,7 @@ class Plugin(object):
             self.name = name
             self.value = value
     
-    def initialize(self, namespace=None, fields=[], properties=[]):
+    def initialize(self, namespace=None, support_regions=True, fields=[], properties=[]):
         self.is_updated = False
         db_loader = self.get_plugin_loader().get_database_loader()
         if namespace == None:
@@ -49,7 +49,7 @@ class Plugin(object):
 
         if len(fields) != 0:
             namespace_obj = db_loader.create_namespace(namespace,
-                                                       support_regions=True,
+                                                       support_regions=support_regions,
                                                        version=self.get_version())
             for field in fields:
                 is_created = namespace_obj.add_field(field.name, field.type, non_zero=field.non_zero)

+ 3 - 0
mainline/core/db/loader.py

@@ -877,6 +877,9 @@ class Loader(object):
                 distribution = self.db.count_rows(name, path_like = final_path_like, group_by_column = field)
                 data[field]['distribution-bars'] = []
                 for each in distribution:
+                    if each[0] == None:
+                        continue
+                    assert(float(data[field]['count'] != 0))
                     data[field]['distribution-bars'].append({'metric': each[0],
                                                              'count': each[1],
                                                              'ratio': round((float(each[1]) / float(data[field]['count'])), 4)})

+ 1 - 1
mainline/core/dir.py

@@ -58,7 +58,7 @@ class Plugin(core.api.Plugin, core.api.Parent, core.api.IConfigurable, core.api.
             fields.append(self.Field('procerrors', int))
         if self.is_size_enabled == True:
             fields.append(self.Field('size', int))
-        core.api.Plugin.initialize(self, namespace='std.general', fields=fields)
+        core.api.Plugin.initialize(self, namespace='std.general', support_regions=False, fields=fields)
         
     def run(self, args):
         if len(args) == 0:

+ 52 - 6
mainline/ext/std/suppress.py

@@ -41,7 +41,13 @@ class Plugin(core.api.Plugin, core.api.Child, core.api.IConfigurable):
         if self.is_active == True:
             fields.append(self.Field('count', int, non_zero=True))
             fields.append(self.Field('list', str))
+        # - init per regions table
         core.api.Plugin.initialize(self, fields=fields)
+        # - init per file table
+        core.api.Plugin.initialize(self,
+                                   namespace = self.get_name() + '.file',
+                                   support_regions = False,
+                                   fields=fields)
         
         if len(fields) != 0:
             core.api.subscribe_by_parents_interface(core.api.ICode, self, 'callback')
@@ -53,9 +59,11 @@ class Plugin(core.api.Plugin, core.api.Child, core.api.IConfigurable):
         is_updated = is_updated or self.is_updated
         if is_updated == True:
             text = data.get_content()
+            file_count = 0
+            file_list_text = []
             for region in data.iterate_regions():
                 count = 0
-                list_text = ""
+                list_text = []
                 last_comment_end = None
                 for marker in data.iterate_markers(
                                 filter_group = data.get_marker_types().COMMENT,
@@ -79,12 +87,50 @@ class Plugin(core.api.Plugin, core.api.Child, core.api.IConfigurable):
                                                     "' is not being collected",
                                                   [("Metric name", namespace_name + ":" + field),
                                                    ("Region name", region.get_name())])
-                            continue 
+                            continue
+                        if namespace.are_regions_supported() == False:
+                            if region.get_id() != 1:
+                                core.cout.notify(data.get_path(), region.get_cursor(),
+                                                  core.cout.SEVERITY_WARNING,
+                                                  "Suppressed metric '" + namespace_name + ":" + field +
+                                                    "' is attributed to a file, not a region. "
+                                                    "Remove it or move to the beginning of the file.",
+                                                  [("Metric name", namespace_name + ":" + field),
+                                                   ("Region name", region.get_name())])
+                                continue
+                            
+                            if m in file_list_text:
+                                core.cout.notify(data.get_path(), region.get_cursor(),
+                                              core.cout.SEVERITY_WARNING,
+                                              "Duplicate suppression of the metric '" +
+                                               namespace_name + ":" + field + "'",
+                                              [("Metric name", namespace_name + ":" + field),
+                                               ("Region name", None)])
+                                continue
+                            
+                            file_count += 1
+                            file_list_text.append(m)
+                            continue
+                        
+                        if m in list_text:
+                            core.cout.notify(data.get_path(), region.get_cursor(),
+                                          core.cout.SEVERITY_WARNING,
+                                          "Duplicate suppression of the metric '" +
+                                           namespace_name + ":" + field + "'",
+                                          [("Metric name", namespace_name + ":" + field),
+                                           ("Region name", region.get_name())])
+                            continue
+                        
                         count += 1
-                        list_text += "[" + m +"]"
+                        list_text.append(m)
+                        continue
+
+                if count > 0:
+                    region.set_data(self.get_name(), 'count', count)
+                    region.set_data(self.get_name(), 'list', '[' + ']['.join(list_text) + ']')
 
-                    if count > 0:
-                        region.set_data(self.get_name(), 'count', count)
-                        region.set_data(self.get_name(), 'list', list_text)
+            if file_count > 0:
+                data.set_data(self.get_name() + '.file', 'count', file_count)
+                data.set_data(self.get_name() + '.file', 'list', '[' + ']['.join(file_list_text) + ']')
 
 

+ 17 - 1
mainline/tests/general/test_basic.py

@@ -189,7 +189,23 @@ class Test(tests.common.TestCase):
                                          dirs_list=['./simple.cpp'],
                                          use_prev=True)
         self.assertExec(runner.run())
-        
+
+    def test_std_general_metrics(self):
+
+        runner = tests.common.ToolRunner('collect',
+                                         ['--std.general.size',
+                                          '--std.general.procerrors',
+                                          '--std.general.proctime'])
+        self.assertExec(runner.run())
+
+        runner = tests.common.ToolRunner('view', ['--format=txt'], prefix='txt')
+        self.assertExec(runner.run())
+
+        runner = tests.common.ToolRunner('view',
+                                         ['--nest-regions', '--format=txt'],
+                                         prefix='nest_per_file',
+                                         dirs_list=['./simple.cpp'])
+        self.assertExec(runner.run())
 
 if __name__ == '__main__':
     unittest.main()

+ 0 - 0
mainline/tests/general/test_basic/test_std_general_metrics_collect_default_stdout.gold.txt


+ 148 - 0
mainline/tests/general/test_basic/test_std_general_metrics_view_nest_per_file_stdout.gold.txt

@@ -0,0 +1,148 @@
+================================================================================
+Export
+________________________________________________________________________________
+
+--------------------------------------------------------------------------------
+data:  
+.   info: 
+.   .   path="./simple.cpp"
+.   .   id="1"
+.   file-data:  
+.   .   regions:
+.   .   
+.   .   .   region:  
+.   .   .   .   info: 
+.   .   .   .   .   cursor="0"
+.   .   .   .   .   name="__global__"
+.   .   .   .   .   offset_end="487"
+.   .   .   .   .   line_begin="3"
+.   .   .   .   .   type="global"
+.   .   .   .   .   line_end="52"
+.   .   .   .   .   offset_begin="2"
+.   .   .   .   data: 
+.   .   .   .   subregions:
+.   .   .   .   
+.   .   .   .   .   subregion:  
+.   .   .   .   .   .   info: 
+.   .   .   .   .   .   .   cursor="4"
+.   .   .   .   .   .   .   name="hmm"
+.   .   .   .   .   .   .   offset_end="486"
+.   .   .   .   .   .   .   line_begin="3"
+.   .   .   .   .   .   .   type="namespace"
+.   .   .   .   .   .   .   line_end="51"
+.   .   .   .   .   .   .   offset_begin="2"
+.   .   .   .   .   .   data: 
+.   .   .   .   .   .   subregions:
+.   .   .   .   .   .   
+.   .   .   .   .   .   .   subregion:  
+.   .   .   .   .   .   .   .   info: 
+.   .   .   .   .   .   .   .   .   cursor="7"
+.   .   .   .   .   .   .   .   .   name="A"
+.   .   .   .   .   .   .   .   .   offset_end="482"
+.   .   .   .   .   .   .   .   .   line_begin="7"
+.   .   .   .   .   .   .   .   .   type="class"
+.   .   .   .   .   .   .   .   .   line_end="49"
+.   .   .   .   .   .   .   .   .   offset_begin="76"
+.   .   .   .   .   .   .   .   data: 
+.   .   .   .   .   .   .   .   subregions:
+.   .   .   .   .   .   .   .   
+.   .   .   .   .   .   .   .   .   subregion:  
+.   .   .   .   .   .   .   .   .   .   info: 
+.   .   .   .   .   .   .   .   .   .   .   cursor="10"
+.   .   .   .   .   .   .   .   .   .   .   name="A"
+.   .   .   .   .   .   .   .   .   .   .   offset_end="234"
+.   .   .   .   .   .   .   .   .   .   .   line_begin="10"
+.   .   .   .   .   .   .   .   .   .   .   type="function"
+.   .   .   .   .   .   .   .   .   .   .   line_end="21"
+.   .   .   .   .   .   .   .   .   .   .   offset_begin="88"
+.   .   .   .   .   .   .   .   .   .   data: 
+.   .   .   .   .   .   .   .   .   .   subregions:
+.   .   .   .   .   .   .   .   
+.   .   .   .   .   .   .   .   .   subregion:  
+.   .   .   .   .   .   .   .   .   .   info: 
+.   .   .   .   .   .   .   .   .   .   .   cursor="23"
+.   .   .   .   .   .   .   .   .   .   .   name="func"
+.   .   .   .   .   .   .   .   .   .   .   offset_end="386"
+.   .   .   .   .   .   .   .   .   .   .   line_begin="23"
+.   .   .   .   .   .   .   .   .   .   .   type="function"
+.   .   .   .   .   .   .   .   .   .   .   line_end="37"
+.   .   .   .   .   .   .   .   .   .   .   offset_begin="237"
+.   .   .   .   .   .   .   .   .   .   data: 
+.   .   .   .   .   .   .   .   .   .   subregions:
+.   .   .   .   .   .   .   .   .   .   
+.   .   .   .   .   .   .   .   .   .   .   subregion:  
+.   .   .   .   .   .   .   .   .   .   .   .   info: 
+.   .   .   .   .   .   .   .   .   .   .   .   .   cursor="25"
+.   .   .   .   .   .   .   .   .   .   .   .   .   name="embeded"
+.   .   .   .   .   .   .   .   .   .   .   .   .   offset_end="372"
+.   .   .   .   .   .   .   .   .   .   .   .   .   line_begin="25"
+.   .   .   .   .   .   .   .   .   .   .   .   .   type="class"
+.   .   .   .   .   .   .   .   .   .   .   .   .   line_end="35"
+.   .   .   .   .   .   .   .   .   .   .   .   .   offset_begin="266"
+.   .   .   .   .   .   .   .   .   .   .   .   data: 
+.   .   .   .   .   .   .   .   .   .   .   .   subregions:
+.   .   .   .   .   .   .   .   .   .   .   .   
+.   .   .   .   .   .   .   .   .   .   .   .   .   subregion:  
+.   .   .   .   .   .   .   .   .   .   .   .   .   .   info: 
+.   .   .   .   .   .   .   .   .   .   .   .   .   .   .   cursor="27"
+.   .   .   .   .   .   .   .   .   .   .   .   .   .   .   name="embeded"
+.   .   .   .   .   .   .   .   .   .   .   .   .   .   .   offset_end="368"
+.   .   .   .   .   .   .   .   .   .   .   .   .   .   .   line_begin="27"
+.   .   .   .   .   .   .   .   .   .   .   .   .   .   .   type="function"
+.   .   .   .   .   .   .   .   .   .   .   .   .   .   .   line_end="34"
+.   .   .   .   .   .   .   .   .   .   .   .   .   .   .   offset_begin="287"
+.   .   .   .   .   .   .   .   .   .   .   .   .   .   data: 
+.   .   .   .   .   .   .   .   .   .   .   .   .   .   subregions:
+.   .   .   .   .   .   .   .   
+.   .   .   .   .   .   .   .   .   subregion:  
+.   .   .   .   .   .   .   .   .   .   info: 
+.   .   .   .   .   .   .   .   .   .   .   cursor="39"
+.   .   .   .   .   .   .   .   .   .   .   name="never"
+.   .   .   .   .   .   .   .   .   .   .   offset_end="459"
+.   .   .   .   .   .   .   .   .   .   .   line_begin="39"
+.   .   .   .   .   .   .   .   .   .   .   type="function"
+.   .   .   .   .   .   .   .   .   .   .   line_end="46"
+.   .   .   .   .   .   .   .   .   .   .   offset_begin="389"
+.   .   .   .   .   .   .   .   .   .   data: 
+.   .   .   .   .   .   .   .   .   .   subregions:
+.   .   std.general: 
+.   .   .   proctime="0.00399994850159"
+.   .   .   size="487"
+.   subfiles:
+.   subdirs:
+.   aggregated-data:  
+.   .   std.general:  
+.   .   .   procerrors: 
+.   .   .   .   count="0"
+.   .   .   .   max="None"
+.   .   .   .   avg="None"
+.   .   .   .   total="0.0"
+.   .   .   .   min="None" 
+.   .   .   .   distribution-bars:
+.   .   .   proctime: 
+.   .   .   .   count="1"
+.   .   .   .   max="0.00399994850159"
+.   .   .   .   avg="0.00399994850159"
+.   .   .   .   total="0.00399994850159"
+.   .   .   .   min="0.00399994850159" 
+.   .   .   .   distribution-bars:
+.   .   .   .   
+.   .   .   .   .   distribution-bar: 
+.   .   .   .   .   .   count="1"
+.   .   .   .   .   .   metric="0.00399994850159"
+.   .   .   .   .   .   ratio="1.0"
+.   .   .   size: 
+.   .   .   .   count="1"
+.   .   .   .   max="487"
+.   .   .   .   avg="487.0"
+.   .   .   .   total="487.0"
+.   .   .   .   min="487" 
+.   .   .   .   distribution-bars:
+.   .   .   .   
+.   .   .   .   .   distribution-bar: 
+.   .   .   .   .   .   count="1"
+.   .   .   .   .   .   metric="487"
+.   .   .   .   .   .   ratio="1.0"
+================================================================================
+
+

+ 49 - 0
mainline/tests/general/test_basic/test_std_general_metrics_view_txt_stdout.gold.txt

@@ -0,0 +1,49 @@
+================================================================================
+Export
+________________________________________________________________________________
+
+--------------------------------------------------------------------------------
+data:  
+.   info: 
+.   .   path=""
+.   .   id="1"
+.   file-data: 
+.   subfiles:
+.   subdirs:
+.   .   .
+.   aggregated-data:  
+.   .   std.general:  
+.   .   .   procerrors: 
+.   .   .   .   count="0"
+.   .   .   .   max="None"
+.   .   .   .   avg="None"
+.   .   .   .   total="0.0"
+.   .   .   .   min="None" 
+.   .   .   .   distribution-bars:
+.   .   .   proctime: 
+.   .   .   .   count="1"
+.   .   .   .   max="0.00399994850159"
+.   .   .   .   avg="0.00399994850159"
+.   .   .   .   total="0.00399994850159"
+.   .   .   .   min="0.00399994850159" 
+.   .   .   .   distribution-bars:
+.   .   .   .   
+.   .   .   .   .   distribution-bar: 
+.   .   .   .   .   .   count="1"
+.   .   .   .   .   .   metric="0.00399994850159"
+.   .   .   .   .   .   ratio="1.0"
+.   .   .   size: 
+.   .   .   .   count="1"
+.   .   .   .   max="487"
+.   .   .   .   avg="487.0"
+.   .   .   .   total="487.0"
+.   .   .   .   min="487" 
+.   .   .   .   distribution-bars:
+.   .   .   .   
+.   .   .   .   .   distribution-bar: 
+.   .   .   .   .   .   count="1"
+.   .   .   .   .   .   metric="487"
+.   .   .   .   .   .   ratio="1.0"
+================================================================================
+
+

+ 15 - 2
mainline/tests/general/test_std_suppress.py

@@ -28,7 +28,8 @@ class Test(tests.common.TestCase):
         
         runner = tests.common.ToolRunner('collect', ['--std.suppress',
                                                      '--std.code.complexity.cyclomatic',
-                                                     '--std.code.length.total'])
+                                                     '--std.code.length.total',
+                                                     '--std.general.size'])
         self.assertExec(runner.run())
 
         runner = tests.common.ToolRunner('limit',
@@ -51,7 +52,7 @@ class Test(tests.common.TestCase):
 
         runner = tests.common.ToolRunner('limit',
                                          ['--max-limit=std.code.length:total:0', '--disable-suppressions'],
-                                         exit_code=24,
+                                         exit_code=26,
                                          prefix='4')
         self.assertExec(runner.run())
 
@@ -61,5 +62,17 @@ class Test(tests.common.TestCase):
                                          prefix='5')
         self.assertExec(runner.run())
 
+        runner = tests.common.ToolRunner('limit',
+                                         ['--max-limit=std.general:size:0'],
+                                         exit_code=0,
+                                         prefix='size')
+        self.assertExec(runner.run())
+
+        runner = tests.common.ToolRunner('limit',
+                                         ['--max-limit=std.general:size:0', '--disable-suppressions'],
+                                         exit_code=1,
+                                         prefix='size_nosup')
+        self.assertExec(runner.run())
+
 if __name__ == '__main__':
     unittest.main()

+ 13 - 0
mainline/tests/general/test_std_suppress/sources/test.c

@@ -1,6 +1,8 @@
 /* comment here per global region
  *
  *	metrix++:	suppress std.code.length:total
+ *	metrix++: suppress std.general:size
+ *	metrix++: suppress std.general:size intentional duplicate
  */
 
 
@@ -156,4 +158,15 @@ int func10()
 	if (1) return;
 }
 
+/* metrix++: suppress std.code.length:total
+ * metrix++: suppress std.code.length:total */
+int duplicate_suppression_of_size()
+{
+}
+
+/* metrix++: suppress std.general:size intentional suppression per file metric
+ * metrix++: suppress std.code.length:total */
+int bad_suppression_of_file_size()
+{
+}
 

+ 16 - 4
mainline/tests/general/test_std_suppress/test_basic_collect_default_stdout.gold.txt

@@ -1,16 +1,28 @@
-./test.c:82: warning: Suppressed metric 'invalid:metric' is not being collected
+./test.c:0: warning: Duplicate suppression of the metric 'std.general:size'
+	Metric name    : std.general:size
+	Region name    : None
+
+./test.c:84: warning: Suppressed metric 'invalid:metric' is not being collected
 	Metric name    : invalid:metric
 	Region name    : suppresed_for_invalid_metric
 
-./test.c:88: warning: Suppressed metric 'std.code.length:invlaid_metric' is not being collected
+./test.c:90: warning: Suppressed metric 'std.code.length:invlaid_metric' is not being collected
 	Metric name    : std.code.length:invlaid_metric
 	Region name    : suppresed_for_invalid_metric
 
-./test.c:95: warning: Suppressed metric 'invalid:metric' is not being collected
+./test.c:97: warning: Suppressed metric 'invalid:metric' is not being collected
 	Metric name    : invalid:metric
 	Region name    : suppressed_for_size_and_invalid_metric
 
-./test.c:103: warning: Suppressed metric 'invalid:metric' is not being collected
+./test.c:105: warning: Suppressed metric 'invalid:metric' is not being collected
 	Metric name    : invalid:metric
 	Region name    : suppressed_for_size_and_complexity_and_invalid_metric
 
+./test.c:163: warning: Duplicate suppression of the metric 'std.code.length:total'
+	Metric name    : std.code.length:total
+	Region name    : duplicate_suppression_of_size
+
+./test.c:169: warning: Suppressed metric 'std.general:size' is attributed to a file, not a region. Remove it or move to the beginning of the file.
+	Metric name    : std.general:size
+	Region name    : bad_suppression_of_file_size
+

+ 1 - 1
mainline/tests/general/test_std_suppress/test_basic_limit_1_stdout.gold.txt

@@ -1,4 +1,4 @@
-./test.c:122: warning: Metric 'std.code.complexity:cyclomatic' for region 'no_suppress_for_cyclomatic_complexity' exceeds the limit.
+./test.c:124: warning: Metric 'std.code.complexity:cyclomatic' for region 'no_suppress_for_cyclomatic_complexity' exceeds the limit.
 	Metric name    : std.code.complexity:cyclomatic
 	Region name    : no_suppress_for_cyclomatic_complexity
 	Metric value   : 1

+ 8 - 8
mainline/tests/general/test_std_suppress/test_basic_limit_2_stdout.gold.txt

@@ -1,4 +1,4 @@
-./test.c:103: warning: Metric 'std.code.complexity:cyclomatic' for region 'suppressed_for_size_and_complexity_and_invalid_metric' exceeds the limit.
+./test.c:105: warning: Metric 'std.code.complexity:cyclomatic' for region 'suppressed_for_size_and_complexity_and_invalid_metric' exceeds the limit.
 	Metric name    : std.code.complexity:cyclomatic
 	Region name    : suppressed_for_size_and_complexity_and_invalid_metric
 	Metric value   : 1
@@ -7,7 +7,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:110: warning: Metric 'std.code.complexity:cyclomatic' for region 'func7' exceeds the limit.
+./test.c:112: warning: Metric 'std.code.complexity:cyclomatic' for region 'func7' exceeds the limit.
 	Metric name    : std.code.complexity:cyclomatic
 	Region name    : func7
 	Metric value   : 1
@@ -16,7 +16,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:116: warning: Metric 'std.code.complexity:cyclomatic' for region 'nu_suppress_for_size' exceeds the limit.
+./test.c:118: warning: Metric 'std.code.complexity:cyclomatic' for region 'nu_suppress_for_size' exceeds the limit.
 	Metric name    : std.code.complexity:cyclomatic
 	Region name    : nu_suppress_for_size
 	Metric value   : 1
@@ -25,7 +25,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:122: warning: Metric 'std.code.complexity:cyclomatic' for region 'no_suppress_for_cyclomatic_complexity' exceeds the limit.
+./test.c:124: warning: Metric 'std.code.complexity:cyclomatic' for region 'no_suppress_for_cyclomatic_complexity' exceeds the limit.
 	Metric name    : std.code.complexity:cyclomatic
 	Region name    : no_suppress_for_cyclomatic_complexity
 	Metric value   : 1
@@ -34,7 +34,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:130: warning: Metric 'std.code.complexity:cyclomatic' for region 'func8' exceeds the limit.
+./test.c:132: warning: Metric 'std.code.complexity:cyclomatic' for region 'func8' exceeds the limit.
 	Metric name    : std.code.complexity:cyclomatic
 	Region name    : func8
 	Metric value   : 1
@@ -43,7 +43,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:138: warning: Metric 'std.code.complexity:cyclomatic' for region 'func9' exceeds the limit.
+./test.c:140: warning: Metric 'std.code.complexity:cyclomatic' for region 'func9' exceeds the limit.
 	Metric name    : std.code.complexity:cyclomatic
 	Region name    : func9
 	Metric value   : 1
@@ -52,7 +52,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:144: warning: Metric 'std.code.complexity:cyclomatic' for region 'bad_suppress_for_size' exceeds the limit.
+./test.c:146: warning: Metric 'std.code.complexity:cyclomatic' for region 'bad_suppress_for_size' exceeds the limit.
 	Metric name    : std.code.complexity:cyclomatic
 	Region name    : bad_suppress_for_size
 	Metric value   : 1
@@ -61,7 +61,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:154: warning: Metric 'std.code.complexity:cyclomatic' for region 'func10' exceeds the limit.
+./test.c:156: warning: Metric 'std.code.complexity:cyclomatic' for region 'func10' exceeds the limit.
 	Metric name    : std.code.complexity:cyclomatic
 	Region name    : func10
 	Metric value   : 1

+ 7 - 7
mainline/tests/general/test_std_suppress/test_basic_limit_3_stdout.gold.txt

@@ -1,4 +1,4 @@
-./test.c:54: warning: Metric 'std.code.length:total' for region 'no_suppress_cl' exceeds the limit.
+./test.c:56: warning: Metric 'std.code.length:total' for region 'no_suppress_cl' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : no_suppress_cl
 	Metric value   : 44
@@ -7,7 +7,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:60: warning: Metric 'std.code.length:total' for region 'nu_suppress_func' exceeds the limit.
+./test.c:62: warning: Metric 'std.code.length:total' for region 'nu_suppress_func' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : nu_suppress_func
 	Metric value   : 63
@@ -16,7 +16,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:75: warning: Metric 'std.code.length:total' for region 'func_no_suppress_within_struct' exceeds the limit.
+./test.c:77: warning: Metric 'std.code.length:total' for region 'func_no_suppress_within_struct' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : func_no_suppress_within_struct
 	Metric value   : 43
@@ -25,7 +25,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:82: warning: Metric 'std.code.length:total' for region 'suppresed_for_invalid_metric' exceeds the limit.
+./test.c:84: warning: Metric 'std.code.length:total' for region 'suppresed_for_invalid_metric' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : suppresed_for_invalid_metric
 	Metric value   : 80
@@ -34,7 +34,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:88: warning: Metric 'std.code.length:total' for region 'suppresed_for_invalid_metric' exceeds the limit.
+./test.c:90: warning: Metric 'std.code.length:total' for region 'suppresed_for_invalid_metric' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : suppresed_for_invalid_metric
 	Metric value   : 96
@@ -43,7 +43,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:116: warning: Metric 'std.code.length:total' for region 'nu_suppress_for_size' exceeds the limit.
+./test.c:118: warning: Metric 'std.code.length:total' for region 'nu_suppress_for_size' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : nu_suppress_for_size
 	Metric value   : 105
@@ -52,7 +52,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:144: warning: Metric 'std.code.length:total' for region 'bad_suppress_for_size' exceeds the limit.
+./test.c:146: warning: Metric 'std.code.length:total' for region 'bad_suppress_for_size' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : bad_suppress_for_size
 	Metric value   : 152

+ 42 - 24
mainline/tests/general/test_std_suppress/test_basic_limit_4_stdout.gold.txt

@@ -1,13 +1,13 @@
 ./test.c:0: warning: Metric 'std.code.length:total' for region '__global__' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : __global__
-	Metric value   : 139
+	Metric value   : 242
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:8: warning: Metric 'std.code.length:total' for region 'func' exceeds the limit.
+./test.c:10: warning: Metric 'std.code.length:total' for region 'func' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : func
 	Metric value   : 79
@@ -16,7 +16,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:13: warning: Metric 'std.code.length:total' for region 'func2' exceeds the limit.
+./test.c:15: warning: Metric 'std.code.length:total' for region 'func2' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : func2
 	Metric value   : 61
@@ -25,7 +25,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:19: warning: Metric 'std.code.length:total' for region 'func3' exceeds the limit.
+./test.c:21: warning: Metric 'std.code.length:total' for region 'func3' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : func3
 	Metric value   : 109
@@ -34,7 +34,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:28: warning: Metric 'std.code.length:total' for region 'func4' exceeds the limit.
+./test.c:30: warning: Metric 'std.code.length:total' for region 'func4' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : func4
 	Metric value   : 137
@@ -43,7 +43,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:34: warning: Metric 'std.code.length:total' for region 'cl1' exceeds the limit.
+./test.c:36: warning: Metric 'std.code.length:total' for region 'cl1' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : cl1
 	Metric value   : 62
@@ -52,7 +52,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:39: warning: Metric 'std.code.length:total' for region 'cl2' exceeds the limit.
+./test.c:41: warning: Metric 'std.code.length:total' for region 'cl2' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : cl2
 	Metric value   : 62
@@ -61,7 +61,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:48: warning: Metric 'std.code.length:total' for region 'cl3' exceeds the limit.
+./test.c:50: warning: Metric 'std.code.length:total' for region 'cl3' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : cl3
 	Metric value   : 80
@@ -70,7 +70,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:54: warning: Metric 'std.code.length:total' for region 'no_suppress_cl' exceeds the limit.
+./test.c:56: warning: Metric 'std.code.length:total' for region 'no_suppress_cl' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : no_suppress_cl
 	Metric value   : 44
@@ -79,7 +79,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:60: warning: Metric 'std.code.length:total' for region 'nu_suppress_func' exceeds the limit.
+./test.c:62: warning: Metric 'std.code.length:total' for region 'nu_suppress_func' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : nu_suppress_func
 	Metric value   : 63
@@ -88,7 +88,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:65: warning: Metric 'std.code.length:total' for region 'cl2' exceeds the limit.
+./test.c:67: warning: Metric 'std.code.length:total' for region 'cl2' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : cl2
 	Metric value   : 78
@@ -97,7 +97,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:70: warning: Metric 'std.code.length:total' for region 'func4' exceeds the limit.
+./test.c:72: warning: Metric 'std.code.length:total' for region 'func4' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : func4
 	Metric value   : 79
@@ -106,7 +106,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:75: warning: Metric 'std.code.length:total' for region 'func_no_suppress_within_struct' exceeds the limit.
+./test.c:77: warning: Metric 'std.code.length:total' for region 'func_no_suppress_within_struct' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : func_no_suppress_within_struct
 	Metric value   : 43
@@ -115,7 +115,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:82: warning: Metric 'std.code.length:total' for region 'suppresed_for_invalid_metric' exceeds the limit.
+./test.c:84: warning: Metric 'std.code.length:total' for region 'suppresed_for_invalid_metric' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : suppresed_for_invalid_metric
 	Metric value   : 80
@@ -124,7 +124,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:88: warning: Metric 'std.code.length:total' for region 'suppresed_for_invalid_metric' exceeds the limit.
+./test.c:90: warning: Metric 'std.code.length:total' for region 'suppresed_for_invalid_metric' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : suppresed_for_invalid_metric
 	Metric value   : 96
@@ -133,7 +133,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:95: warning: Metric 'std.code.length:total' for region 'suppressed_for_size_and_invalid_metric' exceeds the limit.
+./test.c:97: warning: Metric 'std.code.length:total' for region 'suppressed_for_size_and_invalid_metric' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : suppressed_for_size_and_invalid_metric
 	Metric value   : 137
@@ -142,7 +142,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:103: warning: Metric 'std.code.length:total' for region 'suppressed_for_size_and_complexity_and_invalid_metric' exceeds the limit.
+./test.c:105: warning: Metric 'std.code.length:total' for region 'suppressed_for_size_and_complexity_and_invalid_metric' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : suppressed_for_size_and_complexity_and_invalid_metric
 	Metric value   : 222
@@ -151,7 +151,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:110: warning: Metric 'std.code.length:total' for region 'func7' exceeds the limit.
+./test.c:112: warning: Metric 'std.code.length:total' for region 'func7' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : func7
 	Metric value   : 140
@@ -160,7 +160,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:116: warning: Metric 'std.code.length:total' for region 'nu_suppress_for_size' exceeds the limit.
+./test.c:118: warning: Metric 'std.code.length:total' for region 'nu_suppress_for_size' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : nu_suppress_for_size
 	Metric value   : 105
@@ -169,7 +169,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:122: warning: Metric 'std.code.length:total' for region 'no_suppress_for_cyclomatic_complexity' exceeds the limit.
+./test.c:124: warning: Metric 'std.code.length:total' for region 'no_suppress_for_cyclomatic_complexity' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : no_suppress_for_cyclomatic_complexity
 	Metric value   : 113
@@ -178,7 +178,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:130: warning: Metric 'std.code.length:total' for region 'func8' exceeds the limit.
+./test.c:132: warning: Metric 'std.code.length:total' for region 'func8' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : func8
 	Metric value   : 175
@@ -187,7 +187,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:138: warning: Metric 'std.code.length:total' for region 'func9' exceeds the limit.
+./test.c:140: warning: Metric 'std.code.length:total' for region 'func9' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : func9
 	Metric value   : 184
@@ -196,7 +196,7 @@
 	Limit          : 0.0
 	Suppressed     : True
 
-./test.c:144: warning: Metric 'std.code.length:total' for region 'bad_suppress_for_size' exceeds the limit.
+./test.c:146: warning: Metric 'std.code.length:total' for region 'bad_suppress_for_size' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : bad_suppress_for_size
 	Metric value   : 152
@@ -205,7 +205,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:154: warning: Metric 'std.code.length:total' for region 'func10' exceeds the limit.
+./test.c:156: warning: Metric 'std.code.length:total' for region 'func10' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : func10
 	Metric value   : 179
@@ -214,3 +214,21 @@
 	Limit          : 0.0
 	Suppressed     : True
 
+./test.c:163: warning: Metric 'std.code.length:total' for region 'duplicate_suppression_of_size' exceeds the limit.
+	Metric name    : std.code.length:total
+	Region name    : duplicate_suppression_of_size
+	Metric value   : 130
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:169: warning: Metric 'std.code.length:total' for region 'bad_suppression_of_file_size' exceeds the limit.
+	Metric name    : std.code.length:total
+	Region name    : bad_suppression_of_file_size
+	Metric value   : 164
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+

+ 8 - 8
mainline/tests/general/test_std_suppress/test_basic_limit_5_stdout.gold.txt

@@ -1,4 +1,4 @@
-./test.c:122: warning: Metric 'std.code.complexity:cyclomatic' for region 'no_suppress_for_cyclomatic_complexity' exceeds the limit.
+./test.c:124: warning: Metric 'std.code.complexity:cyclomatic' for region 'no_suppress_for_cyclomatic_complexity' exceeds the limit.
 	Metric name    : std.code.complexity:cyclomatic
 	Region name    : no_suppress_for_cyclomatic_complexity
 	Metric value   : 1
@@ -7,7 +7,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:54: warning: Metric 'std.code.length:total' for region 'no_suppress_cl' exceeds the limit.
+./test.c:56: warning: Metric 'std.code.length:total' for region 'no_suppress_cl' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : no_suppress_cl
 	Metric value   : 44
@@ -16,7 +16,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:60: warning: Metric 'std.code.length:total' for region 'nu_suppress_func' exceeds the limit.
+./test.c:62: warning: Metric 'std.code.length:total' for region 'nu_suppress_func' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : nu_suppress_func
 	Metric value   : 63
@@ -25,7 +25,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:75: warning: Metric 'std.code.length:total' for region 'func_no_suppress_within_struct' exceeds the limit.
+./test.c:77: warning: Metric 'std.code.length:total' for region 'func_no_suppress_within_struct' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : func_no_suppress_within_struct
 	Metric value   : 43
@@ -34,7 +34,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:82: warning: Metric 'std.code.length:total' for region 'suppresed_for_invalid_metric' exceeds the limit.
+./test.c:84: warning: Metric 'std.code.length:total' for region 'suppresed_for_invalid_metric' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : suppresed_for_invalid_metric
 	Metric value   : 80
@@ -43,7 +43,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:88: warning: Metric 'std.code.length:total' for region 'suppresed_for_invalid_metric' exceeds the limit.
+./test.c:90: warning: Metric 'std.code.length:total' for region 'suppresed_for_invalid_metric' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : suppresed_for_invalid_metric
 	Metric value   : 96
@@ -52,7 +52,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:116: warning: Metric 'std.code.length:total' for region 'nu_suppress_for_size' exceeds the limit.
+./test.c:118: warning: Metric 'std.code.length:total' for region 'nu_suppress_for_size' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : nu_suppress_for_size
 	Metric value   : 105
@@ -61,7 +61,7 @@
 	Limit          : 0.0
 	Suppressed     : False
 
-./test.c:144: warning: Metric 'std.code.length:total' for region 'bad_suppress_for_size' exceeds the limit.
+./test.c:146: warning: Metric 'std.code.length:total' for region 'bad_suppress_for_size' exceeds the limit.
 	Metric name    : std.code.length:total
 	Region name    : bad_suppress_for_size
 	Metric value   : 152

+ 9 - 0
mainline/tests/general/test_std_suppress/test_basic_limit_size_nosup_stdout.gold.txt

@@ -0,0 +1,9 @@
+./test.c:0: warning: Metric 'std.general:size' exceeds the limit.
+	Metric name    : std.general:size
+	Region name    : None
+	Metric value   : 3016
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+

+ 0 - 0
mainline/tests/general/test_std_suppress/test_basic_limit_size_stdout.gold.txt


+ 8 - 4
mainline/tools/limit.py

@@ -143,7 +143,7 @@ def main(tool_args):
                 
                 exit_code += 1
                 region_cursor = 0
-                region_name = ""
+                region_name = None
                 if select_data.get_region() != None:
                     region_cursor = select_data.get_region().cursor
                     region_name = select_data.get_region().name
@@ -189,8 +189,9 @@ def is_metric_suppressed(metric_namespace, metric_field, loader, select_data):
     data = loader.load_file_data(select_data.get_path())
     if select_data.get_region() != None:
         data = data.get_region(select_data.get_region().get_id())
-    
-    sup_data = data.get_data('std.suppress', 'list')
+        sup_data = data.get_data('std.suppress', 'list')
+    else:
+        sup_data = data.get_data('std.suppress.file', 'list')
     if sup_data != None and sup_data.find('[' + metric_namespace + ':' + metric_field + ']') != -1:
         return True
     return False
@@ -198,7 +199,10 @@ def is_metric_suppressed(metric_namespace, metric_field, loader, select_data):
 def report_limit_exceeded(path, cursor, namespace, field, region_name,
                           stat_level, trend_value, stat_limit,
                           is_modified, is_suppressed):
-    message = "Metric '" + namespace + ":" + field + "' for region '" + region_name + "' exceeds the limit."
+    if region_name != None:
+        message = "Metric '" + namespace + ":" + field + "' for region '" + region_name + "' exceeds the limit."
+    else:
+        message = "Metric '" + namespace + ":" + field + "' exceeds the limit."
     details = [("Metric name", namespace + ":" + field),
                ("Region name", region_name),
                ("Metric value", stat_level),