소스 검색

Correct output for float using format() instead of str(). Update gold files

Emmanuel Olivi 2 년 전
부모
커밋
9f51b37c2e

+ 1 - 1
metrixpp/ext/std/tools/view.py

@@ -544,7 +544,7 @@ def cout_txt_regions(path, regions, indent = 0):
                 if field == '__diff__':
                     continue
                 if field in list(diff_data.keys()):
-                    diff_str = " [" + ("+" if diff_data[field] >= 0 else "") + str(diff_data[field]) + "]"
+                    diff_str = " [" + ("+" if diff_data[field] >= 0 else "") + "{0:.3g}".format(diff_data[field]) + "]"
                 details.append((namespace + ":" + field, str(region['data'][namespace][field]) + diff_str))
         cout.notify(path,
                         region['info']['cursor'],

+ 4 - 4
metrixpp/tests/common.py

@@ -96,9 +96,9 @@ class ToolRunner(object):
                 f.close()
 
         # Match with gold        
-        self.is_stdout_matched = self.inetrnal_compare_with_gold(child_stdout, gold_file_stdout, real_file_stdout, diff_file_stdout)
+        self.is_stdout_matched = self.internal_compare_with_gold(child_stdout, gold_file_stdout, real_file_stdout, diff_file_stdout)
         if self.stderr_lines != None:
-            self.is_stderr_matched = self.inetrnal_compare_with_gold(child_stderr, gold_file_stderr, real_file_stderr, diff_file_stderr, self.stderr_lines)
+            self.is_stderr_matched = self.internal_compare_with_gold(child_stderr, gold_file_stderr, real_file_stderr, diff_file_stderr, self.stderr_lines)
         else:
             self.is_stderr_matched = None
             if self.is_stdout_matched == False:
@@ -114,7 +114,7 @@ class ToolRunner(object):
             shutil.copy2(self.dbfile, self.dbfile_prev)                
         return self
 
-    def inetrnal_compare_with_gold(self, text, gold_file, real_file, diff_file, lines = None):
+    def internal_compare_with_gold(self, text, gold_file, real_file, diff_file, lines = None):
         if os.path.exists(gold_file) == False:
             self.message += "\nGold file does not exist: " + gold_file
             return False
@@ -123,7 +123,7 @@ class ToolRunner(object):
         gold_text = f.read();
         f.close()
         
-        # don't compare dictionaries as string - they are not in order... (test case failes sometimes)
+        # don't compare dictionaries as string - they are not in order... (test case fails sometimes)
         try:
             textDict = ast.literal_eval(str(text.decode('ascii')))
             goldDict = ast.literal_eval(str(gold_text))

+ 8 - 6
metrixpp/tests/general/test_basic/test_help_limit_default_stdout.gold.txt

@@ -35,9 +35,10 @@ Options:
                         select regions, which have got metric value less than
                         the specified limit. This option can be specified
                         multiple times, if it is necessary to apply several
-                        limits. Should be in the format: <namespace>:<field
-                        >:<limit-value>[:region_type[,region_type]], for
-                        example: 'std.code.lines:comments:1', or
+                        limits. Should be in the format:
+                        <namespace>:<field>:<limit-
+                        value>[:region_type[,region_type]], for example:
+                        'std.code.lines:comments:1', or
                         'std.code.lines:comments:1:function,class'. Region
                         types is optional specifier, and if not defined the
                         limit is applied to regions of all types.
@@ -46,9 +47,10 @@ Options:
                         select regions, which have got metric value more than
                         the specified limit. This option can be specified
                         multiple times, if it is necessary to apply several
-                        limits. Should be in the format: <namespace>:<field
-                        >:<limit-value>[:region_type[,region_type]], for
-                        example: 'std.code.complexity:cyclomatic:7', or
+                        limits. Should be in the format:
+                        <namespace>:<field>:<limit-
+                        value>[:region_type[,region_type]], for example:
+                        'std.code.complexity:cyclomatic:7', or
                         'std.code.complexity:maxdepth:5:function'. Region
                         types is optional specifier, and if not defined the
                         limit is applied to regions of all types.

+ 1 - 1
metrixpp/tests/general/test_basic/test_view_format_view_python_stdout.gold.txt

@@ -1 +1 @@
-{'view': [{'data': {'info': {'path': './', 'id': 1}, 'file-data': {}, 'subfiles': [u'file_deleted_in_new_sources.cpp', u'simple.cpp'], 'subdirs': [], 'aggregated-data': {'std.code.complexity': {'cyclomatic': {'count': 8, 'nonzero': False, 'avg': 1.375, 'min': 1, 'max': 3, 'distribution-bars': [{'count': 6, 'ratio': 0.75, 'metric': '1'}, {'count': 1, 'ratio': 0.125, 'metric': '2'}, {'count': 1, 'ratio': 0.125, 'metric': '3'}], 'sup': 0, 'total': 11.0}}}}}]}
+{'view': [{'data': {'info': {'path': './', 'id': 1}, 'aggregated-data': {'std.code.complexity': {'cyclomatic': {'max': 3, 'min': 1, 'avg': 1.375, 'total': 11.0, 'count': 8, 'nonzero': False, 'distribution-bars': [{'count': 6, 'ratio': 0.75, 'metric': '1'}, {'count': 1, 'ratio': 0.125, 'metric': '2'}, {'count': 1, 'ratio': 0.125, 'metric': '3'}], 'sup': 0}}}, 'file-data': {}, 'subdirs': [], 'subfiles': ['file_deleted_in_new_sources.cpp', 'simple.cpp']}}]}

+ 6 - 6
metrixpp/tests/general/test_basic/test_workflow_view_second_per_file_txt_all_stdout.gold.txt

@@ -8,7 +8,7 @@
 	std.code.lines:comments: 0 [+0]
 	std.code.lines:preprocessor: 0 [+0]
 	std.code.lines:total: 0 [+0]
-	std.code.ratio:comments: 0.0 [+0.0]
+	std.code.ratio:comments: 0.0 [+0]
 
 ./simple.cpp:4: info: Metrics per 'hmm' region
 	Region name    : hmm
@@ -20,7 +20,7 @@
 	std.code.lines:comments: 1 [+0]
 	std.code.lines:preprocessor: 2 [+1]
 	std.code.lines:total: 7 [+1]
-	std.code.ratio:comments: 0.2 [+0.0]
+	std.code.ratio:comments: 0.2 [+0]
 
 ./simple.cpp:10: info: Metrics per 'A' region
 	Region name    : A
@@ -32,7 +32,7 @@
 	std.code.lines:comments: 0 [+0]
 	std.code.lines:preprocessor: 0 [+0]
 	std.code.lines:total: 4 [-16]
-	std.code.ratio:comments: 0.0 [+0.0]
+	std.code.ratio:comments: 0.0 [+0]
 
 ./simple.cpp:13: info: Metrics per 'A' region
 	Region name    : A
@@ -45,7 +45,7 @@
 	std.code.lines:comments: 2 [+0]
 	std.code.lines:preprocessor: 0 [+0]
 	std.code.lines:total: 12 [+0]
-	std.code.ratio:comments: 0.153 [+0.0]
+	std.code.ratio:comments: 0.153 [+0]
 
 ./simple.cpp:26: info: Metrics per 'func' region
 	Region name    : func
@@ -58,7 +58,7 @@
 	std.code.lines:comments: 0 [+0]
 	std.code.lines:preprocessor: 0 [+0]
 	std.code.lines:total: 5 [+0]
-	std.code.ratio:comments: 0.0 [+0.0]
+	std.code.ratio:comments: 0.0 [+0]
 
 ./simple.cpp:28: info: Metrics per 'embeded' region
 	Region name    : embeded
@@ -70,7 +70,7 @@
 	std.code.lines:comments: 0 [+0]
 	std.code.lines:preprocessor: 0 [+0]
 	std.code.lines:total: 3 [+0]
-	std.code.ratio:comments: 0.0 [+0.0]
+	std.code.ratio:comments: 0.0 [+0]
 
 ./simple.cpp:30: info: Metrics per 'embeded' region
 	Region name    : embeded

+ 6 - 6
metrixpp/tests/general/test_basic/test_workflow_view_second_per_file_txt_new_stdout.gold.txt

@@ -8,7 +8,7 @@
 	std.code.lines:comments: 0 [+0]
 	std.code.lines:preprocessor: 0 [+0]
 	std.code.lines:total: 0 [+0]
-	std.code.ratio:comments: 0.0 [+0.0]
+	std.code.ratio:comments: 0.0 [+0]
 
 ./simple.cpp:4: info: Metrics per 'hmm' region
 	Region name    : hmm
@@ -20,7 +20,7 @@
 	std.code.lines:comments: 1 [+0]
 	std.code.lines:preprocessor: 2 [+1]
 	std.code.lines:total: 7 [+1]
-	std.code.ratio:comments: 0.2 [+0.0]
+	std.code.ratio:comments: 0.2 [+0]
 
 ./simple.cpp:10: info: Metrics per 'A' region
 	Region name    : A
@@ -32,7 +32,7 @@
 	std.code.lines:comments: 0 [+0]
 	std.code.lines:preprocessor: 0 [+0]
 	std.code.lines:total: 4 [-16]
-	std.code.ratio:comments: 0.0 [+0.0]
+	std.code.ratio:comments: 0.0 [+0]
 
 ./simple.cpp:13: info: Metrics per 'A' region
 	Region name    : A
@@ -45,7 +45,7 @@
 	std.code.lines:comments: 2 [+0]
 	std.code.lines:preprocessor: 0 [+0]
 	std.code.lines:total: 12 [+0]
-	std.code.ratio:comments: 0.153 [+0.0]
+	std.code.ratio:comments: 0.153 [+0]
 
 ./simple.cpp:26: info: Metrics per 'func' region
 	Region name    : func
@@ -58,7 +58,7 @@
 	std.code.lines:comments: 0 [+0]
 	std.code.lines:preprocessor: 0 [+0]
 	std.code.lines:total: 5 [+0]
-	std.code.ratio:comments: 0.0 [+0.0]
+	std.code.ratio:comments: 0.0 [+0]
 
 ./simple.cpp:28: info: Metrics per 'embeded' region
 	Region name    : embeded
@@ -70,7 +70,7 @@
 	std.code.lines:comments: 0 [+0]
 	std.code.lines:preprocessor: 0 [+0]
 	std.code.lines:total: 3 [+0]
-	std.code.ratio:comments: 0.0 [+0.0]
+	std.code.ratio:comments: 0.0 [+0]
 
 ./simple.cpp:30: info: Metrics per 'embeded' region
 	Region name    : embeded

+ 6 - 6
metrixpp/tests/general/test_basic/test_workflow_view_second_per_file_txt_touched_stdout.gold.txt

@@ -8,7 +8,7 @@
 	std.code.lines:comments: 0 [+0]
 	std.code.lines:preprocessor: 0 [+0]
 	std.code.lines:total: 0 [+0]
-	std.code.ratio:comments: 0.0 [+0.0]
+	std.code.ratio:comments: 0.0 [+0]
 
 ./simple.cpp:4: info: Metrics per 'hmm' region
 	Region name    : hmm
@@ -20,7 +20,7 @@
 	std.code.lines:comments: 1 [+0]
 	std.code.lines:preprocessor: 2 [+1]
 	std.code.lines:total: 7 [+1]
-	std.code.ratio:comments: 0.2 [+0.0]
+	std.code.ratio:comments: 0.2 [+0]
 
 ./simple.cpp:10: info: Metrics per 'A' region
 	Region name    : A
@@ -32,7 +32,7 @@
 	std.code.lines:comments: 0 [+0]
 	std.code.lines:preprocessor: 0 [+0]
 	std.code.lines:total: 4 [-16]
-	std.code.ratio:comments: 0.0 [+0.0]
+	std.code.ratio:comments: 0.0 [+0]
 
 ./simple.cpp:13: info: Metrics per 'A' region
 	Region name    : A
@@ -45,7 +45,7 @@
 	std.code.lines:comments: 2 [+0]
 	std.code.lines:preprocessor: 0 [+0]
 	std.code.lines:total: 12 [+0]
-	std.code.ratio:comments: 0.153 [+0.0]
+	std.code.ratio:comments: 0.153 [+0]
 
 ./simple.cpp:26: info: Metrics per 'func' region
 	Region name    : func
@@ -58,7 +58,7 @@
 	std.code.lines:comments: 0 [+0]
 	std.code.lines:preprocessor: 0 [+0]
 	std.code.lines:total: 5 [+0]
-	std.code.ratio:comments: 0.0 [+0.0]
+	std.code.ratio:comments: 0.0 [+0]
 
 ./simple.cpp:28: info: Metrics per 'embeded' region
 	Region name    : embeded
@@ -70,7 +70,7 @@
 	std.code.lines:comments: 0 [+0]
 	std.code.lines:preprocessor: 0 [+0]
 	std.code.lines:total: 3 [+0]
-	std.code.ratio:comments: 0.0 [+0.0]
+	std.code.ratio:comments: 0.0 [+0]
 
 ./simple.cpp:30: info: Metrics per 'embeded' region
 	Region name    : embeded