aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/testing_commands.py
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-11-07 08:47:57 -0500
committerGitHub <noreply@github.com>2018-11-07 08:47:57 -0500
commitda2d9b2228441863feba2af2a60f84d2657fb962 (patch)
tree760c0eb675e95b46890480a9e10bc2c2cc714512 /python/servo/testing_commands.py
parent618a790050d8eab39e3c44b3d39dfefa7648445e (diff)
parent1855c88d6106c73febec1f5f29e246a75ff2f849 (diff)
downloadservo-da2d9b2228441863feba2af2a60f84d2657fb962.tar.gz
servo-da2d9b2228441863feba2af2a60f84d2657fb962.zip
Auto merge of #22126 - pyfisch:autoformat, r=jdm
Enforce rustfmt on CI <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22126) <!-- Reviewable:end -->
Diffstat (limited to 'python/servo/testing_commands.py')
-rw-r--r--python/servo/testing_commands.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py
index 506d20874a4..771d1746351 100644
--- a/python/servo/testing_commands.py
+++ b/python/servo/testing_commands.py
@@ -304,6 +304,13 @@ class MachCommands(CommandBase):
"tests/wpt/mozilla/.")
return 0
+ def install_rustfmt(self):
+ with open(os.devnull, "w") as devnull:
+ if self.call_rustup_run(["cargo", "fmt", "--version", "-q"],
+ stderr=devnull) != 0:
+ # Rustfmt is not installed. Install:
+ self.call_rustup_run(["rustup", "component", "add", "rustfmt-preview"])
+
@Command('test-tidy',
description='Run the source code tidiness check',
category='testing')
@@ -322,7 +329,9 @@ class MachCommands(CommandBase):
else:
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
+ self.install_rustfmt()
+ rustfmt_failed = self.call_rustup_run(["cargo", "fmt", "--", "--check"])
+ return tidy_failed or manifest_dirty or rustfmt_failed
@Command('test-webidl',
description='Run the WebIDL parser tests',
@@ -443,6 +452,13 @@ class MachCommands(CommandBase):
def update_manifest(self, **kwargs):
return run_update(self.context.topdir, **kwargs)
+ @Command('fmt',
+ description='Format the Rust source files with rustfmt',
+ category='testing')
+ def format_code(self, **kwargs):
+ self.install_rustfmt()
+ return self.call_rustup_run(["cargo", "fmt"])
+
@Command('update-wpt',
description='Update the web platform tests',
category='testing',