Skip to content
This repository was archived by the owner on Nov 11, 2019. It is now read-only.

Commit 2e1a964

Browse files
authored
codecoverage/bot: Make getting chunks platform-specific, as some chunks are only available in a platform and not in another (#1794)
For example, the entire 'robocop' test suite is available only for Android. Moreover, some test suites are divided in a smaller/higher number of chunks according to platform (e.g. on Linux we have less chunks than on Windows, as Windows is slower).
1 parent 4b56d69 commit 2e1a964

4 files changed

Lines changed: 17 additions & 10 deletions

File tree

src/codecoverage/bot/code_coverage_bot/artifacts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def generate_path(self, platform, chunk, artifact):
2929
file_name = '%s_%s_%s' % (platform, chunk, os.path.basename(artifact['name']))
3030
return os.path.join(self.parent_dir, file_name)
3131

32-
def get_chunks(self):
33-
return list(set([f.split('_')[1] for f in os.listdir(self.parent_dir)]))
32+
def get_chunks(self, platform):
33+
return set(f.split('_')[1] for f in os.listdir(self.parent_dir) if os.path.basename(f).startswith(f'{platform}_'))
3434

3535
def get(self, platform=None, suite=None, chunk=None):
3636
files = os.listdir(self.parent_dir)

src/codecoverage/bot/code_coverage_bot/chunk_mapping.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,18 @@ def generate(repo_dir, revision, artifactsHandler, out_dir='.'):
167167
futures = {}
168168
for platform in PLATFORMS:
169169
logger.info('Reading chunk coverage artifacts for {}.'.format(platform))
170-
for chunk in artifactsHandler.get_chunks():
170+
for chunk in artifactsHandler.get_chunks(platform):
171171
suite = taskcluster.get_suite(chunk)
172172
if not is_chunk_only_suite(suite):
173173
continue
174174

175175
assert chunk.strip() != '', 'chunk can not be an empty string'
176176

177-
future = executor.submit(grcov.files_list, artifactsHandler.get(platform=platform, chunk=chunk), source_dir=repo_dir)
177+
artifacts = artifactsHandler.get(platform=platform, chunk=chunk)
178+
179+
assert len(artifacts) > 0, 'There should be at least one artifact'
180+
181+
future = executor.submit(grcov.files_list, artifacts, source_dir=repo_dir)
178182
futures[future] = (platform, chunk)
179183

180184
logger.info('Populating chunk_to_test table for {}.'.format(platform))

src/codecoverage/bot/tests/test_artifacts.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@ def test_generate_path(FAKE_ARTIFACTS_DIR):
3737

3838
def test_get_chunks(FAKE_ARTIFACTS_DIR):
3939
a = ArtifactsHandler([], parent_dir=FAKE_ARTIFACTS_DIR)
40-
assert set(a.get_chunks()) == set([
41-
'mochitest-1', 'mochitest-2', 'xpcshell-3', 'xpcshell-7',
42-
'cppunit', 'firefox-ui-functional-remote',
43-
])
40+
assert a.get_chunks('windows') == {
41+
'mochitest-1', 'xpcshell-7', 'cppunit',
42+
}
43+
assert a.get_chunks('linux') == {
44+
'mochitest-2', 'xpcshell-3', 'xpcshell-7',
45+
'firefox-ui-functional-remote',
46+
}
4447

4548

4649
def test_get_coverage_artifacts(FAKE_ARTIFACTS_DIR):

src/codecoverage/bot/tests/test_chunk_mapping.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class FakeArtifactsHandler(object):
1616
def __init__(self):
1717
pass
1818

19-
def get_chunks(self):
20-
return ['chunk1', 'chunk2']
19+
def get_chunks(self, platform):
20+
return {'chunk1', 'chunk2'}
2121

2222
def get(self, platform=None, suite=None, chunk=None):
2323
if platform == 'linux' and chunk == 'chunk1':

0 commit comments

Comments
 (0)