Browse Source

Fixed non-stable test.

avkonst 11 years ago
parent
commit
ee2d9c7a20

+ 6 - 1
mainline/core/dir.py

@@ -81,6 +81,10 @@ class DirectoryReader():
     
     def run(self, plugin, directory):
         
+        IS_TEST_MODE = False
+        if 'METRIXPLUSPLUS_TEST_MODE' in os.environ.keys():
+            IS_TEST_MODE = True
+        
         def run_per_file(plugin, fname, full_path):
             exit_code = 0
             norm_path = re.sub(r'''[\\]''', "/", full_path)
@@ -103,7 +107,8 @@ class DirectoryReader():
                         (data, is_updated) = plugin.get_plugin_loader().get_database_loader().create_file_data(norm_path, checksum, text)
                         procerrors = parser.process(plugin, data, is_updated)
                         if plugin.is_proctime_enabled == True:
-                            data.set_data('std.general', 'proctime', time.time() - ts)
+                            data.set_data('std.general', 'proctime',
+                                          (time.time() - ts) if IS_TEST_MODE == False else 0.01)
                         if plugin.is_procerrors_enabled == True and procerrors != None and procerrors != 0:
                             data.set_data('std.general', 'procerrors', procerrors)
                         if plugin.is_size_enabled == True:

+ 6 - 6
mainline/tests/general/test_basic/test_std_general_metrics_view_nest_per_file_stdout.gold.txt

@@ -106,7 +106,7 @@ data:
 .   .   .   .   .   .   .   .   .   .   data: 
 .   .   .   .   .   .   .   .   .   .   subregions:
 .   .   std.general: 
-.   .   .   proctime="0.0019998550415"
+.   .   .   proctime="0.01"
 .   .   .   size="487"
 .   subfiles:
 .   subdirs:
@@ -121,15 +121,15 @@ data:
 .   .   .   .   distribution-bars:
 .   .   .   proctime: 
 .   .   .   .   count="1"
-.   .   .   .   max="0.0019998550415"
-.   .   .   .   avg="0.0019998550415"
-.   .   .   .   total="0.0019998550415"
-.   .   .   .   min="0.0019998550415" 
+.   .   .   .   max="0.01"
+.   .   .   .   avg="0.01"
+.   .   .   .   total="0.01"
+.   .   .   .   min="0.01" 
 .   .   .   .   distribution-bars:
 .   .   .   .   
 .   .   .   .   .   distribution-bar: 
 .   .   .   .   .   .   count="1"
-.   .   .   .   .   .   metric="0.0019998550415"
+.   .   .   .   .   .   metric="0.01"
 .   .   .   .   .   .   ratio="1.0"
 .   .   .   size: 
 .   .   .   .   count="1"

+ 5 - 5
mainline/tests/general/test_basic/test_std_general_metrics_view_txt_stdout.gold.txt

@@ -22,15 +22,15 @@ data:
 .   .   .   .   distribution-bars:
 .   .   .   proctime: 
 .   .   .   .   count="1"
-.   .   .   .   max="0.0019998550415"
-.   .   .   .   avg="0.0019998550415"
-.   .   .   .   total="0.0019998550415"
-.   .   .   .   min="0.0019998550415" 
+.   .   .   .   max="0.01"
+.   .   .   .   avg="0.01"
+.   .   .   .   total="0.01"
+.   .   .   .   min="0.01" 
 .   .   .   .   distribution-bars:
 .   .   .   .   
 .   .   .   .   .   distribution-bar: 
 .   .   .   .   .   .   count="1"
-.   .   .   .   .   .   metric="0.0019998550415"
+.   .   .   .   .   .   metric="0.01"
 .   .   .   .   .   .   ratio="1.0"
 .   .   .   size: 
 .   .   .   .   count="1"

+ 1 - 0
mainline/tools/test.py

@@ -43,6 +43,7 @@ def main(tool_args):
     log_plugin.configure(options)
     
     os.environ['METRIXPLUSPLUS_TEST_GENERATE_GOLDS'] = str(options.__dict__['generate_golds'])
+    os.environ['METRIXPLUSPLUS_TEST_MODE'] = str("True")
     
     tests_dir = os.path.join(os.environ['METRIXPLUSPLUS_INSTALL_DIR'], 'tests')
     process_data= ["python", "-m", "unittest", "discover", "-v", "-s"]