Exemplo n.º 1
0
def test_get_coverage_artifacts(FAKE_ARTIFACTS_DIR):
    def add_dir(files):
        return set([os.path.join(FAKE_ARTIFACTS_DIR, f) for f in files])

    a = ArtifactsHandler([], [], parent_dir=FAKE_ARTIFACTS_DIR)
    assert set(a.get()) == add_dir(FILES)
    assert set(a.get(suite='mochitest')) == add_dir([
        'windows_mochitest-1_code-coverage-jsvm.info',
        'linux_mochitest-2_code-coverage-grcov.zip'
    ])
    assert set(a.get(chunk='xpcshell-7')) == add_dir([
        'windows_xpcshell-7_code-coverage-jsvm.info',
        'linux_xpcshell-7_code-coverage-grcov.zip'
    ])
    assert set(a.get(chunk='cppunit')) == add_dir(
        ['windows_cppunit_code-coverage-grcov.zip'])
    assert set(a.get(platform='windows')) == add_dir([
        'windows_mochitest-1_code-coverage-jsvm.info',
        'windows_xpcshell-7_code-coverage-jsvm.info',
        'windows_cppunit_code-coverage-grcov.zip',
    ])
    assert set(a.get(platform='linux', chunk='xpcshell-7')) == add_dir(
        ['linux_xpcshell-7_code-coverage-grcov.zip'])

    with pytest.raises(Exception,
                       message='suite and chunk can\'t both have a value'):
        a.get(chunk='xpcshell-7', suite='mochitest')
Exemplo n.º 2
0
def test_get_coverage_artifacts():
    utils.mkdir('ccov-artifacts')

    for f in FILES:
        open(f, 'w')

    a = ArtifactsHandler([], [])
    assert set(a.get()) == set(FILES)
    assert set(a.get(suite='mochitest')) == set([
        'ccov-artifacts/windows_mochitest-1_code-coverage-jsvm.info',
        'ccov-artifacts/linux_mochitest-2_code-coverage-grcov.zip'
    ])
    assert set(a.get(chunk='xpcshell-7')) == set([
        'ccov-artifacts/windows_xpcshell-7_code-coverage-jsvm.info',
        'ccov-artifacts/linux_xpcshell-7_code-coverage-grcov.zip'
    ])
    assert set(a.get(chunk='cppunit')) == set(
        ['ccov-artifacts/windows_cppunit_code-coverage-grcov.zip'])
    assert set(a.get(platform='windows')) == set([
        'ccov-artifacts/windows_mochitest-1_code-coverage-jsvm.info',
        'ccov-artifacts/windows_xpcshell-7_code-coverage-jsvm.info',
        'ccov-artifacts/windows_cppunit_code-coverage-grcov.zip',
    ])
    assert set(a.get(platform='linux', chunk='xpcshell-7')) == set(
        ['ccov-artifacts/linux_xpcshell-7_code-coverage-grcov.zip'])

    try:
        a.get(chunk='xpcshell-7', suite='mochitest')
        assert False, 'An exception should have been thrown'
    except Exception:
        pass

    for f in FILES:
        os.remove(f)
Exemplo n.º 3
0
def test_get_chunks(FAKE_ARTIFACTS_DIR):
    a = ArtifactsHandler([], [], parent_dir=FAKE_ARTIFACTS_DIR)
    assert set(a.get_chunks()) == set([
        'mochitest-1',
        'mochitest-2',
        'xpcshell-3',
        'xpcshell-7',
        'cppunit',
        'firefox-ui-functional-remote',
    ])
Exemplo n.º 4
0
def test_get_chunks():
    utils.mkdir('ccov-artifacts')

    for f in FILES:
        open(f, 'w')

    a = ArtifactsHandler([], [])
    assert set(a.get_chunks()) == set([
        'mochitest-1',
        'mochitest-2',
        'xpcshell-3',
        'xpcshell-7',
        'cppunit',
        'firefox-ui-functional-remote',
    ])

    for f in FILES:
        os.remove(f)
Exemplo n.º 5
0
def test_download(mocked_download_artifact, mocked_get_task_artifact, TEST_TASK_FROM_GROUP, LINUX_TEST_TASK_ARTIFACTS):
    a = ArtifactsHandler([], [])
    mocked_get_task_artifact.return_value = LINUX_TEST_TASK_ARTIFACTS['artifacts']

    a.download(TEST_TASK_FROM_GROUP)

    assert mocked_get_task_artifact.call_count == 1
    assert mocked_download_artifact.call_count == 2
    assert mocked_download_artifact.call_args_list[0] == mock.call(
        'ccov-artifacts/linux_mochitest-devtools-chrome-4_code-coverage-grcov.zip',
        'AN1M9SW0QY6DZT6suL3zlQ',
        'public/test_info/code-coverage-grcov.zip',
    )
    assert mocked_download_artifact.call_args_list[1] == mock.call(
        'ccov-artifacts/linux_mochitest-devtools-chrome-4_code-coverage-jsvm.zip',
        'AN1M9SW0QY6DZT6suL3zlQ',
        'public/test_info/code-coverage-jsvm.zip',
    )
Exemplo n.º 6
0
    def __init__(self, revision, cache_root, client_id, access_token):
        # List of test-suite, sorted alphabetically.
        # This way, the index of a suite in the array should be stable enough.
        self.suites = [
            'cppunit',
            'gtest',
            'web-platform-tests',
            'talos',
        ]

        self.cache_root = cache_root

        assert os.path.isdir(cache_root), 'Cache root {} is not a dir.'.format(
            cache_root)
        self.repo_dir = os.path.join(cache_root, 'mozilla-central')

        self.client_id = client_id
        self.access_token = access_token

        self.githubUtils = GitHubUtils(cache_root, client_id, access_token)

        if revision is None:
            # Retrieve revision of latest codecov build
            github_revision = uploader.get_latest_codecov()
            self.revision = self.githubUtils.get_mercurial(github_revision)
            self.from_pulse = False
            suites_to_ignore = []
        else:
            self.revision = revision
            self.from_pulse = True
            suites_to_ignore = ['awsy', 'talos']
            self.notifier = Notifier(revision, client_id, access_token)

        logger.info('Mercurial revision', revision=self.revision)

        task_ids = {
            'linux':
            taskcluster.get_task('mozilla-central', self.revision, 'linux'),
            'windows':
            taskcluster.get_task('mozilla-central', self.revision, 'win'),
        }

        self.artifactsHandler = ArtifactsHandler(task_ids, suites_to_ignore)