Commit 251b10ec authored by Julien Muchembled's avatar Julien Muchembled

Unit tests: make --save more reliable if an empty 'unit_test/Xxx.bak' is removed

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33931 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f6ea216e
import errno
import os import os
import shutil import shutil
import sys import sys
...@@ -16,6 +17,15 @@ data_fs_path = os.environ.get('erp5_tests_data_fs_path', ...@@ -16,6 +17,15 @@ data_fs_path = os.environ.get('erp5_tests_data_fs_path',
load = int(os.environ.get('erp5_load_data_fs', 0)) load = int(os.environ.get('erp5_load_data_fs', 0))
save = int(os.environ.get('erp5_save_data_fs', 0)) save = int(os.environ.get('erp5_save_data_fs', 0))
_print("Cleaning static files ... ")
static_dir_list = 'Constraint', 'Document', 'PropertySheet', 'Extensions'
for dir in static_dir_list:
try:
shutil.rmtree(os.path.join(instance_home, dir))
except OSError, e:
if e.errno != errno.ENOENT:
raise
if load: if load:
dump_sql = os.path.join(instance_home, 'dump.sql') dump_sql = os.path.join(instance_home, 'dump.sql')
if os.path.exists(dump_sql): if os.path.exists(dump_sql):
...@@ -25,22 +35,12 @@ if load: ...@@ -25,22 +35,12 @@ if load:
else: else:
os.environ['erp5_tests_recreate_catalog'] = '1' os.environ['erp5_tests_recreate_catalog'] = '1'
_print("Restoring static files ... ") _print("Restoring static files ... ")
for dir in ('Constraint', 'Document', 'PropertySheet', 'Extensions'): for dir in static_dir_list:
if os.path.exists(os.path.join(instance_home, '%s.bak' % dir)):
full_path = os.path.join(instance_home, dir)
shutil.rmtree(full_path)
shutil.copytree(os.path.join(instance_home, '%s.bak' % dir),
full_path, symlinks=True)
else:
_print("Cleaning static files ... ")
for dir in ('Constraint', 'Document', 'PropertySheet', 'Extensions'):
full_path = os.path.join(instance_home, dir) full_path = os.path.join(instance_home, dir)
if os.path.exists(full_path): if os.path.exists(full_path + '.bak'):
assert os.path.isdir(full_path) shutil.copytree(full_path + '.bak', full_path, symlinks=True)
for f in glob.glob('%s/*' % full_path): elif save and os.path.exists(data_fs_path):
os.unlink(f) os.remove(data_fs_path)
if save and os.path.exists(data_fs_path):
os.remove(data_fs_path)
if save: if save:
Storage = FileStorage(data_fs_path) Storage = FileStorage(data_fs_path)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment