diff options
Diffstat (limited to 'python')
-rw-r--r-- | python/requirements.txt | 2 | ||||
-rw-r--r-- | python/servo/build_commands.py | 32 | ||||
-rw-r--r-- | python/servo/command_base.py | 27 | ||||
-rw-r--r-- | python/servo/package_commands.py | 103 | ||||
-rw-r--r-- | python/servo/testing_commands.py | 5 | ||||
-rw-r--r-- | python/tidy/servo_tidy/tidy.py | 94 | ||||
-rw-r--r-- | python/tidy/servo_tidy_tests/duplicated_package.lock | 28 | ||||
-rw-r--r-- | python/tidy/servo_tidy_tests/script_thread.rs | 18 | ||||
-rw-r--r-- | python/tidy/servo_tidy_tests/test_tidy.py | 22 |
9 files changed, 212 insertions, 119 deletions
diff --git a/python/requirements.txt b/python/requirements.txt index 34794fd5031..8248a21e930 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -4,7 +4,7 @@ mozdebug == 0.1 mozinfo == 0.8 mozlog == 3.3 setuptools == 18.5 -toml == 0.9.1 +toml == 0.9.2 Mako == 1.0.4 # For Python linting diff --git a/python/servo/build_commands.py b/python/servo/build_commands.py index 514a8f87e69..bd09221d56f 100644 --- a/python/servo/build_commands.py +++ b/python/servo/build_commands.py @@ -24,7 +24,7 @@ from mach.decorators import ( Command, ) -from servo.command_base import CommandBase, cd, call, BIN_SUFFIX, host_triple +from servo.command_base import CommandBase, cd, call, BIN_SUFFIX, host_triple, find_dep_path_newest def format_duration(seconds): @@ -384,6 +384,9 @@ class MachCommands(CommandBase): @Command('build-geckolib', description='Build a static library of components used by Gecko', category='build') + @CommandArgument('--with-gecko', + default=None, + help='Build with Gecko dist directory') @CommandArgument('--jobs', '-j', default=None, help='Number of jobs to run in parallel') @@ -393,12 +396,19 @@ class MachCommands(CommandBase): @CommandArgument('--release', '-r', action='store_true', help='Build in release mode') - def build_geckolib(self, jobs=None, verbose=False, release=False): + def build_geckolib(self, with_gecko=None, jobs=None, verbose=False, release=False): self.set_use_stable_rust() self.ensure_bootstrapped() + env = self.build_env(is_build=True) + geckolib_build_path = path.join(self.context.topdir, "target", "geckolib").encode("UTF-8") + env["CARGO_TARGET_DIR"] = geckolib_build_path + ret = None opts = [] + if with_gecko is not None: + opts += ["--features", "bindgen"] + env["MOZ_DIST"] = path.abspath(with_gecko) if jobs is not None: opts += ["-j", jobs] if verbose: @@ -406,8 +416,13 @@ class MachCommands(CommandBase): if release: opts += ["--release"] - env = self.build_env(is_build=True) - env["CARGO_TARGET_DIR"] = path.join(self.context.topdir, "target", "geckolib").encode("UTF-8") + if with_gecko is not None: + print("Generating atoms data...") + run_file = path.join(self.context.topdir, "components", + "style", "binding_tools", "regen_atoms.py") + run_globals = {"__file__": run_file} + execfile(run_file, run_globals) + run_globals["generate_atoms"](env["MOZ_DIST"]) build_start = time() with cd(path.join("ports", "geckolib")): @@ -419,6 +434,15 @@ class MachCommands(CommandBase): print("GeckoLib build completed in %s" % format_duration(elapsed)) + if with_gecko is not None: + print("Copying binding files to style/gecko_bindings...") + build_path = path.join(geckolib_build_path, "release" if release else "debug", "") + target_style_path = find_dep_path_newest("style", build_path) + out_gecko_path = path.join(target_style_path, "out", "gecko") + bindings_path = path.join(self.context.topdir, "components", "style", "gecko_bindings") + for f in ["bindings.rs", "structs_debug.rs", "structs_release.rs"]: + shutil.copy(path.join(out_gecko_path, f), bindings_path) + return ret @Command('clean', diff --git a/python/servo/command_base.py b/python/servo/command_base.py index 9fc797b28f9..b0f62e65061 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -50,12 +50,14 @@ def setlocale(name): def find_dep_path_newest(package, bin_path): deps_path = path.join(path.split(bin_path)[0], "build") + candidates = [] with cd(deps_path): - candidates = glob(package + '-*') - candidates = (path.join(deps_path, c) for c in candidates) - candidate_times = sorted(((path.getmtime(c), c) for c in candidates), reverse=True) - if len(candidate_times) > 0: - return candidate_times[0][1] + for c in glob(package + '-*'): + candidate_path = path.join(deps_path, c) + if path.exists(path.join(candidate_path, "output")): + candidates.append(candidate_path) + if candidates: + return max(candidates, key=lambda c: path.getmtime(path.join(c, "output"))) return None @@ -216,7 +218,10 @@ def is_linux(): def set_osmesa_env(bin_path, env): """Set proper LD_LIBRARY_PATH and DRIVE for software rendering on Linux and OSX""" if is_linux(): - osmesa_path = path.join(find_dep_path_newest('osmesa-src', bin_path), "out", "lib", "gallium") + dep_path = find_dep_path_newest('osmesa-src', bin_path) + if not dep_path: + return None + osmesa_path = path.join(dep_path, "out", "lib", "gallium") env["LD_LIBRARY_PATH"] = osmesa_path env["GALLIUM_DRIVER"] = "softpipe" elif is_macosx(): @@ -224,6 +229,8 @@ def set_osmesa_env(bin_path, env): "out", "src", "gallium", "targets", "osmesa", ".libs") glapi_path = path.join(find_dep_path_newest('osmesa-src', bin_path), "out", "src", "mapi", "shared-glapi", ".libs") + if not (osmesa_path and glapi_path): + return None env["DYLD_LIBRARY_PATH"] = osmesa_path + ":" + glapi_path env["GALLIUM_DRIVER"] = "softpipe" return env @@ -297,6 +304,7 @@ class CommandBase(object): self.config["build"].setdefault("mode", "") self.config["build"].setdefault("debug-mozjs", False) self.config["build"].setdefault("ccache", "") + self.config["build"].setdefault("rustflags", "") self.config.setdefault("android", {}) self.config["android"].setdefault("sdk", "") @@ -420,6 +428,10 @@ class CommandBase(object): # Link moztools env["MOZTOOLS_PATH"] = path.join(msvc_deps_dir, "moztools", "bin") + if is_windows(): + if not os.environ.get("NATIVE_WIN32_PYTHON"): + env["NATIVE_WIN32_PYTHON"] = sys.executable + if not self.config["tools"]["system-rust"] \ or self.config["tools"]["rust-root"]: env["RUST_ROOT"] = self.config["tools"]["rust-root"] @@ -486,6 +498,9 @@ class CommandBase(object): env['RUSTDOC'] = path.join(self.context.topdir, 'etc', 'rustdoc-with-private') + if self.config["build"]["rustflags"]: + env['RUSTFLAGS'] = env.get('RUSTFLAGS', "") + " " + self.config["build"]["rustflags"] + # Don't run the gold linker if on Windows https://github.com/servo/servo/issues/9499 if self.config["tools"]["rustc-with-gold"] and sys.platform not in ("win32", "msys"): if subprocess.call(['which', 'ld.gold'], stdout=PIPE, stderr=PIPE) == 0: diff --git a/python/servo/package_commands.py b/python/servo/package_commands.py index 103238a6e55..19935e13f4a 100644 --- a/python/servo/package_commands.py +++ b/python/servo/package_commands.py @@ -152,13 +152,13 @@ class PackageCommands(CommandBase): return e.returncode elif is_macosx(): - dir_to_build = '/'.join(binary_path.split('/')[:-1]) - dir_to_root = '/'.join(binary_path.split('/')[:-3]) + dir_to_build = path.dirname(binary_path) + dir_to_root = self.get_top_dir() print("Creating Servo.app") - dir_to_dmg = '/'.join(binary_path.split('/')[:-2]) + '/dmg' - dir_to_app = dir_to_dmg + '/Servo.app' - dir_to_resources = dir_to_app + '/Contents/Resources/' + dir_to_dmg = path.join(dir_to_build, 'dmg') + dir_to_app = path.join(dir_to_dmg, 'Servo.app') + dir_to_resources = path.join(dir_to_app, 'Contents', 'Resources') if path.exists(dir_to_dmg): print("Cleaning up from previous packaging") delete(dir_to_dmg) @@ -168,19 +168,23 @@ class PackageCommands(CommandBase): return 1 print("Copying files") - shutil.copytree(dir_to_root + '/resources', dir_to_resources) - shutil.copytree(browserhtml_path, dir_to_resources + browserhtml_path.split('/')[-1]) - shutil.copy2(dir_to_root + '/Info.plist', dir_to_app + '/Contents/Info.plist') - os.makedirs(dir_to_app + '/Contents/MacOS/') - shutil.copy2(dir_to_build + '/servo', dir_to_app + '/Contents/MacOS/') + shutil.copytree(path.join(dir_to_root, 'resources'), dir_to_resources) + shutil.copytree(browserhtml_path, path.join(dir_to_resources, path.basename(browserhtml_path))) + shutil.copy2(path.join(dir_to_root, 'Info.plist'), path.join(dir_to_app, 'Contents', 'Info.plist')) + + content_dir = path.join(dir_to_app, 'Contents', 'MacOS') + os.makedirs(content_dir) + shutil.copy2(binary_path, content_dir) print("Swapping prefs") - delete(dir_to_resources + '/prefs.json') - shutil.copy2(dir_to_resources + 'package-prefs.json', dir_to_resources + 'prefs.json') - delete(dir_to_resources + '/package-prefs.json') + package_prefs_path = path.join(dir_to_resources, 'package-prefs.json') + prefs_path = path.join(dir_to_resources, 'prefs.json') + delete(prefs_path) + shutil.copy2(package_prefs_path, prefs_path) + delete(package_prefs_path) print("Finding dylibs and relinking") - copy_dependencies(dir_to_app + '/Contents/MacOS/servo', dir_to_app + '/Contents/MacOS/') + copy_dependencies(path.join(content_dir, 'servo'), content_dir) print("Adding version to Credits.rtf") version_command = [binary_path, '--version'] @@ -193,8 +197,8 @@ class PackageCommands(CommandBase): raise Exception("Error occurred when getting Servo version: " + stderr) version = "Nightly version: " + version - template_path = os.path.join(dir_to_resources, 'Credits.rtf.mako') - credits_path = os.path.join(dir_to_resources, 'Credits.rtf') + template_path = path.join(dir_to_resources, 'Credits.rtf.mako') + credits_path = path.join(dir_to_resources, 'Credits.rtf') with open(template_path) as template_file: template = mako.template.Template(template_file.read()) with open(credits_path, "w") as credits_file: @@ -202,15 +206,19 @@ class PackageCommands(CommandBase): delete(template_path) print("Writing run-servo") - bhtml_path = path.join('${0%/*}/../Resources', browserhtml_path.split('/')[-1], 'out', 'index.html') - runservo = os.open(dir_to_app + '/Contents/MacOS/run-servo', os.O_WRONLY | os.O_CREAT, int("0755", 8)) + bhtml_path = path.join('${0%/*}', '..', 'Resources', path.basename(browserhtml_path), 'out', 'index.html') + runservo = os.open( + path.join(content_dir, 'run-servo'), + os.O_WRONLY | os.O_CREAT, + int("0755", 8) + ) os.write(runservo, '#!/bin/bash\nexec ${0%/*}/servo ' + bhtml_path) os.close(runservo) print("Creating dmg") - os.symlink('/Applications', dir_to_dmg + '/Applications') - dmg_path = '/'.join(dir_to_build.split('/')[:-1]) + '/' - dmg_path += "servo-tech-demo.dmg" + os.symlink('/Applications', path.join(dir_to_dmg, 'Applications')) + dmg_path = path.join(dir_to_build, "servo-tech-demo.dmg") + try: subprocess.check_call(['hdiutil', 'create', '-volname', 'Servo', dmg_path, '-srcfolder', dir_to_dmg]) except subprocess.CalledProcessError as e: @@ -221,24 +229,24 @@ class PackageCommands(CommandBase): print("Packaged Servo into " + dmg_path) print("Creating brew package") - dir_to_brew = '/'.join(binary_path.split('/')[:-2]) + '/brew_tmp/' - dir_to_tar = '/'.join(dir_to_build.split('/')[:-1]) + '/brew/' + dir_to_brew = path.join(dir_to_build, 'brew_tmp') + dir_to_tar = path.join(dir_to_build, 'brew') if not path.exists(dir_to_tar): os.makedirs(dir_to_tar) - tar_path = dir_to_tar + "servo.tar.gz" + tar_path = path.join(dir_to_tar, "servo.tar.gz") if path.exists(dir_to_brew): print("Cleaning up from previous packaging") delete(dir_to_brew) if path.exists(tar_path): print("Deleting existing package") os.remove(tar_path) - shutil.copytree(dir_to_root + '/resources', dir_to_brew + "/resources/") - os.makedirs(dir_to_brew + '/bin/') - shutil.copy2(dir_to_build + '/servo', dir_to_brew + '/bin/servo') + shutil.copytree(path.join(dir_to_root, 'resources'), path.join(dir_to_brew, 'resources')) + os.makedirs(path.join(dir_to_brew, 'bin')) + shutil.copy2(binary_path, path.join(dir_to_brew, 'bin', 'servo')) # Note that in the context of Homebrew, libexec is reserved for private use by the formula # and therefore is not symlinked into HOMEBREW_PREFIX. - os.makedirs(dir_to_brew + '/libexec/') - copy_dependencies(dir_to_brew + '/bin/servo', dir_to_brew + '/libexec/') + os.makedirs(path.join(dir_to_brew, 'libexec')) + copy_dependencies(path.join(dir_to_brew, 'bin', 'servo'), path.join(dir_to_brew, 'libexec')) archive_deterministically(dir_to_brew, tar_path, prepend_path='servo/') delete(dir_to_brew) print("Packaged Servo into " + tar_path) @@ -283,7 +291,7 @@ class PackageCommands(CommandBase): msi_path = path.join(dir_to_msi, "Servo.msi") print("Packaged Servo into {}".format(msi_path)) else: - dir_to_temp = path.join(os.path.dirname(binary_path), 'packaging-temp') + dir_to_temp = path.join(path.dirname(binary_path), 'packaging-temp') browserhtml_path = find_dep_path_newest('browserhtml', binary_path) if browserhtml_path is None: print("Could not find browserhtml package; perhaps you haven't built Servo.") @@ -307,12 +315,12 @@ class PackageCommands(CommandBase): '--pref', 'shell.builtin-key-shortcuts.enabled=false', path.join('./browserhtml', 'out', 'index.html')] - runservo = os.open(dir_to_temp + '/runservo.sh', os.O_WRONLY | os.O_CREAT, int("0755", 8)) + runservo = os.open(path.join(dir_to_temp, 'runservo.sh'), os.O_WRONLY | os.O_CREAT, int("0755", 8)) os.write(runservo, "#!/usr/bin/env sh\n./servo " + ' '.join(servo_args)) os.close(runservo) print("Creating tarball") - tar_path = path.join(self.get_target_dir(), 'servo-tech-demo.tar.gz') + tar_path = path.join(path.dirname(binary_path), 'servo-tech-demo.tar.gz') archive_deterministically(dir_to_temp, tar_path, prepend_path='servo/') @@ -321,33 +329,44 @@ class PackageCommands(CommandBase): print("Packaged Servo into " + tar_path) @Command('install', - description='Install Servo (currently, Android only)', + description='Install Servo (currently, Android and Windows only)', category='package') @CommandArgument('--release', '-r', action='store_true', help='Install the release build') @CommandArgument('--dev', '-d', action='store_true', help='Install the dev build') - def install(self, release=False, dev=False): + @CommandArgument('--android', + action='store_true', + help='Install on Android') + def install(self, release=False, dev=False, android=False): try: - binary_path = self.get_binary_path(release, dev, android=True) + binary_path = self.get_binary_path(release, dev, android=android) except BuildNotFound: print("Servo build not found. Building servo...") result = Registrar.dispatch( - "build", context=self.context, release=release, dev=dev + "build", context=self.context, release=release, dev=dev, android=android ) if result: return result try: - binary_path = self.get_binary_path(release, dev, android=True) + binary_path = self.get_binary_path(release, dev, android=android) except BuildNotFound: print("Rebuilding Servo did not solve the missing build problem.") return 1 - apk_path = binary_path + ".apk" - if not path.exists(apk_path): - result = Registrar.dispatch("package", context=self.context, release=release, dev=dev) + if android: + pkg_path = binary_path + ".apk" + exec_command = ["adb", "install", "-r", pkg_path] + elif is_windows(): + pkg_path = path.join(path.dirname(binary_path), 'msi', 'Servo.msi') + exec_command = ["msiexec", "/i", pkg_path] + + if not path.exists(pkg_path): + result = Registrar.dispatch( + "package", context=self.context, release=release, dev=dev, android=android + ) if result != 0: return result - print(["adb", "install", "-r", apk_path]) - return subprocess.call(["adb", "install", "-r", apk_path], env=self.build_env()) + print(" ".join(exec_command)) + return subprocess.call(exec_command, env=self.build_env()) diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index a2c752aeebc..3351984290d 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -734,8 +734,9 @@ class MachCommands(CommandBase): # On Linux and mac, find the OSMesa software rendering library and # add it to the dynamic linker search path. try: - args = [self.get_binary_path(use_release, not use_release)] - set_osmesa_env(args[0], os.environ) + bin_path = self.get_binary_path(use_release, not use_release) + if not set_osmesa_env(bin_path, os.environ): + print("Warning: Cannot set the path to OSMesa library.") except BuildNotFound: # This can occur when cross compiling (e.g. arm64), in which case # we won't run the tests anyway so can safely ignore this step. diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py index b40bdd67194..cae431205f8 100644 --- a/python/tidy/servo_tidy/tidy.py +++ b/python/tidy/servo_tidy/tidy.py @@ -33,10 +33,10 @@ config = { "lint-scripts": [], "ignore": { "files": [ - "./.", # ignore hidden files + os.path.join(".", "."), # ignore hidden files ], "directories": [ - "./.", # ignore hidden directories + os.path.join(".", "."), # ignore hidden directories ], "packages": [], }, @@ -90,6 +90,10 @@ def is_iter_empty(iterator): return False, iterator +def normilize_paths(paths): + return [os.path.join(*path.split('/')) for path in paths] + + # A simple wrapper for iterators to show progress # (Note that it's inefficient for giant iterators, since it iterates once to get the upper bound) def progress_wrapper(iterator): @@ -123,11 +127,9 @@ class FileList(object): args = ["git", "log", "-n1", "--merges", "--format=%H"] last_merge = subprocess.check_output(args).strip() args = ["git", "diff", "--name-only", last_merge, self.directory] - file_list = subprocess.check_output(args) + file_list = normilize_paths(subprocess.check_output(args).splitlines()) - for f in file_list.splitlines(): - if sys.platform == 'win32': - os.path.join(*f.split('/')) + for f in file_list: if not any(os.path.join('.', os.path.dirname(f)).startswith(path) for path in self.excluded): yield os.path.join('.', f) @@ -299,61 +301,42 @@ def check_flake8(file_name, contents): def check_lock(file_name, contents): - def find_reverse_dependencies(dependency, version, content): - dependency_prefix = "{} {}".format(dependency, version) + def find_reverse_dependencies(name, content): for package in itertools.chain([content["root"]], content["package"]): for dependency in package.get("dependencies", []): - if dependency.startswith(dependency_prefix): - yield package["name"] + if dependency.startswith("{} ".format(name)): + yield package["name"], dependency if not file_name.endswith(".lock"): raise StopIteration - # package names to be neglected (as named by cargo) + # Package names to be neglected (as named by cargo) exceptions = config["ignore"]["packages"] - # toml.py has a bug(?) that we trip up in [metadata] sections; - # see https://github.com/uiri/toml/issues/61 - # This should only affect a very few lines (that have embedded ?branch=...), - # and most of them won't be in the repo - try: - content = toml.loads(contents) - except: - print "WARNING!" - print "WARNING! toml parsing failed for Cargo.lock, but ignoring..." - print "WARNING!" - raise StopIteration + content = toml.loads(contents) - packages = {} + packages_by_name = {} for package in content.get("package", []): - packages.setdefault(package["name"], []).append(package["version"]) + source = package.get("source", "") + if source == r"registry+https://github.com/rust-lang/crates.io-index": + source = "crates.io" + packages_by_name.setdefault(package["name"], []).append((package["version"], source)) - for (name, versions) in packages.iteritems(): - if name in exceptions or len(versions) <= 1: + for (name, packages) in packages_by_name.iteritems(): + if name in exceptions or len(packages) <= 1: continue - highest = max(versions) - for version in versions: - if version != highest: - reverse_dependencies = "\n".join( - "\t\t{}".format(n) - for n in find_reverse_dependencies(name, version, content) - ) - substitutions = { - "package": name, - "old_version": version, - "new_version": highest, - "reverse_dependencies": reverse_dependencies - } - message = """ -duplicate versions for package "{package}" -\t\033[93mfound dependency on version {old_version}\033[0m -\t\033[91mbut highest version is {new_version}\033[0m -\t\033[93mtry upgrading with\033[0m \033[96m./mach cargo-update -p {package}:{old_version}\033[0m -\tThe following packages depend on version {old_version}: -{reverse_dependencies} -""".format(**substitutions).strip() - yield (1, message) + message = "duplicate versions for package `{}`".format(name) + packages.sort() + packages_dependencies = list(find_reverse_dependencies(name, content)) + for version, source in packages: + short_source = source.split("#")[0].replace("git+", "") + message += "\n\t\033[93mThe following packages depend on version {} from '{}':\033[0m" \ + .format(version, short_source) + for name, dependency in packages_dependencies: + if version in dependency and short_source in dependency: + message += "\n\t\t" + name + yield (1, message) def check_toml(file_name, lines): @@ -542,6 +525,9 @@ def check_rust(file_name, lines): lambda match, line: line.startswith('use ')), (r"^\s*else {", "else braces should be on the same line", no_filter), (r"[^$ ]\([ \t]", "extra space after (", no_filter), + # This particular pattern is not reentrant-safe in script_thread.rs + (r"match self.documents.borrow", "use a separate variable for the match expression", + lambda match, line: file_name.endswith('script_thread.rs')), ] for pattern, message, filter_func in regex_rules: @@ -859,23 +845,17 @@ def parse_config(content): config_file = toml.loads(content) exclude = config_file.get("ignore", {}) # Add list of ignored directories to config - config["ignore"]["directories"] += exclude.get("directories", []) + config["ignore"]["directories"] += normilize_paths(exclude.get("directories", [])) # Add list of ignored files to config - config["ignore"]["files"] += exclude.get("files", []) + config["ignore"]["files"] += normilize_paths(exclude.get("files", [])) # Add list of ignored packages to config config["ignore"]["packages"] = exclude.get("packages", []) - # Fix the paths (OS-dependent) - config['ignore']['files'] = map(lambda path: os.path.join(*path.split('/')), - config['ignore']['files']) - config['ignore']['directories'] = map(lambda path: os.path.join(*path.split('/')), - config['ignore']['directories']) # Add dict of dir, list of expected ext to config dirs_to_check = config_file.get("check_ext", {}) # Fix the paths (OS-dependent) for path, exts in dirs_to_check.items(): - fixed_path = os.path.join(*path.split('/')) - config['check_ext'][fixed_path] = exts + config['check_ext'][normilize_paths([path])[0]] = exts # Override default configs user_configs = config_file.get("configs", []) diff --git a/python/tidy/servo_tidy_tests/duplicated_package.lock b/python/tidy/servo_tidy_tests/duplicated_package.lock index 77777fdd82c..6075f99164c 100644 --- a/python/tidy/servo_tidy_tests/duplicated_package.lock +++ b/python/tidy/servo_tidy_tests/duplicated_package.lock @@ -15,7 +15,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "test2" version = "0.1.0" -source = "git+https://github.com/" +source = "git+https://github.com/user/test2#c54edsf" dependencies = [ "test 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", ] + +[[package]] +name = "test3" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "test3" +version = "0.5.1" +source = "git+https://github.com/user/test3#c54edsf" + +[[package]] +name = "test4" +version = "0.1.0" +source = "git+https://github.com/user/test4#c54edsf" +dependencies = [ + "test3 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "test5" +version = "0.1.0" +source = "git+https://github.com/" +dependencies = [ + "test3 0.5.1 (git+https://github.com/user/test3)", +] diff --git a/python/tidy/servo_tidy_tests/script_thread.rs b/python/tidy/servo_tidy_tests/script_thread.rs new file mode 100644 index 00000000000..5dbeaec0e17 --- /dev/null +++ b/python/tidy/servo_tidy_tests/script_thread.rs @@ -0,0 +1,18 @@ +fn main() { + // This should trigger an error. + match self.documents.borrow_mut() { + _ => {} + } + // This should trigger an error. + match self.documents.borrow() { + _ => {} + } + // This should not trigger an error. + match { self.documents.borrow().find_window(id) } { + => {} + } + // This should not trigger an error. + match self.documents_status.borrow() { + => {} + } +} diff --git a/python/tidy/servo_tidy_tests/test_tidy.py b/python/tidy/servo_tidy_tests/test_tidy.py index c6fe8bd83fa..7adcbda2dfe 100644 --- a/python/tidy/servo_tidy_tests/test_tidy.py +++ b/python/tidy/servo_tidy_tests/test_tidy.py @@ -141,6 +141,12 @@ class CheckTidiness(unittest.TestCase): self.assertEqual('method declared in webidl is missing a comment with a specification link', errors.next()[2]) self.assertNoMoreErrors(errors) + def test_script_thread(self): + errors = tidy.collect_errors_for_files(iterFile('script_thread.rs'), [], [tidy.check_rust], print_text=False) + self.assertEqual('use a separate variable for the match expression', errors.next()[2]) + self.assertEqual('use a separate variable for the match expression', errors.next()[2]) + self.assertNoMoreErrors(errors) + def test_webidl(self): errors = tidy.collect_errors_for_files(iterFile('spec.webidl'), [tidy.check_webidl_spec], [], print_text=False) self.assertEqual('No specification link found.', errors.next()[2]) @@ -194,13 +200,17 @@ class CheckTidiness(unittest.TestCase): def test_lock(self): errors = tidy.collect_errors_for_files(iterFile('duplicated_package.lock'), [tidy.check_lock], [], print_text=False) - msg = """duplicate versions for package "test" -\t\033[93mfound dependency on version 0.4.9\033[0m -\t\033[91mbut highest version is 0.5.1\033[0m -\t\033[93mtry upgrading with\033[0m \033[96m./mach cargo-update -p test:0.4.9\033[0m -\tThe following packages depend on version 0.4.9: -\t\ttest2""" + msg = """duplicate versions for package `test` +\t\x1b[93mThe following packages depend on version 0.4.9 from 'crates.io':\x1b[0m +\t\ttest2 +\t\x1b[93mThe following packages depend on version 0.5.1 from 'crates.io':\x1b[0m""" self.assertEqual(msg, errors.next()[2]) + msg2 = """duplicate versions for package `test3` +\t\x1b[93mThe following packages depend on version 0.5.1 from 'crates.io':\x1b[0m +\t\ttest4 +\t\x1b[93mThe following packages depend on version 0.5.1 from 'https://github.com/user/test3':\x1b[0m +\t\ttest5""" + self.assertEqual(msg2, errors.next()[2]) self.assertNoMoreErrors(errors) def test_lint_runner(self): |