Skip to content
Snippets Groups Projects
Commit 0ec4c58e authored by Sebastien Ponce's avatar Sebastien Ponce
Browse files

Optimized test suite by recreating directories only once, and not everytime we use a file

parent f34049b1
No related branches found
No related tags found
No related merge requests found
......@@ -25,7 +25,6 @@ def _setFileClass(self, path, fileclass):
assert len(output) == 0, \
'Failed to set FileClass ' + fileclass + \
' on directory ' + path + os.linesep + "Error :" + os.linesep + output
return path
Setup._setFileClass = _setFileClass
def _addACLforUnprivUser(self, path):
......@@ -41,14 +40,14 @@ def _addACLforUnprivUser(self, path):
assert len(output) == 0, \
'Failed to set ACLs for user ' + self.options.get('Tags', 'unprivUid') + \
' on working directory ' + path + os.linesep + "Error :" + os.linesep + output
return path
Setup._addACLforUnprivUser = _addACLforUnprivUser
def _configuredPath(self, test, fileclass):
# create the directory and configure it
path = self._createDir(self.getTag(test, '_testSessionPath') + os.sep + test)
path = self._setFileClass(path, fileclass)
path = self._addACLforUnprivUser(path)
path, created = self._createDir(self.getTag(test, '_testSessionPath') + os.sep + test)
if created:
self._setFileClass(path, fileclass)
self._addACLforUnprivUser(path)
return path
Setup._configuredPath = _configuredPath
......
......@@ -24,17 +24,20 @@ def _createDir(self, path):
# create the path in the namespace
output = Popen('nsmkdir ' + path)
# check it went fine
assert len(output) == 0 or output.find('File exists'), \
assert len(output) == 0 or output.find('File exists') >= 0, \
'Failed to create working directory ' + path + os.linesep + "Error :" + os.linesep + output
# return the created dir
return path
if output.find('File exists') >= 0:
return (path, False)
else:
return (path, True)
Setup._createDir = _createDir
def _testSessionPath(self):
# get the test path
testpath = self.options.get('Generic','CastorTestDir')
# create a unique directory
return self._createDir(testpath + os.sep + self.getTag(None, 'sessionuuid'))
return self._createDir(testpath + os.sep + self.getTag(None, 'sessionuuid'))[0]
Setup.getTag__testSessionPath = _testSessionPath
def nsDir(self):
......@@ -42,7 +45,7 @@ def nsDir(self):
Setup.getTag_nsDir = nsDir
def nsFile(self, nb=0):
return (lambda test : self._createDir(self.getTag(test, 'nsDir')) + \
return (lambda test : self._createDir(self.getTag(test, 'nsDir'))[0] + \
os.sep + test + str(nb))
Setup.getTag_nsFile = nsFile
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment