зеркало из https://github.com/mozilla/gecko-dev.git
Bug 739753 - Fatal handling of invalid head and tail files in xpcshell test runner; r=ted
This commit is contained in:
Родитель
d3601149fe
Коммит
5bdd6a6a7c
|
@ -179,13 +179,26 @@ class XPCShellRemote(xpcshell.XPCShellTests, object):
|
|||
self.remoteDebuggerArgs,
|
||||
self.xpcsCmd]
|
||||
|
||||
def getHeadFiles(self, test):
|
||||
def getHeadAndTailFiles(self, test):
|
||||
"""Override parent method to find files on remote device."""
|
||||
def sanitize_list(s, kind):
|
||||
for f in s.strip().split(' '):
|
||||
f = f.strip()
|
||||
if len(f) < 1:
|
||||
continue
|
||||
|
||||
path = self.remoteJoin(self.remoteHere, f)
|
||||
if not self.device.fileExists(path):
|
||||
raise Exception('%s file does not exist: %s' % ( kind,
|
||||
path))
|
||||
|
||||
yield path
|
||||
|
||||
self.remoteHere = self.remoteForLocal(test['here'])
|
||||
return [f.strip() for f in sorted(test['head'].split(' ')) if self.device.fileExists(self.remoteJoin(self.remoteHere, f))]
|
||||
|
||||
def getTailFiles(self, test):
|
||||
return [f.strip() for f in sorted(test['tail'].split(' ')) if self.device.fileExists(self.remoteJoin(self.remoteHere, f))]
|
||||
|
||||
|
||||
return (list(sanitize_list(test['head'], 'head')),
|
||||
list(sanitize_list(test['tail'], 'tail')))
|
||||
|
||||
def buildCmdTestFile(self, name):
|
||||
remoteDir = self.remoteForLocal(os.path.dirname(name))
|
||||
if remoteDir == self.remoteHere:
|
||||
|
|
|
@ -254,24 +254,29 @@ class XPCShellTests(object):
|
|||
# Simply remove optional ending separator.
|
||||
self.testPath = self.testPath.rstrip("/")
|
||||
|
||||
def getHeadAndTailFiles(self, test):
|
||||
"""Obtain the list of head and tail files.
|
||||
|
||||
def getHeadFiles(self, test):
|
||||
"""
|
||||
test['head'] is a whitespace delimited list of head files.
|
||||
return the list of head files as paths including the subdir if the head file exists
|
||||
Returns a 2-tuple. The first element is a list of head files. The second
|
||||
is a list of tail files.
|
||||
"""
|
||||
def sanitize_list(s, kind):
|
||||
for f in s.strip().split(' '):
|
||||
f = f.strip()
|
||||
if len(f) < 1:
|
||||
continue
|
||||
|
||||
On a remote system, this may be overloaded to list files in a remote directory structure.
|
||||
"""
|
||||
return [os.path.join(test['here'], f).strip() for f in sorted(test['head'].split(' ')) if os.path.isfile(os.path.join(test['here'], f))]
|
||||
path = os.path.normpath(os.path.join(test['here'], f))
|
||||
if not os.path.exists(path):
|
||||
raise Exception('%s file does not exist: %s' % (kind, path))
|
||||
|
||||
def getTailFiles(self, test):
|
||||
"""
|
||||
test['tail'] is a whitespace delimited list of head files.
|
||||
return the list of tail files as paths including the subdir if the tail file exists
|
||||
if not os.path.isfile(path):
|
||||
raise Exception('%s file is not a file: %s' % (kind, path))
|
||||
|
||||
On a remote system, this may be overloaded to list files in a remote directory structure.
|
||||
"""
|
||||
return [os.path.join(test['here'], f).strip() for f in sorted(test['tail'].split(' ')) if os.path.isfile(os.path.join(test['here'], f))]
|
||||
yield path
|
||||
|
||||
return (list(sanitize_list(test['head'], 'head')),
|
||||
list(sanitize_list(test['tail'], 'tail')))
|
||||
|
||||
def setupProfileDir(self):
|
||||
"""
|
||||
|
@ -637,8 +642,7 @@ class XPCShellTests(object):
|
|||
|
||||
testdir = os.path.dirname(name)
|
||||
self.buildXpcsCmd(testdir)
|
||||
testHeadFiles = self.getHeadFiles(test)
|
||||
testTailFiles = self.getTailFiles(test)
|
||||
testHeadFiles, testTailFiles = self.getHeadAndTailFiles(test)
|
||||
cmdH = self.buildCmdHead(testHeadFiles, testTailFiles, self.xpcsCmd)
|
||||
|
||||
# create a temp dir that the JS harness can stick a profile in
|
||||
|
|
|
@ -212,6 +212,41 @@ tail =
|
|||
self.assertInLog("TEST-UNEXPECTED-FAIL")
|
||||
self.assertNotInLog("TEST-PASS")
|
||||
|
||||
def testMissingHeadFile(self):
|
||||
"""
|
||||
Ensure that missing head file results in fatal error.
|
||||
"""
|
||||
self.writeFile("test_basic.js", SIMPLE_PASSING_TEST)
|
||||
self.writeManifest([("test_basic.js", "head = missing.js")])
|
||||
|
||||
raised = False
|
||||
|
||||
try:
|
||||
# The actual return value is never checked because we raise.
|
||||
self.assertTestResult(True)
|
||||
except Exception, ex:
|
||||
raised = True
|
||||
self.assertEquals(ex.message[0:9], "head file")
|
||||
|
||||
self.assertTrue(raised)
|
||||
|
||||
def testMissingTailFile(self):
|
||||
"""
|
||||
Ensure that missing tail file results in fatal error.
|
||||
"""
|
||||
self.writeFile("test_basic.js", SIMPLE_PASSING_TEST)
|
||||
self.writeManifest([("test_basic.js", "tail = missing.js")])
|
||||
|
||||
raised = False
|
||||
|
||||
try:
|
||||
self.assertTestResult(True)
|
||||
except Exception, ex:
|
||||
raised = True
|
||||
self.assertEquals(ex.message[0:9], "tail file")
|
||||
|
||||
self.assertTrue(raised)
|
||||
|
||||
def testRandomExecution(self):
|
||||
"""
|
||||
Check that random execution doesn't break.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[DEFAULT]
|
||||
head = head_crashreporter.js
|
||||
tail =
|
||||
head =
|
||||
tail =
|
||||
|
||||
[test_content_annotation.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче