Bug 1134395 - mozbuild should pass in rootdir to manifestparser to properly calculate test relpaths, r=gps

--HG--
extra : rebase_source : 0d77784a6e7eea31be009f3f475861cf57caeeb3
This commit is contained in:
Andrew Halberstadt 2015-02-18 17:07:55 -05:00
Родитель 30b9c7ce5f
Коммит c6d32a2950
6 изменённых файлов: 21 добавлений и 12 удалений

Просмотреть файл

@ -908,7 +908,8 @@ class TreeMetadataEmitter(LoggingMixin):
install_prefix = mozpath.join(install_root, install_subdir)
try:
m = manifestparser.TestManifest(manifests=[path], strict=True)
m = manifestparser.TestManifest(manifests=[path], strict=True,
rootdir=context.config.topsrcdir)
defaults = m.manifest_defaults[os.path.normpath(path)]
if not m.tests and not 'support-files' in defaults:
raise SandboxValidationError('Empty test manifest: %s'
@ -1002,8 +1003,10 @@ class TreeMetadataEmitter(LoggingMixin):
# Some test files are compiled and should not be copied into the
# test package. They function as identifiers rather than files.
if package_tests:
manifest_relpath = mozpath.relpath(test['path'],
mozpath.dirname(test['manifest']))
obj.installs[mozpath.normpath(test['path'])] = \
(mozpath.join(out_dir, test['relpath']), True)
((mozpath.join(out_dir, manifest_relpath)), True)
process_support_files(test)

Просмотреть файл

@ -29,8 +29,10 @@ def rewrite_test_base(test, new_base, honor_install_to_subdir=False):
test['here'] = mozpath.join(new_base, test['dir_relpath'])
if honor_install_to_subdir and test.get('install-to-subdir'):
manifest_relpath = mozpath.relpath(test['path'],
mozpath.dirname(test['manifest']))
test['path'] = mozpath.join(new_base, test['dir_relpath'],
test['install-to-subdir'], test['relpath'])
test['install-to-subdir'], manifest_relpath)
else:
test['path'] = mozpath.join(new_base, test['file_relpath'])

Просмотреть файл

@ -182,7 +182,11 @@ Manifest Destiny gives tests as a list of dictionaries (in python
terms).
* path: full path to the test
* relpath: relative path starting from the root manifest location
* relpath: relative path starting from the root directory. The root directory
is typically the location of the root manifest, or the source
repository. It can be specified at runtime by passing in `rootdir`
to `TestManifest`. Defaults to the directory containing the test's
ancestor manifest.
* name: file name of the test
* here: the parent directory of the manifest
* manifest: the path to the manifest containing the test

Просмотреть файл

@ -203,7 +203,7 @@ class chunk_by_dir(InstanceFilter):
tests_by_dir = defaultdict(list)
ordered_dirs = []
for test in tests:
path = test['path']
path = test['relpath']
if path.startswith(os.sep):
path = path[1:]

Просмотреть файл

@ -43,13 +43,13 @@ def denormalize_path(path):
class ManifestParser(object):
"""read .ini manifests"""
def __init__(self, manifests=(), defaults=None, strict=True):
def __init__(self, manifests=(), defaults=None, strict=True, rootdir=None):
self._defaults = defaults or {}
self._ancestor_defaults = {}
self.tests = []
self.manifest_defaults = {}
self.strict = strict
self.rootdir = None
self.rootdir = rootdir
self.relativeRoot = None
if manifests:
self.read(*manifests)

Просмотреть файл

@ -78,18 +78,18 @@ class ChunkByDir(unittest.TestCase):
i += 1
name = 'test%i' % i
test = {'name': name,
'path': os.path.join(d, name)}
'relpath': os.path.join(d, name)}
yield test
def run_all_combos(self, dirs):
tests = self.generate_tests(dirs)
tests = list(self.generate_tests(dirs))
deepest = max(len(t['path'].split(os.sep))-1 for t in tests)
deepest = max(len(t['relpath'].split(os.sep))-1 for t in tests)
for depth in range(1, deepest+1):
def num_groups(tests):
unique = set()
for p in [t['path'] for t in tests]:
for p in [t['relpath'] for t in tests]:
p = p.split(os.sep)
p = p[:min(depth, len(p)-1)]
unique.add(os.sep.join(p))
@ -99,7 +99,7 @@ class ChunkByDir(unittest.TestCase):
res = []
for this in range(1, total+1):
f = chunk_by_dir(this, total, depth)
res.append(f(tests, {}))
res.append(list(f(tests, {})))
lengths = map(num_groups, res)
# the chunk with the most dirs should have at most one more