Browse Source

tests for suppress plugin

avkonst 11 years ago
parent
commit
f8554b8e2c

+ 2 - 2
mainline/tests/general/test_basic/test_help_limit_default_stdout.gold.txt

@@ -42,8 +42,8 @@ Options:
   --hotspots=HOTSPOTS, --hs=HOTSPOTS
   --hotspots=HOTSPOTS, --hs=HOTSPOTS
                         If not set (none), all exceeded limits are printed. If
                         If not set (none), all exceeded limits are printed. If
                         set, exceeded limits are sorted (the worst is the
                         set, exceeded limits are sorted (the worst is the
-                        first) and only first GENERAL.HOTSPOTS limits are
-                        printed. [default: none]
+                        first) and only first HOTSPOTS limits are printed.
+                        [default: none]
   --disable-suppressions, --ds
   --disable-suppressions, --ds
                         If not set (none), all suppressions are ignored and
                         If not set (none), all suppressions are ignored and
                         associated warnings are printed. [default: False]
                         associated warnings are printed. [default: False]

+ 14 - 6
mainline/tests/general/test_std_suppress.py

@@ -34,24 +34,32 @@ class Test(tests.common.TestCase):
 
 
         runner = tests.common.ToolRunner('limit',
         runner = tests.common.ToolRunner('limit',
                                          ['--max-limit=std.code.complexity:cyclomatic:0'],
                                          ['--max-limit=std.code.complexity:cyclomatic:0'],
-                                         exit_code=1)
+                                         exit_code=1,
+                                         prefix='1')
+        self.assertExec(runner.run())
 
 
         runner = tests.common.ToolRunner('limit',
         runner = tests.common.ToolRunner('limit',
                                          ['--max-limit=std.code.complexity:cyclomatic:0', '--disable-suppressions'],
                                          ['--max-limit=std.code.complexity:cyclomatic:0', '--disable-suppressions'],
-                                         exit_code=8)
+                                         exit_code=8,
+                                         prefix='2')
+        self.assertExec(runner.run())
 
 
         runner = tests.common.ToolRunner('limit',
         runner = tests.common.ToolRunner('limit',
                                          ['--max-limit=std.code.length:size:0'],
                                          ['--max-limit=std.code.length:size:0'],
-                                         exit_code=7)
+                                         exit_code=7,
+                                         prefix='3')
+        self.assertExec(runner.run())
 
 
         runner = tests.common.ToolRunner('limit',
         runner = tests.common.ToolRunner('limit',
                                          ['--max-limit=std.code.length:size:0', '--disable-suppressions'],
                                          ['--max-limit=std.code.length:size:0', '--disable-suppressions'],
-                                         exit_code=24)
+                                         exit_code=24,
+                                         prefix='4')
+        self.assertExec(runner.run())
 
 
         runner = tests.common.ToolRunner('limit',
         runner = tests.common.ToolRunner('limit',
                                          ['--max-limit=std.code.complexity:cyclomatic:0', '--max-limit=std.code.length:size:0'],
                                          ['--max-limit=std.code.complexity:cyclomatic:0', '--max-limit=std.code.length:size:0'],
-                                         exit_code=8)
-        
+                                         exit_code=8,
+                                         prefix='5')
         self.assertExec(runner.run())
         self.assertExec(runner.run())
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':

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

@@ -0,0 +1,16 @@
+./test.c:82: 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
+	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
+	Metric name    : invalid:metric
+	Region name    : suppressed_for_size_and_invalid_metric
+
+./test.c:103: warning: Suppressed metric 'invalid:metric' is not being collected
+	Metric name    : invalid:metric
+	Region name    : suppressed_for_size_and_complexity_and_invalid_metric
+

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

@@ -0,0 +1,9 @@
+./test.c:122: 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
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+

+ 72 - 0
mainline/tests/general/test_std_suppress/test_basic_limit_2_stdout.gold.txt

@@ -0,0 +1,72 @@
+./test.c:103: 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
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:110: warning: Metric 'std.code.complexity:cyclomatic' for region 'func7' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
+	Region name    : func7
+	Metric value   : 1
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:116: 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
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:122: 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
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:130: warning: Metric 'std.code.complexity:cyclomatic' for region 'func8' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
+	Region name    : func8
+	Metric value   : 1
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:138: warning: Metric 'std.code.complexity:cyclomatic' for region 'func9' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
+	Region name    : func9
+	Metric value   : 1
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:144: 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
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:154: warning: Metric 'std.code.complexity:cyclomatic' for region 'func10' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
+	Region name    : func10
+	Metric value   : 1
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+

+ 63 - 0
mainline/tests/general/test_std_suppress/test_basic_limit_3_stdout.gold.txt

@@ -0,0 +1,63 @@
+./test.c:54: warning: Metric 'std.code.length:size' for region 'no_suppress_cl' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : no_suppress_cl
+	Metric value   : 44
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:60: warning: Metric 'std.code.length:size' for region 'nu_suppress_func' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : nu_suppress_func
+	Metric value   : 63
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:75: warning: Metric 'std.code.length:size' for region 'func_no_suppress_within_struct' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : func_no_suppress_within_struct
+	Metric value   : 43
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:82: warning: Metric 'std.code.length:size' for region 'suppresed_for_invalid_metric' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : suppresed_for_invalid_metric
+	Metric value   : 80
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:88: warning: Metric 'std.code.length:size' for region 'suppresed_for_invalid_metric' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : suppresed_for_invalid_metric
+	Metric value   : 96
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:116: warning: Metric 'std.code.length:size' for region 'nu_suppress_for_size' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : nu_suppress_for_size
+	Metric value   : 105
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:144: warning: Metric 'std.code.length:size' for region 'bad_suppress_for_size' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : bad_suppress_for_size
+	Metric value   : 151
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+

+ 216 - 0
mainline/tests/general/test_std_suppress/test_basic_limit_4_stdout.gold.txt

@@ -0,0 +1,216 @@
+./test.c:0: warning: Metric 'std.code.length:size' for region '__global__' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : __global__
+	Metric value   : 138
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:8: warning: Metric 'std.code.length:size' for region 'func' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : func
+	Metric value   : 78
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:13: warning: Metric 'std.code.length:size' for region 'func2' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : func2
+	Metric value   : 60
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:19: warning: Metric 'std.code.length:size' for region 'func3' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : func3
+	Metric value   : 107
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:28: warning: Metric 'std.code.length:size' for region 'func4' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : func4
+	Metric value   : 135
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:34: warning: Metric 'std.code.length:size' for region 'cl1' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : cl1
+	Metric value   : 61
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:39: warning: Metric 'std.code.length:size' for region 'cl2' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : cl2
+	Metric value   : 61
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:48: warning: Metric 'std.code.length:size' for region 'cl3' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : cl3
+	Metric value   : 79
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:54: warning: Metric 'std.code.length:size' for region 'no_suppress_cl' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : no_suppress_cl
+	Metric value   : 44
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:60: warning: Metric 'std.code.length:size' for region 'nu_suppress_func' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : nu_suppress_func
+	Metric value   : 63
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:65: warning: Metric 'std.code.length:size' for region 'cl2' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : cl2
+	Metric value   : 77
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:70: warning: Metric 'std.code.length:size' for region 'func4' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : func4
+	Metric value   : 78
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:75: warning: Metric 'std.code.length:size' for region 'func_no_suppress_within_struct' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : func_no_suppress_within_struct
+	Metric value   : 43
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:82: warning: Metric 'std.code.length:size' for region 'suppresed_for_invalid_metric' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : suppresed_for_invalid_metric
+	Metric value   : 80
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:88: warning: Metric 'std.code.length:size' for region 'suppresed_for_invalid_metric' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : suppresed_for_invalid_metric
+	Metric value   : 96
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:95: warning: Metric 'std.code.length:size' for region 'suppressed_for_size_and_invalid_metric' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : suppressed_for_size_and_invalid_metric
+	Metric value   : 136
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:103: warning: Metric 'std.code.length:size' for region 'suppressed_for_size_and_complexity_and_invalid_metric' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : suppressed_for_size_and_complexity_and_invalid_metric
+	Metric value   : 221
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:110: warning: Metric 'std.code.length:size' for region 'func7' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : func7
+	Metric value   : 139
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:116: warning: Metric 'std.code.length:size' for region 'nu_suppress_for_size' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : nu_suppress_for_size
+	Metric value   : 105
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:122: warning: Metric 'std.code.length:size' for region 'no_suppress_for_cyclomatic_complexity' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : no_suppress_for_cyclomatic_complexity
+	Metric value   : 112
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:130: warning: Metric 'std.code.length:size' for region 'func8' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : func8
+	Metric value   : 174
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:138: warning: Metric 'std.code.length:size' for region 'func9' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : func9
+	Metric value   : 183
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+
+./test.c:144: warning: Metric 'std.code.length:size' for region 'bad_suppress_for_size' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : bad_suppress_for_size
+	Metric value   : 151
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:154: warning: Metric 'std.code.length:size' for region 'func10' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : func10
+	Metric value   : 178
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : True
+

+ 72 - 0
mainline/tests/general/test_std_suppress/test_basic_limit_5_stdout.gold.txt

@@ -0,0 +1,72 @@
+./test.c:122: 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
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:54: warning: Metric 'std.code.length:size' for region 'no_suppress_cl' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : no_suppress_cl
+	Metric value   : 44
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:60: warning: Metric 'std.code.length:size' for region 'nu_suppress_func' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : nu_suppress_func
+	Metric value   : 63
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:75: warning: Metric 'std.code.length:size' for region 'func_no_suppress_within_struct' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : func_no_suppress_within_struct
+	Metric value   : 43
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:82: warning: Metric 'std.code.length:size' for region 'suppresed_for_invalid_metric' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : suppresed_for_invalid_metric
+	Metric value   : 80
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:88: warning: Metric 'std.code.length:size' for region 'suppresed_for_invalid_metric' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : suppresed_for_invalid_metric
+	Metric value   : 96
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:116: warning: Metric 'std.code.length:size' for region 'nu_suppress_for_size' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : nu_suppress_for_size
+	Metric value   : 105
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+
+./test.c:144: warning: Metric 'std.code.length:size' for region 'bad_suppress_for_size' exceeds the limit.
+	Metric name    : std.code.length:size
+	Region name    : bad_suppress_for_size
+	Metric value   : 151
+	Modified       : None
+	Change trend   : None
+	Limit          : 0.0
+	Suppressed     : False
+