From a24b3303087c81135f7e2222adcbd014b988abac Mon Sep 17 00:00:00 2001 From: xusheng Date: Tue, 27 Oct 2020 17:03:33 +0800 Subject: support packaging/unpacking bndb files --- suite/generator.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'suite/generator.py') diff --git a/suite/generator.py b/suite/generator.py index 12072f32..63ae64ff 100755 --- a/suite/generator.py +++ b/suite/generator.py @@ -261,12 +261,20 @@ def generate(test_store, outdir, exclude_binaries): allfiles = sorted(testcommon.get_file_list(test_store)) for progress, testfile in enumerate(allfiles): oraclefile = None + zip_only = False if testfile.endswith(".gitignore"): continue if testfile.endswith(".pkl"): continue elif testfile.endswith(".DS_Store"): continue + elif testfile.endswith(".bndb"): + # For databases, we do not wish to create oracle data for them + # However, we do wish them to be zipped + zip_only = True + oraclefile = testfile + elif testfile.endswith(".bndb.zip"): + continue elif testfile.endswith(".zip"): # We have a zipped binary unzip it so we can rebaseline with zipfile.ZipFile(testfile, "r") as zf: @@ -282,6 +290,15 @@ def generate(test_store, outdir, exclude_binaries): # We have a binary that isn't zipped use it as a new test case oraclefile = testfile + # create the zip archive for the file + if not os.path.exists(oraclefile + ".zip"): + with zipfile.ZipFile(oraclefile + ".zip", "w") as zf: + zf.write(oraclefile, os.path.relpath(oraclefile, start=os.path.dirname(__file__))) + + if zip_only: + os.unlink(oraclefile) + continue + oraclefile_rel = os.path.relpath(oraclefile, start=os.path.dirname(__file__)) # Now generate the oracle data @@ -306,10 +323,6 @@ def generate(test_store, outdir, exclude_binaries): binary_oracle.add_entry(test_data, method) binary_oracle.close() - if not os.path.exists(oraclefile + ".zip"): - with zipfile.ZipFile(oraclefile + ".zip", "w") as zf: - zf.write(oraclefile, os.path.relpath(oraclefile, start=os.path.dirname(__file__))) - os.unlink(oraclefile) update_progress(len(allfiles), len(allfiles), "Generating binary unit tests complete", True) -- cgit v1.3.1