diff options
Diffstat (limited to 'python/servo')
-rw-r--r-- | python/servo/build_commands.py | 7 | ||||
-rw-r--r-- | python/servo/command_base.py | 24 | ||||
-rw-r--r-- | python/servo/testing_commands.py | 73 |
3 files changed, 54 insertions, 50 deletions
diff --git a/python/servo/build_commands.py b/python/servo/build_commands.py index 8f462939b5b..4630c9a9dbf 100644 --- a/python/servo/build_commands.py +++ b/python/servo/build_commands.py @@ -635,7 +635,7 @@ class MachCommands(CommandBase): opts = ["-Ztimings=info"] + opts if very_verbose: - print (["Calling", "cargo", "build"] + opts) + print(["Calling", "cargo", "build"] + opts) for key in env: print((key, env[key])) @@ -756,7 +756,8 @@ class MachCommands(CommandBase): def clean(self, manifest_path=None, params=[], verbose=False): self.ensure_bootstrapped() - virtualenv_path = path.join(self.get_top_dir(), 'python', '_virtualenv') + virtualenv_fname = '_virtualenv%d.%d' % (sys.version_info[0], sys.version_info[1]) + virtualenv_path = path.join(self.get_top_dir(), 'python', virtualenv_fname) if path.exists(virtualenv_path): print('Removing virtualenv directory: %s' % virtualenv_path) shutil.rmtree(virtualenv_path) @@ -797,7 +798,7 @@ def angle_root(target, nuget_env): } angle_arch = arch[target.split('-')[0]] angle_default_path = path.join(os.getcwd(), "support", "hololens", "packages", - "ANGLE.WindowsStore.Servo.2.1.15", "bin", "UAP", angle_arch) + "ANGLE.WindowsStore.Servo.2.1.16", "bin", "UAP", angle_arch) # Nuget executable command nuget_app = path.join(os.getcwd(), "support", "hololens", "ServoApp.sln") diff --git a/python/servo/command_base.py b/python/servo/command_base.py index 7473b78844d..7c82acaa534 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -27,6 +27,7 @@ import six import sys import tarfile import zipfile +import functools from xml.etree.ElementTree import XML from servo.util import download_file import six.moves.urllib as urllib @@ -103,13 +104,13 @@ def archive_deterministically(dir_to_archive, dest_archive, prepend_path=None): # Sort file entries with the fixed locale with setlocale('C'): - file_list.sort(cmp=locale.strcoll) + file_list.sort(key=functools.cmp_to_key(locale.strcoll)) # Use a temporary file and atomic rename to avoid partially-formed # packaging (in case of exceptional situations like running out of disk space). # TODO do this in a temporary folder after #11983 is fixed temp_file = '{}.temp~'.format(dest_archive) - with os.fdopen(os.open(temp_file, os.O_WRONLY | os.O_CREAT, 0o644), 'w') as out_file: + with os.fdopen(os.open(temp_file, os.O_WRONLY | os.O_CREAT, 0o644), 'wb') as out_file: if dest_archive.endswith('.zip'): with zipfile.ZipFile(temp_file, 'w', zipfile.ZIP_DEFLATED) as zip_file: for entry in file_list: @@ -257,7 +258,7 @@ def gstreamer_root(target, env, topdir=None): return env.get(gst_env) elif os.path.exists(path.join(gst_default_path, "bin", "ffi-7.dll")): return gst_default_path - elif sys.platform == "linux2": + elif is_linux(): return path.join(topdir, "support", "linux", "gstreamer", "gst") return None @@ -323,6 +324,7 @@ class CommandBase(object): self.config["build"].setdefault("mode", "") self.config["build"].setdefault("debug-assertions", False) self.config["build"].setdefault("debug-mozjs", False) + self.config["build"].setdefault("layout-2020", False) self.config["build"].setdefault("ccache", "") self.config["build"].setdefault("rustflags", "") self.config["build"].setdefault("incremental", None) @@ -579,7 +581,7 @@ class CommandBase(object): if "x86_64" not in effective_target or "android" in effective_target: # We don't build gstreamer for non-x86_64 / android yet return False - if sys.platform == "linux2" or is_windows(): + if is_linux() or is_windows(): if path.isdir(gstreamer_root(effective_target, env, self.get_top_dir())): return True else: @@ -626,7 +628,7 @@ install them, let us know by filing a bug!") def build_env(self, hosts_file_path=None, target=None, is_build=False, test_unit=False, uwp=False, features=None): """Return an extended environment dictionary.""" env = os.environ.copy() - if sys.platform == "win32" and type(env['PATH']) == unicode: + if sys.platform == "win32" and type(env['PATH']) == six.text_type: # On win32, the virtualenv's activate_this.py script sometimes ends up # turning os.environ['PATH'] into a unicode string. This doesn't work # for passing env vars in to a process, so we force it back to ascii. @@ -689,7 +691,7 @@ install them, let us know by filing a bug!") extra_lib = [libpath] + extra_lib append_to_path_env(path.join(libpath, "pkgconfig"), env, "PKG_CONFIG_PATH") - if sys.platform == "linux2": + if is_linux(): distrib, version, _ = distro.linux_distribution() distrib = six.ensure_str(distrib) version = six.ensure_str(version) @@ -849,6 +851,7 @@ install them, let us know by filing a bug!") ), CommandArgument('--with-raqote', default=None, action='store_true'), CommandArgument('--with-layout-2020', default=None, action='store_true'), + CommandArgument('--with-layout-2013', default=None, action='store_true'), CommandArgument('--without-wgl', default=None, action='store_true'), ] @@ -887,7 +890,8 @@ install them, let us know by filing a bug!") env=None, verbose=False, target=None, android=False, magicleap=False, libsimpleservo=False, features=None, debug_mozjs=False, with_debug_assertions=False, - with_frame_pointer=False, with_raqote=False, with_layout_2020=False, without_wgl=False, + with_frame_pointer=False, with_raqote=False, without_wgl=False, + with_layout_2020=False, with_layout_2013=False, uwp=False, media_stack=None, ): env = env or self.build_env() @@ -925,9 +929,9 @@ install them, let us know by filing a bug!") features.append("egl") if with_raqote and "canvas2d-azure" not in features: features.append("canvas2d-raqote") - elif "canvas2d-raqote" not in features: - features.append("canvas2d-azure") - if with_layout_2020 and "layout-2013" not in features: + elif "canvas2d-azure" not in features: + features.append("canvas2d-raqote") + if with_layout_2020 or (self.config["build"]["layout-2020"] and not with_layout_2013): features.append("layout-2020") elif "layout-2020" not in features: features.append("layout-2013") diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index f094ad9bb1b..c60f2d23be1 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -68,6 +68,7 @@ TEST_SUITES_BY_PREFIX = {path: k for k, v in iteritems(TEST_SUITES) if "paths" i def create_parser_wpt(): + import mozlog.commandline parser = wptcommandline.create_parser() parser.add_argument('--release', default=False, action="store_true", help="Run with a release build of servo") @@ -77,6 +78,8 @@ def create_parser_wpt(): help="Pass preferences to servo") parser.add_argument('--layout-2020', default=False, action="store_true", help="Use expected results for the 2020 layout engine") + parser.add_argument('--log-servojson', action="append", type=mozlog.commandline.log_file, + help="Servo's JSON logger of unexpected results") parser.add_argument('--always-succeed', default=False, action="store_true", help="Always yield exit code of zero") return parser @@ -511,7 +514,7 @@ class MachCommands(CommandBase): description='Given a WPT error summary file, filter out intermittents and other cruft.', category='testing') @CommandArgument('summary', - help="Error summary log to take un") + help="Error summary log to take in") @CommandArgument('--log-filteredsummary', default=None, help='Print filtered log to file') @CommandArgument('--log-intermittents', default=None, @@ -529,10 +532,7 @@ class MachCommands(CommandBase): encoded_auth = base64.encodestring(file.read().strip()).replace('\n', '') failures = [] with open(summary, "r") as file: - for line in file: - line_json = json.loads(line) - if 'status' in line_json: - failures += [line_json] + failures = [json.loads(line) for line in file] actual_failures = [] intermittents = [] for failure in failures: @@ -546,10 +546,7 @@ class MachCommands(CommandBase): request = urllib.request.Request("%s/query.py?name=%s" % (tracker_api, query)) search = urllib.request.urlopen(request) data = json.load(search) - if len(data) == 0: - actual_failures += [failure] - else: - intermittents += [failure] + is_intermittent = len(data) > 0 else: qstr = "repo:servo/servo+label:I-intermittent+type:issue+state:open+%s" % failure['test'] # we want `/` to get quoted, but not `+` (github's API doesn't like that), so we set `safe` to `+` @@ -559,28 +556,30 @@ class MachCommands(CommandBase): request.add_header("Authorization", "Basic %s" % encoded_auth) search = urllib.request.urlopen(request) data = json.load(search) - if data['total_count'] == 0: - actual_failures += [failure] - else: - intermittents += [failure] + is_intermittent = data['total_count'] > 0 + + if is_intermittent: + intermittents.append(failure["output"]) + else: + actual_failures.append(failure["output"]) + + def format(outputs, description, file=sys.stdout): + formatted = "%s %s:\n%s" % (len(outputs), description, "\n".join(outputs)) + file.write(formatted.encode("utf-8")) if log_intermittents: - with open(log_intermittents, "w") as intermittents_file: - for intermittent in intermittents: - json.dump(intermittent, intermittents_file, indent=4) - print("\n", end='', file=intermittents_file) + with open(log_intermittents, "wb") as file: + format(intermittents, "known-intermittent unexpected results", file) - output = open(log_filteredsummary, "w") if log_filteredsummary else sys.stdout - for failure in actual_failures: - json.dump(failure, output, indent=4) - print("\n", end='', file=output) + description = "unexpected results that are NOT known-intermittents" + if log_filteredsummary: + with open(log_filteredsummary, "wb") as file: + format(actual_failures, description, file) - if output is not sys.stdout: - output.close() + if actual_failures: + format(actual_failures, description) - if len(actual_failures) == 0: - return 0 - return 1 + return bool(actual_failures) @Command('test-android-startup', description='Extremely minimal testing of Servo for Android', @@ -701,20 +700,20 @@ class MachCommands(CommandBase): width_col4 = max([len(str(x)) for x in result['Difference(%)']]) for p, q, r, s in zip(['Test'], ['First Run'], ['Second Run'], ['Difference(%)']): - print ("\033[1m" + "{}|{}|{}|{}".format(p.ljust(width_col1), q.ljust(width_col2), r.ljust(width_col3), - s.ljust(width_col4)) + "\033[0m" + "\n" + "--------------------------------------------------" - + "-------------------------------------------------------------------------") + print("\033[1m" + "{}|{}|{}|{}".format(p.ljust(width_col1), q.ljust(width_col2), r.ljust(width_col3), + s.ljust(width_col4)) + "\033[0m" + "\n" + "--------------------------------------------------" + + "-------------------------------------------------------------------------") for a1, b1, c1, d1 in zip(result['Test'], result['Prev_Time'], result['Cur_Time'], result['Difference(%)']): if d1 > 0: - print ("\033[91m" + "{}|{}|{}|{}".format(a1.ljust(width_col1), - str(b1).ljust(width_col2), str(c1).ljust(width_col3), str(d1).ljust(width_col4)) + "\033[0m") + print("\033[91m" + "{}|{}|{}|{}".format(a1.ljust(width_col1), + str(b1).ljust(width_col2), str(c1).ljust(width_col3), str(d1).ljust(width_col4)) + "\033[0m") elif d1 < 0: - print ("\033[92m" + "{}|{}|{}|{}".format(a1.ljust(width_col1), - str(b1).ljust(width_col2), str(c1).ljust(width_col3), str(d1).ljust(width_col4)) + "\033[0m") + print("\033[92m" + "{}|{}|{}|{}".format(a1.ljust(width_col1), + str(b1).ljust(width_col2), str(c1).ljust(width_col3), str(d1).ljust(width_col4)) + "\033[0m") else: - print ("{}|{}|{}|{}".format(a1.ljust(width_col1), str(b1).ljust(width_col2), - str(c1).ljust(width_col3), str(d1).ljust(width_col4))) + print("{}|{}|{}|{}".format(a1.ljust(width_col1), str(b1).ljust(width_col2), + str(c1).ljust(width_col3), str(d1).ljust(width_col4))) def jquery_test_runner(self, cmd, release, dev): self.ensure_bootstrapped() @@ -777,7 +776,7 @@ class MachCommands(CommandBase): def setup_clangfmt(env): cmd = "clang-format.exe" if sys.platform == "win32" else "clang-format" try: - version = check_output([cmd, "--version"], env=env).rstrip() + version = check_output([cmd, "--version"], env=env, universal_newlines=True).rstrip() print(version) if not version.startswith("clang-format version {}.".format(CLANGFMT_VERSION)): print("clang-format: wrong version (v{} required). Skipping CPP formatting.".format(CLANGFMT_VERSION)) @@ -786,7 +785,7 @@ def setup_clangfmt(env): print("clang-format not installed. Skipping CPP formatting.") return False, None, None gitcmd = ['git', 'ls-files'] - gitfiles = check_output(gitcmd + CLANGFMT_CPP_DIRS).splitlines() + gitfiles = check_output(gitcmd + CLANGFMT_CPP_DIRS, universal_newlines=True).splitlines() filtered = [line for line in gitfiles if line.endswith(".h") or line.endswith(".cpp")] return True, cmd, filtered |