tools/lint/wpt/wpt.py
author Gregory Szorc <gps@mozilla.com>
Tue, 07 Nov 2017 16:38:39 -0800
changeset 441455 b5f79b0f2a3586faf692c715b443264478e921c3
parent 425150 ba1b16b46b0c6473c410fcdb4eaa0bace6f7f5e5
child 448237 f6ba05c2b2aedf14b977d8f8f396a7a78eceffc9
permissions -rw-r--r--
Bug 1412932 - Switch to PGO build in Makefile.in; r=ted Previously, client.mk made the decision of whether to perform a PGO build. This required passing around MOZ_PGO and invoking a separate make target if this variable was set. In this commit, we move this logic to Makefile.in. We employ a special mechanism in rules.mk to override the default make target so `make` evaluates "profiledbuild" if MOZ_PGO is set. This also required using an explicit target for $(MAKE) invocations inside the "profiledbuild" rule to avoid infinite recursion. MozReview-Commit-ID: 8sHiVspMisM

# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import json
import os

from mozprocess import ProcessHandler

from mozlint import result

results = []


def lint(files, config, **kwargs):
    tests_dir = os.path.join(kwargs['root'], 'testing', 'web-platform', 'tests')

    def process_line(line):
        try:
            data = json.loads(line)
        except ValueError:
            return
        data["level"] = "error"
        data["path"] = os.path.relpath(os.path.join(tests_dir, data["path"]), kwargs['root'])
        results.append(result.from_config(config, **data))

    path = os.path.join(tests_dir, "wpt")
    proc = ProcessHandler([path, "lint", "--json"] + files, env=os.environ,
                          processOutputLine=process_line)
    proc.run()
    try:
        proc.wait()
    except KeyboardInterrupt:
        proc.kill()

    return results