test-bugzilla-files/new-control.py         |   28 ++++++++++++++++++++++++++++
 test-bugzilla-files/test-bugzilla-files.py |   25 ++++---------------------
 2 files changed, 32 insertions(+), 21 deletions(-)

New commits:
commit d7224055ba764836a6984afabd21853a6eed8fa4
Author:     Gülşah Köse <gulsah.k...@collabora.com>
AuthorDate: Mon Sep 6 18:46:39 2021 +0300
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Sep 7 08:23:09 2021 +0200

    Move previous dir handling out of the thread.
    
    Change-Id: I6fcd7f9e160975eb7730d87a9a667916ec934d5a
    Reviewed-on: https://gerrit.libreoffice.org/c/dev-tools/+/121582
    Tested-by: Miklos Vajna <vmik...@collabora.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/test-bugzilla-files/new-control.py 
b/test-bugzilla-files/new-control.py
index 79913bc..6807d8e 100644
--- a/test-bugzilla-files/new-control.py
+++ b/test-bugzilla-files/new-control.py
@@ -23,6 +23,7 @@ import time
 import subprocess
 import getopt
 import sys
+from shutil import copyfile, rmtree
 
 def partition(l, n):
     for i in range(0, len(l), n):
@@ -52,6 +53,30 @@ def execute_task(task_file, asan):
         subprocess.call("./execute.sh " + task_file, shell=True)
     time.sleep(1)
 
+def saveAsPreviousState(exported_files):
+    odf_file_ext = ['odt']
+    previous_path = "/srv/crashtestdata/previous/srv/crashtestdata/files/odt"
+    if os.path.exists(previous_path):
+        rmtree("/srv/crashtestdata/previous")
+    os.makedirs(previous_path)
+
+    for file in exported_files:
+        ext = file[-3:]
+        if ext in odf_file_ext and os.path.exists(file):
+            
os.makedirs(os.path.dirname("/srv/crashtestdata/previous"+file[26:]), 
exist_ok=True)
+            copyfile(file, "/srv/crashtestdata/previous"+file[26:])
+
+def get_list_of_files(directory_name):
+    list_of_file = os.listdir(directory_name)
+    all_files = list()
+    for filename in list_of_file:
+        full_path = os.path.join(directory_name, filename)
+        if os.path.isdir(full_path):
+            all_files = all_files + get_list_of_files(full_path)
+        else:
+            all_files.append(full_path)
+    return all_files
+
 def usage():
     message = """usage: {program} [option] dir"
  - h | --help: print usage information
@@ -96,3 +121,6 @@ if __name__ == "__main__":
                 print('%r generated an exception: %s' % (task, exc))
             else:
                 print('%r successfully passed' % (task))
+
+    exported_files = 
get_list_of_files("/srv/crashtestdata/current/srv/crashtestdata/files/odt/")
+    saveAsPreviousState(exported_files)
diff --git a/test-bugzilla-files/test-bugzilla-files.py 
b/test-bugzilla-files/test-bugzilla-files.py
index 82fba62..0ade4eb 100644
--- a/test-bugzilla-files/test-bugzilla-files.py
+++ b/test-bugzilla-files/test-bugzilla-files.py
@@ -33,7 +33,6 @@ import sys
 import time
 import uuid
 import datetime
-from shutil import copyfile, rmtree
 
 import signal
 import threading
@@ -394,28 +393,15 @@ def exportDoc(xDoc, filterName, validationCommand, 
filename, connection, timer):
         except subprocess.CalledProcessError:
             pass # ignore that exception
 
+def getODFunDiffCommand():
+    return os.environ["HOME"] + "/source/bin/odfundiff-exe"
+
 def isPreviousExist():
     previous_path = "/srv/crashtestdata/previous"
     if os.path.exists(previous_path):
         return True
     return False
 
-def saveAsPreviousState(exported_files):
-    odf_file_ext = ['odt']
-    previous_path = "/srv/crashtestdata/previous/srv/crashtestdata/files/odt"
-    if os.path.exists(previous_path):
-        rmtree("/srv/crashtestdata/previous")
-    os.makedirs(previous_path)
-
-    for file in exportedFiles:
-        ext = file[-3:]
-        if ext in odf_file_ext and 
os.path.exists("/srv/crashtestdata/current"+file):
-            os.makedirs(os.path.dirname("/srv/crashtestdata/previous"+file), 
exist_ok=True)
-            copyfile("/srv/crashtestdata/current"+file, 
"/srv/crashtestdata/previous"+file)
-
-def getODFunDiffCommand():
-    return os.environ["HOME"] + "/source/bin/odfundiff-exe"
-
 class ExportFileTest:
     def __init__(self, xDoc, filename, enable_validation, timer):
         self.xDoc = xDoc
@@ -675,9 +661,7 @@ if __name__ == "__main__":
         # Check the roundtripped files doesn't crash at import time
         runLoadFileTests(opts, exportedFiles, False)
 
-        if not isPreviousExist():
-            saveAsPreviousState(exportedFiles)
-        else:
+        if  isPreviousExist():
             for filename in exportedFiles:
                 if filename[-3:] == 'odt':
                     odfundiffCommandWithURL = getODFunDiffCommand() + " 
/srv/crashtestdata/previous" + filename + " /srv/crashtestdata/current" + 
filename
@@ -691,7 +675,6 @@ if __name__ == "__main__":
                             handleODFunDiff(filename)
                     except subprocess.CalledProcessError:
                         pass
-            saveAsPreviousState(exportedFiles)
     else:
         usage()
         sys.exit(1)

Reply via email to