diff --git a/bot/code_coverage_bot/chunk_mapping.py b/bot/code_coverage_bot/chunk_mapping.py index 040d93c52..597af04f4 100644 --- a/bot/code_coverage_bot/chunk_mapping.py +++ b/bot/code_coverage_bot/chunk_mapping.py @@ -38,12 +38,7 @@ def get_suites(revision): "and": [ {"eq": {"repo.branch.name": "mozilla-central"}}, {"eq": {"repo.changeset.id12": revision[:12]}}, - { - "or": [ - {"prefix": {"run.key": "test-linux64-ccov"}}, - {"prefix": {"run.key": "test-windows10-64-ccov"}}, - ] - }, + {"regexp": {"run.key": ".*-ccov/.*"}}, ] }, "limit": 500000, @@ -58,13 +53,6 @@ def get_suites(revision): # Retrieve chunk -> tests mapping from ActiveData. def get_tests_chunks(revision, platform, suite): - if platform == "linux": - run_key_prefix = "test-linux64-ccov" - elif platform == "windows": - run_key_prefix = "test-windows10-64-ccov" - else: - raise Exception("Unsupported platform {}".format(platform)) - r = requests.post( ACTIVEDATA_QUERY_URL, json={ @@ -74,7 +62,7 @@ def get_tests_chunks(revision, platform, suite): {"eq": {"repo.branch.name": "mozilla-central"}}, {"eq": {"repo.changeset.id12": revision[:12]}}, {"eq": {"run.suite.fullname": suite}}, - {"prefix": {"run.key": run_key_prefix}}, + {"regexp": {"run.key": f".*-{platform}.*-ccov/.*"}}, ] }, "limit": 50000, diff --git a/bot/code_coverage_bot/taskcluster.py b/bot/code_coverage_bot/taskcluster.py index c6277d627..6731c0611 100644 --- a/bot/code_coverage_bot/taskcluster.py +++ b/bot/code_coverage_bot/taskcluster.py @@ -14,6 +14,8 @@ logger = structlog.getLogger(__name__) taskcluster_config = TaskclusterConfig("https://firefox-ci-tc.services.mozilla.com") +NAME_PARTS_TO_SKIP = ("opt", "debug", "e10s", "1proc") + def get_task(branch, revision, platform): if platform == "linux": @@ -99,47 +101,29 @@ def perform_download(): retry(perform_download) -BUILD_PLATFORMS = [ - "build-linux64-ccov/opt", - "build-win64-ccov/debug", - "build-android-test-ccov/opt", -] - -TEST_PLATFORMS = [ - "test-linux64-ccov/opt", - "test-windows10-64-ccov/debug", - "test-android-em-4.3-arm7-api-16-ccov/debug", -] + BUILD_PLATFORMS - - def is_coverage_task(task): - return any(task["metadata"]["name"].startswith(t) for t in TEST_PLATFORMS) + return "ccov" in task["metadata"]["name"].split("/")[0].split("-") -def name_to_chunk(name): +def name_to_chunk(name: str): """ Helper to convert a task name to a chunk Used by chunk mapping """ - assert isinstance(name, str) - # Some tests are run on build machines, we define a placeholder chunk for those. - if name in BUILD_PLATFORMS: + if name.startswith("build-"): return "build" - for t in TEST_PLATFORMS: - if name.startswith(t): - name = name[len(t) + 1 :] - break - return "-".join([p for p in name.split("-") if p != "e10s"]) + name = name[name.find("/") + 1 :] + + return "-".join([p for p in name.split("-") if p not in NAME_PARTS_TO_SKIP]) -def chunk_to_suite(chunk): +def chunk_to_suite(chunk: str): """ Helper to convert a chunk to a suite (no numbers) Used by chunk mapping """ - assert isinstance(chunk, str) return "-".join([p for p in chunk.split("-") if not p.isdigit()]) diff --git a/bot/tests/fixtures/test-linux1804-64-ccov/opt-cppunit.json b/bot/tests/fixtures/test-linux1804-64-ccov/opt-cppunit.json new file mode 100644 index 000000000..ab232ea75 --- /dev/null +++ b/bot/tests/fixtures/test-linux1804-64-ccov/opt-cppunit.json @@ -0,0 +1,144 @@ +{ + "provisionerId": "gecko-t", + "workerType": "t-linux-xlarge", + "schedulerId": "gecko-level-3", + "taskGroupId": "S5_GgKsuQvuxsHqLKGXpow", + "dependencies": [ + "LLq0pXcjRQSeeqX39y0LIg", + "T6iDE8yqQryKzJiVSvfpiQ", + "cCf9pNwMTp-U1DLCivF6ew" + ], + "requires": "all-completed", + "routes": [ + "tc-treeherder.v2.mozilla-central.1fd87ec46d80675d2a8b18b47029f53a28d43a38.36976" + ], + "priority": "medium", + "retries": 5, + "created": "2020-01-03T16:09:04.017Z", + "deadline": "2020-01-04T16:09:04.017Z", + "expires": "2021-01-02T16:09:04.017Z", + "scopes": [ + "secrets:get:project/taskcluster/gecko/hgfingerprint", + "secrets:get:project/taskcluster/gecko/hgmointernal", + "project:releng:services/tooltool/api/download/public", + "docker-worker:feature:allowPtrace", + "docker-worker:cache:gecko-level-3-checkouts-v3-75316e4022f196ea1700", + "docker-worker:cache:gecko-level-3-tooltool-cache-v3-75316e4022f196ea1700" + ], + "payload": { + "onExitStatus": { + "retry": [ + 4, + 72 + ], + "purgeCaches": [ + 72 + ] + }, + "maxRunTime": 3600, + "image": { + "path": "public/image.tar.zst", + "type": "task-image", + "taskId": "LLq0pXcjRQSeeqX39y0LIg" + }, + "cache": { + "gecko-level-3-checkouts-v3-75316e4022f196ea1700": "/builds/worker/checkouts", + "gecko-level-3-tooltool-cache-v3-75316e4022f196ea1700": "/builds/worker/tooltool-cache" + }, + "artifacts": { + "public/logs/": { + "path": "/builds/worker/workspace/logs/", + "expires": "2021-01-02T16:09:04.017Z", + "type": "directory" + }, + "public/test": { + "path": "/builds/worker/artifacts/", + "expires": "2021-01-02T16:09:04.017Z", + "type": "directory" + }, + "public/test_info/": { + "path": "/builds/worker/workspace/build/blobber_upload_dir/", + "expires": "2021-01-02T16:09:04.017Z", + "type": "directory" + } + }, + "command": [ + "/builds/worker/bin/run-task", + "--fetch-hgfingerprint", + "--", + "/builds/worker/bin/test-linux.sh", + "--cppunittest-suite=cppunittest", + "--code-coverage", + "--disable-e10s", + "--allow-software-gl-layers", + "--download-symbols=ondemand" + ], + "env": { + "MOZ_AUTOMATION": "1", + "TOOLTOOL_CACHE": "/builds/worker/tooltool-cache", + "MOZ_FETCHES_DIR": "fetches", + "MOZHARNESS_SCRIPT": "desktop_unittest.py", + "MOZ_NODE_PATH": "/usr/local/bin/node", + "HG_STORE_PATH": "/builds/worker/checkouts/hg-store", + "MOZILLA_BUILD_URL": "https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/T6iDE8yqQryKzJiVSvfpiQ/artifacts/public/build/target.tar.bz2", + "GECKO_PATH": "/builds/worker/checkouts/gecko", + "GECKO_HEAD_REPOSITORY": "https://hg.mozilla.org/mozilla-central", + "EXTRA_MOZHARNESS_CONFIG": "{\"test_packages_url\": \"https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/T6iDE8yqQryKzJiVSvfpiQ/artifacts/public/build/target.test_packages.json\", \"installer_url\": \"https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/T6iDE8yqQryKzJiVSvfpiQ/artifacts/public/build/target.tar.bz2\"}", + "SCCACHE_DISABLE": "1", + "GECKO_HEAD_REV": "1fd87ec46d80675d2a8b18b47029f53a28d43a38", + "NEED_COMPIZ": "false", + "MOZ_SCM_LEVEL": "3", + "TASKCLUSTER_VOLUMES": "/builds/worker/.cache;/builds/worker/checkouts;/builds/worker/tooltool-cache;/builds/worker/workspace", + "MOZHARNESS_URL": "https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/T6iDE8yqQryKzJiVSvfpiQ/artifacts/public/build/mozharness.zip", + "GECKO_BASE_REPOSITORY": "https://hg.mozilla.org/mozilla-unified", + "MOZ_FETCHES": "[{\"artifact\": \"public/build/grcov.tar.xz\", \"extract\": true, \"task\": \"cCf9pNwMTp-U1DLCivF6ew\"}]", + "TASKCLUSTER_CACHES": "/builds/worker/checkouts;/builds/worker/tooltool-cache", + "WORKING_DIR": "/builds/worker", + "NEED_PULSEAUDIO": "true", + "ENABLE_E10S": "false", + "NEED_WINDOW_MANAGER": "true", + "MOZHARNESS_CONFIG": "unittests/linux_unittest.py remove_executables.py" + }, + "features": { + "taskclusterProxy": true, + "allowPtrace": true + } + }, + "metadata": { + "owner": "malexandru@mozilla.com", + "source": "https://hg.mozilla.org/mozilla-central/file/1fd87ec46d80675d2a8b18b47029f53a28d43a38/taskcluster/ci/test", + "description": "CPP Unit Tests ([Treeherder push](https://treeherder.mozilla.org/#/jobs?repo=mozilla-central&revision=1fd87ec46d80675d2a8b18b47029f53a28d43a38))", + "name": "test-linux1804-64-ccov/opt-cppunit-1proc" + }, + "tags": { + "kind": "test", + "worker-implementation": "docker-worker", + "createdForUser": "malexandru@mozilla.com", + "retrigger": "true", + "label": "test-linux1804-64-ccov/opt-cppunit-1proc", + "os": "linux" + }, + "extra": { + "index": { + "rank": 0 + }, + "parent": "S5_GgKsuQvuxsHqLKGXpow", + "chunks": { + "current": 1, + "total": 1 + }, + "suite": "cppunittest", + "treeherder": { + "machine": { + "platform": "linux1804-64-ccov" + }, + "tier": 2, + "symbol": "cppunit", + "jobKind": "test", + "collection": { + "opt": true + } + }, + "treeherder-platform": "linux1804-64-ccov/opt" + } +} diff --git a/bot/tests/fixtures/test-linux1804-64-ccov/opt-mochitest-1.json b/bot/tests/fixtures/test-linux1804-64-ccov/opt-mochitest-1.json new file mode 100644 index 000000000..6432f5740 --- /dev/null +++ b/bot/tests/fixtures/test-linux1804-64-ccov/opt-mochitest-1.json @@ -0,0 +1,158 @@ +{ + "provisionerId": "gecko-t", + "workerType": "t-linux-xlarge", + "schedulerId": "gecko-level-3", + "taskGroupId": "UpVSSic1SeCw6sdDMidSLQ", + "dependencies": [ + "EfaZjAzoQimatbNgqJd1zA", + "LFz17jARRPOoUz4s3CKY4g", + "Pq4D-RNFRHa_pSR7oP5CKg" + ], + "requires": "all-completed", + "routes": [ + "tc-treeherder.v2.mozilla-central.1e1617c67238dfb685fb3d07bf1793232c4469fa.36805", + "coalesce.v1.mozilla-central.6b77c44ef9bf547dfe11" + ], + "priority": "medium", + "retries": 5, + "created": "2019-11-15T09:55:53.069Z", + "deadline": "2019-11-16T09:55:53.069Z", + "expires": "2020-11-14T09:55:53.069Z", + "scopes": [ + "secrets:get:project/taskcluster/gecko/hgfingerprint", + "secrets:get:project/taskcluster/gecko/hgmointernal", + "project:releng:services/tooltool/api/download/public", + "docker-worker:feature:allowPtrace", + "docker-worker:capability:device:loopbackVideo", + "docker-worker:cache:gecko-level-3-checkouts-v3-e0773b586060dfe744c7", + "docker-worker:cache:gecko-level-3-tooltool-cache-v3-e0773b586060dfe744c7" + ], + "payload": { + "supersederUrl": "https://coalesce.mozilla-releng.net/v1/list/3600/5/mozilla-central.6b77c44ef9bf547dfe11", + "onExitStatus": { + "retry": [ + 4, + 72 + ], + "purgeCaches": [ + 72 + ] + }, + "maxRunTime": 5400, + "image": { + "path": "public/image.tar.zst", + "type": "task-image", + "taskId": "Pq4D-RNFRHa_pSR7oP5CKg" + }, + "cache": { + "gecko-level-3-tooltool-cache-v3-e0773b586060dfe744c7": "/builds/worker/tooltool-cache", + "gecko-level-3-checkouts-v3-e0773b586060dfe744c7": "/builds/worker/checkouts" + }, + "capabilities": { + "devices": { + "loopbackVideo": true + } + }, + "artifacts": { + "public/logs/": { + "path": "/builds/worker/workspace/logs/", + "expires": "2020-11-14T09:55:53.069Z", + "type": "directory" + }, + "public/test": { + "path": "/builds/worker/artifacts/", + "expires": "2020-11-14T09:55:53.069Z", + "type": "directory" + }, + "public/test_info/": { + "path": "/builds/worker/workspace/build/blobber_upload_dir/", + "expires": "2020-11-14T09:55:53.069Z", + "type": "directory" + } + }, + "command": [ + "/builds/worker/bin/run-task", + "--fetch-hgfingerprint", + "--", + "/builds/worker/bin/test-linux.sh", + "--mochitest-suite=mochitest-plain", + "--code-coverage", + "--setpref=media.peerconnection.mtransport_process=false", + "--setpref=network.process.enabled=false", + "--total-chunk=10", + "--this-chunk=1", + "--download-symbols=ondemand" + ], + "env": { + "MOZ_AUTOMATION": "1", + "MOCHITEST_FLAVOR": "plain", + "TOOLTOOL_CACHE": "/builds/worker/tooltool-cache", + "MOZ_FETCHES_DIR": "fetches", + "MOZHARNESS_SCRIPT": "desktop_unittest.py", + "MOZ_NODE_PATH": "/usr/local/bin/node", + "HG_STORE_PATH": "/builds/worker/checkouts/hg-store", + "MOZILLA_BUILD_URL": "https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/EfaZjAzoQimatbNgqJd1zA/artifacts/public/build/target.tar.bz2", + "GECKO_PATH": "/builds/worker/checkouts/gecko", + "GECKO_HEAD_REPOSITORY": "https://hg.mozilla.org/mozilla-central", + "EXTRA_MOZHARNESS_CONFIG": "{\"test_packages_url\": \"https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/EfaZjAzoQimatbNgqJd1zA/artifacts/public/build/target.test_packages.json\", \"installer_url\": \"https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/EfaZjAzoQimatbNgqJd1zA/artifacts/public/build/target.tar.bz2\"}", + "SCCACHE_DISABLE": "1", + "GECKO_HEAD_REV": "1e1617c67238dfb685fb3d07bf1793232c4469fa", + "NEED_COMPIZ": "true", + "MOZ_SCM_LEVEL": "3", + "TASKCLUSTER_VOLUMES": "/builds/worker/.cache;/builds/worker/checkouts;/builds/worker/tooltool-cache;/builds/worker/workspace", + "MOZHARNESS_URL": "https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/EfaZjAzoQimatbNgqJd1zA/artifacts/public/build/mozharness.zip", + "GECKO_BASE_REPOSITORY": "https://hg.mozilla.org/mozilla-unified", + "MOZ_FETCHES": "[{\"artifact\": \"public/build/grcov.tar.xz\", \"extract\": true, \"task\": \"LFz17jARRPOoUz4s3CKY4g\"}]", + "TASKCLUSTER_CACHES": "/builds/worker/checkouts;/builds/worker/tooltool-cache", + "WORKING_DIR": "/builds/worker", + "NEED_PULSEAUDIO": "true", + "ENABLE_E10S": "true", + "NEED_WINDOW_MANAGER": "true", + "MOZHARNESS_CONFIG": "unittests/linux_unittest.py remove_executables.py" + }, + "features": { + "taskclusterProxy": true, + "allowPtrace": true + } + }, + "metadata": { + "owner": "aiakab@mozilla.com", + "source": "https://hg.mozilla.org/mozilla-central/file/1e1617c67238dfb685fb3d07bf1793232c4469fa/taskcluster/ci/test", + "description": "Mochitest plain run ([Treeherder push](https://treeherder.mozilla.org/#/jobs?repo=mozilla-central&revision=1e1617c67238dfb685fb3d07bf1793232c4469fa))", + "name": "test-linux1804-64-ccov/opt-mochitest-e10s-1" + }, + "tags": { + "kind": "test", + "os": "linux", + "createdForUser": "aiakab@mozilla.com", + "retrigger": "true", + "label": "test-linux1804-64-ccov/opt-mochitest-e10s-1", + "test-type": "mochitest", + "worker-implementation": "docker-worker" + }, + "extra": { + "index": { + "rank": 0 + }, + "parent": "UpVSSic1SeCw6sdDMidSLQ", + "chunks": { + "current": 1, + "total": 10 + }, + "suite": "mochitest-plain", + "treeherder": { + "jobKind": "test", + "groupSymbol": "M", + "collection": { + "opt": true + }, + "machine": { + "platform": "linux1804-64-ccov" + }, + "groupName": "Mochitests", + "tier": 3, + "symbol": "1" + }, + "treeherder-platform": "linux1804-64-ccov/opt" + } +} diff --git a/bot/tests/test_chunk_mapping.py b/bot/tests/test_chunk_mapping.py index c4c97802f..979beb87e 100644 --- a/bot/tests/test_chunk_mapping.py +++ b/bot/tests/test_chunk_mapping.py @@ -116,15 +116,15 @@ def request_callback(request): if requested_suite in ["gtest", "talos"]: data = {} elif requested_suite == "marionette": - prefix = payload["where"]["and"][3]["prefix"]["run.key"] - if prefix == "test-linux64-ccov": + regexp = payload["where"]["and"][3]["regexp"]["run.key"] + if regexp == ".*-linux.*-ccov/.*": data = { "result.test": ["marionette-test1"], "run.key": [ "test-linux64-ccov/opt-marionette-headless-e10s" ], } - elif prefix == "test-windows10-64-ccov": + elif regexp == ".*-windows.*-ccov/.*": data = { "result.test": ["marionette-test2"], "run.key": [ @@ -132,7 +132,7 @@ def request_callback(request): ], } else: - assert False, "Unexpected prefix" + assert False, "Unexpected regexp" else: assert False, "Unexpected suite" else: diff --git a/bot/tests/test_taskcluster.py b/bot/tests/test_taskcluster.py index 5f1e062b2..6524a85f6 100644 --- a/bot/tests/test_taskcluster.py +++ b/bot/tests/test_taskcluster.py @@ -134,18 +134,19 @@ def test_get_tasks_in_group(mock_taskcluster, GROUP_TASKS_1, GROUP_TASKS_2): @pytest.mark.parametrize( "task_name, expected", [ - ("test-linux64-ccov/debug-mochitest-1", False), - ("test-linux64-ccov/debug-mochitest-e10s-7", False), - ("test-linux64-ccov/debug-cppunit", False), - ("test-linux64-ccov/debug-firefox-ui-functional-remote-e10s", False), + ("test-linux64-ccov/debug-mochitest-1", True), + ("test-linux64-ccov/debug-mochitest-e10s-7", True), + ("test-linux64-ccov/debug-cppunit", True), + ("test-linux64-ccov/debug-firefox-ui-functional-remote-e10s", True), ("test-linux64-ccov/opt-mochitest-1", True), ("test-linux64-ccov/opt-mochitest-e10s-7", True), ("test-linux64-ccov/opt-cppunit", True), + ("test-linux1804-64-ccov/opt-cppunit", True), ("test-linux64-ccov/opt-firefox-ui-functional-remote-e10s", True), ("test-windows10-64-ccov/debug-mochitest-1", True), ("test-windows10-64-ccov/debug-mochitest-e10s-7", True), ("test-windows10-64-ccov/debug-cppunit", True), - ("build-linux64-ccov/debug", False), + ("build-linux64-ccov/debug", True), ("build-linux64-ccov/opt", True), ("build-android-test-ccov/opt", True), ("build-win64-ccov/debug", True), @@ -164,6 +165,7 @@ def test_is_coverage_task(task_name, expected): [ ("test-linux64-ccov/opt-mochitest-1", "mochitest-1"), ("test-linux64-ccov/opt-mochitest-e10s-7", "mochitest-7"), + ("test-linux1804-64-ccov/opt-mochitest-e10s-7", "mochitest-7"), ("test-linux64-ccov/opt-cppunit", "cppunit"), ( "test-linux64-ccov/opt-firefox-ui-functional-remote-e10s", @@ -201,6 +203,7 @@ def test_chunk_to_suite(chunk, expected): ("test-linux64-ccov/opt-mochitest-1", "mochitest-plain-1"), ("test-linux64-ccov/opt-mochitest-e10s-7", "mochitest-plain-7"), ("test-linux64-ccov/opt-cppunit", "cppunittest-1"), + ("test-linux1804-64-ccov/opt-cppunit", "cppunittest-1"), ( "test-linux64-ccov/opt-firefox-ui-functional-remote-e10s", "firefox-ui-functional-remote-1", @@ -222,6 +225,7 @@ def test_get_chunk(task_name, expected): "task_name, expected", [ ("test-linux64-ccov/opt-mochitest-1", "mochitest-plain"), + ("test-linux1804-64-ccov/opt-mochitest-1", "mochitest-plain"), ("test-linux64-ccov/opt-mochitest-e10s-7", "mochitest-plain"), ("test-linux64-ccov/opt-cppunit", "cppunittest"), ( @@ -245,6 +249,7 @@ def test_get_suite(task_name, expected): "task_name, expected", [ ("test-linux64-ccov/opt-mochitest-1", "linux"), + ("test-linux1804-64-ccov/opt-mochitest-1", "linux"), ("test-linux64-ccov/opt-mochitest-e10s-7", "linux"), ("test-linux64-ccov/opt-cppunit", "linux"), ("test-linux64-ccov/opt-firefox-ui-functional-remote-e10s", "linux"), diff --git a/events/code_coverage_events/workflow.py b/events/code_coverage_events/workflow.py index bed29ddc9..e0145270b 100644 --- a/events/code_coverage_events/workflow.py +++ b/events/code_coverage_events/workflow.py @@ -57,10 +57,8 @@ async def run(self): ) def is_coverage_task(self, task): - return any( - task["task"]["metadata"]["name"].startswith(s) - for s in ["build-linux64-ccov", "build-win64-ccov"] - ) + name = task["task"]["metadata"]["name"] + return name.startswith("build-") and "ccov" in name.split("/")[0].split("-") async def get_build_task_in_group(self, group_id): if group_id in self.triggered_groups: diff --git a/events/tests/test_workflow.py b/events/tests/test_workflow.py index fa6429205..b9feb74e3 100644 --- a/events/tests/test_workflow.py +++ b/events/tests/test_workflow.py @@ -19,6 +19,9 @@ def test_is_coverage_task(mock_taskcluster): cov_task = {"task": {"metadata": {"name": "build-linux64-ccov"}}} assert hook.is_coverage_task(cov_task) + cov_task = {"task": {"metadata": {"name": "build-linux1804-64-ccov"}}} + assert hook.is_coverage_task(cov_task) + cov_task = {"task": {"metadata": {"name": "build-linux64-ccov/opt"}}} assert hook.is_coverage_task(cov_task) diff --git a/report/firefox_code_coverage/codecoverage.py b/report/firefox_code_coverage/codecoverage.py index 15cd6bb6f..106c8084d 100644 --- a/report/firefox_code_coverage/codecoverage.py +++ b/report/firefox_code_coverage/codecoverage.py @@ -18,7 +18,6 @@ from urllib2 import Request, urlopen -TEST_PLATFORMS = ["test-linux64-ccov/opt", "test-windows10-64-ccov/debug"] FINISHED_STATUSES = ["completed", "failed", "exception"] ALL_STATUSES = FINISHED_STATUSES + ["unscheduled", "pending", "running"] STATUS_VALUE = {"exception": 1, "failed": 2, "completed": 3} @@ -114,24 +113,29 @@ def download_artifact(task_id, artifact, artifacts_path): def get_chunk(task_name): - for t in TEST_PLATFORMS: - if task_name.startswith(t): - task_name = task_name[len(t) + 1 :] - break - return "-".join([p for p in task_name.split("-") if p != "e10s"]) + task_name = task_name[task_name.find("/") + 1 :] + return "-".join( + p for p in task_name.split("-") if p not in ("opt", "debug", "e10s", "1proc") + ) def get_suite(task_name): - return "-".join([p for p in get_chunk(task_name).split("-") if not p.isdigit()]) + # Some tests are run on build machines, we define a placeholder chunk for those. + if task_name.startswith("build-"): + return "build" + + return "-".join(p for p in get_chunk(task_name).split("-") if not p.isdigit()) def get_platform(task_name): if "linux" in task_name: return "linux" - elif "windows" in task_name: + elif "win" in task_name: return "windows" + elif "macosx" in task_name: + return "macos" else: - raise Exception("Unknown platform") + raise Exception(f"Unknown platform for {task_name}") def get_task_status(task_id): @@ -154,20 +158,16 @@ def download_coverage_artifacts( task_data = get_task_details(build_task_id) - # Returns True if the task is a test-related task. + # Returns True if the task is a test-related coverage task (build tasks are included). def _is_test_task(t): - return any( - t["task"]["metadata"]["name"].startswith(tp) for tp in TEST_PLATFORMS - ) + return "ccov" in t["task"]["metadata"]["name"].split("/")[0].split("-") # Returns True if the task is part of one of the suites chosen by the user. def _is_in_suites_task(t): suite_name = get_suite(t["task"]["metadata"]["name"]) return ( - suites is None - or suite_name in suites - and suite_name not in suites_to_ignore - ) + suites is None or suite_name in suites + ) and suite_name not in suites_to_ignore def _is_in_platforms_task(t): platform = get_platform(t["task"]["metadata"]["name"]) diff --git a/report/tests/test.py b/report/tests/test.py index 01d8e30d8..dad0fe905 100644 --- a/report/tests/test.py +++ b/report/tests/test.py @@ -68,6 +68,18 @@ def test(self): self.assertEqual(len([a for a in artifact_paths if "grcov" in a]), 2) self.assertEqual(len([a for a in artifact_paths if "jsvm" in a]), 2) + artifact_paths = codecoverage.download_coverage_artifacts( + task_id, "cppunit-1proc", None, "ccov-artifacts" + ) + self.assertEqual( + len([a for a in os.listdir("ccov-artifacts") if "grcov" in a]), 4 + ) + self.assertEqual( + len([a for a in os.listdir("ccov-artifacts") if "jsvm" in a]), 4 + ) + self.assertEqual(len([a for a in artifact_paths if "grcov" in a]), 2) + self.assertEqual(len([a for a in artifact_paths if "jsvm" in a]), 2) + codecoverage.download_grcov() codecoverage.generate_report("./grcov", "lcov", "output.info", artifact_paths) self.assertTrue(os.path.exists("output.info")) @@ -78,6 +90,7 @@ def test(self): def test_suite_name_from_task_name(self): cases = [ + ("test-linux1804-64-ccov/opt-cppunit-1proc", "cppunit"), ("test-linux64-ccov/opt-gtest", "gtest"), ("test-linux64-ccov/opt-jsreftest-1", "jsreftest"), ( @@ -89,6 +102,9 @@ def test_suite_name_from_task_name(self): ("test-linux64-ccov/opt-mochitest-5", "mochitest"), ("test-windows10-64-ccov/debug-mochitest-5", "mochitest"), ("test-windows10-64-ccov/debug-cppunit", "cppunit"), + ("build-linux64-ccov/opt", "build"), + ("build-android-test-ccov/opt", "build"), + ("build-win64-ccov/debug", "build"), ] for c in cases: self.assertEqual(codecoverage.get_suite(c[0]), c[1])