13
13
from distutils.dir_util import remove_tree
14
14
from distutils.dist import Distribution
16
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'modules'))
16
project_dir = os.path.dirname(__file__)
17
modules_dir = os.path.join(project_dir, 'modules')
19
sys.path.insert(0, modules_dir)
20
sys.path.insert(0, project_dir)
22
from tests.common import TEST_DIR, TEST_DATA_DIR
24
################################################################################
27
description = 'run tests'
29
('tests=', None, 'names of tests to run'),
30
('print-only', None, "don't run tests, just print their names"),
33
def initialize_options(self):
35
self.print_only = False
37
def finalize_options(self):
38
if self.tests is not None:
39
self.tests = self.tests.split(',')
42
from tests import load, main, print_names
45
print_names(self.tests)
18
49
################################################################################
48
79
except (IOError, OSError):
49
80
log.warn("failed to remove '%s'" % dirname)
82
def clean_test_data(self):
83
status, output = commands.getstatusoutput(
84
'test -x $(which fusermount) && which fusermount')
86
umount_cmd = '%s -u' % output.strip()
88
status, output = commands.getstatusoutput(
89
'test -x $(which umount) && which umount')
91
umount_cmd = output.strip()
93
raise AssertionError("can't find a umount command")
95
test_tree_root = os.path.join(TEST_DIR, 'test-trees')
97
dirs = os.listdir(test_tree_root)
98
except (IOError, OSError):
100
"not cleaning '%s': failed to read directory" % test_tree_root)
103
full_dir = os.path.join(test_tree_root, dir)
104
mnt_dir = os.path.join(full_dir, 'mnt')
106
log.info("unmounting '%s'" % mnt_dir)
107
status, output = commands.getstatusoutput(
108
'%s %s' % (umount_cmd, mnt_dir))
110
print >>sys.stderr, output
112
self.clean_dir(full_dir)
114
os.rmdir(test_tree_root)
116
self.clean_dir(TEST_DATA_DIR)
119
self.clean_test_data()
52
121
remove_files = list(self.temporary_files)
54
123
remove_files = remove_files + self.nontemporary_files