Skip to content


Browse files Browse the repository at this point in the history
Run rustfmt on test-tidy
Add ./mach fmt command.
Mach installs rustfmt if needed.
  • Loading branch information
pyfisch committed Nov 6, 2018
1 parent 6878dbb commit bf47f90
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
13 changes: 0 additions & 13 deletions python/servo/
Expand Up @@ -233,19 +233,6 @@ def fetch(self):
with cd(self.context.topdir):
return self.call_rustup_run(["cargo", "fetch"], env=self.build_env())

description='Format the Rust code using Cargo fmt',
'--directory', '-d', default=None,
help='Command-line argument to specify the directory for formatting')
def rustfmt(self, directory=""):
if directory == "":
directory = self.context.topdir

with cd(self.context.topdir):
return self.call_rustup_run(["cargo", "fmt", "--", directory], env=self.build_env())

description='Invoke the ndk-stack tool with the expected symbol paths',
Expand Down
17 changes: 16 additions & 1 deletion python/servo/
Expand Up @@ -304,6 +304,12 @@ def test_content(self):
return 0

def install_rustfmt(self):
if self.call_rustup_run(["cargo", "fmt", "--version", "-q"],
stderr=open(os.devnull, "w")) != 0:
# Rustfmt is not installed. Install:
self.call_rustup_run(["rustup", "component", "add", "rustfmt-preview"])

description='Run the source code tidiness check',
Expand All @@ -322,7 +328,9 @@ def test_tidy(self, all_files, no_progress, self_test, stylo):
manifest_dirty = run_update(self.context.topdir, check_clean=True)
tidy_failed = tidy.scan(not all_files, not no_progress, stylo=stylo)
return tidy_failed or manifest_dirty
rustfmt_failed = self.call_rustup_run(["cargo", "fmt", "--", "--check"])
return tidy_failed or manifest_dirty or rustfmt_failed

description='Run the WebIDL parser tests',
Expand Down Expand Up @@ -443,6 +451,13 @@ def wptrunner(self, run_file, **kwargs):
def update_manifest(self, **kwargs):
return run_update(self.context.topdir, **kwargs)

description='Format the Rust source files with rustfmt',
def format_code(self, **kwargs):
return self.call_rustup_run(["cargo", "fmt"])

description='Update the web platform tests',
Expand Down

0 comments on commit bf47f90

Please sign in to comment.