Skip to content

Commit

Permalink
Auto merge of #24692 - paulrouget:checkcpp-tc, r=jdm
Browse files Browse the repository at this point in the history
Run test-tidy with CPP files check on Windows
  • Loading branch information
bors-servo committed Nov 8, 2019
2 parents 8cb6145 + 100ff06 commit 60c34ee
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 23 deletions.
16 changes: 11 additions & 5 deletions .clang-format
Expand Up @@ -17,7 +17,7 @@ AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true BinPackArguments: true
BinPackParameters: true BinPackParameters: true
BraceWrapping: BraceWrapping:
Expand All @@ -39,6 +39,7 @@ BraceWrapping:
BreakBeforeBinaryOperators: None BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon BreakConstructorInitializers: BeforeColon
Expand Down Expand Up @@ -79,6 +80,7 @@ MacroBlockBegin: ''
MacroBlockEnd: '' MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1 MaxEmptyLinesToKeep: 1
NamespaceIndentation: None NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2 ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true ObjCSpaceBeforeProtocolList: true
Expand All @@ -87,20 +89,21 @@ PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300 PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120 PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000 PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000 PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60 PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right PointerAlignment: Right
RawStringFormats:
- Delimiter: pb
Language: TextProto
BasedOnStyle: google
ReflowComments: true ReflowComments: true
SortIncludes: false SortIncludes: false
SortUsingDeclarations: true SortUsingDeclarations: true
SpaceAfterCStyleCast: false SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1 SpacesBeforeTrailingComments: 1
SpacesInAngles: false SpacesInAngles: false
Expand All @@ -109,6 +112,9 @@ SpacesInCStyleCastParentheses: false
SpacesInParentheses: false SpacesInParentheses: false
SpacesInSquareBrackets: false SpacesInSquareBrackets: false
Standard: Cpp11 Standard: Cpp11
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8 TabWidth: 8
UseTab: Never UseTab: Never
... ...
Expand Down
1 change: 1 addition & 0 deletions etc/taskcluster/decision_task.py
Expand Up @@ -434,6 +434,7 @@ def windows_uwp_x64():
windows_build_task("UWP dev build", package=False) windows_build_task("UWP dev build", package=False)
.with_treeherder("Windows x64") .with_treeherder("Windows x64")
.with_script( .with_script(
"python mach test-tidy --force-cpp",
"python mach build --dev --target=x86_64-uwp-windows-msvc", "python mach build --dev --target=x86_64-uwp-windows-msvc",
"python mach package --dev --target=x86_64-uwp-windows-msvc --uwp=x64", "python mach package --dev --target=x86_64-uwp-windows-msvc --uwp=x64",
) )
Expand Down
37 changes: 19 additions & 18 deletions python/servo/testing_commands.py
Expand Up @@ -49,6 +49,7 @@
SERVO_TESTS_PATH = os.path.join("tests", "wpt", "mozilla", "tests") SERVO_TESTS_PATH = os.path.join("tests", "wpt", "mozilla", "tests")


CLANGFMT_CPP_DIRS = ["support/hololens/"] CLANGFMT_CPP_DIRS = ["support/hololens/"]
CLANGFMT_VERSION = "8"


TEST_SUITES = OrderedDict([ TEST_SUITES = OrderedDict([
("tidy", {"kwargs": {"all_files": False, "no_progress": False, "self_test": False, ("tidy", {"kwargs": {"all_files": False, "no_progress": False, "self_test": False,
Expand Down Expand Up @@ -326,8 +327,8 @@ def install_rustfmt(self):
help="Run unit tests for tidy") help="Run unit tests for tidy")
@CommandArgument('--stylo', default=False, action="store_true", @CommandArgument('--stylo', default=False, action="store_true",
help="Only handle files in the stylo tree") help="Only handle files in the stylo tree")
@CommandArgument('--no-cpp', default=False, action="store_true", help="Skip CPP files") @CommandArgument('--force-cpp', default=False, action="store_true", help="Force CPP check")
def test_tidy(self, all_files, no_wpt, no_progress, self_test, stylo, no_cpp): def test_tidy(self, all_files, no_wpt, no_progress, self_test, stylo, force_cpp):
if self_test: if self_test:
return test_tidy.do_tests() return test_tidy.do_tests()
else: else:
Expand All @@ -340,14 +341,16 @@ def test_tidy(self, all_files, no_wpt, no_progress, self_test, stylo, no_cpp):
rustfmt_failed = self.call_rustup_run(["cargo", "fmt", "--", "--check"]) rustfmt_failed = self.call_rustup_run(["cargo", "fmt", "--", "--check"])


clangfmt_failed = False clangfmt_failed = False
if not no_cpp: available, cmd, files = setup_clangfmt()
available, cmd, files = setup_clangfmt() if available:
if available: for file in files:
for file in files: stdout = subprocess.check_output([cmd, "-output-replacements-xml", file])
stdout = subprocess.check_output([cmd, "-output-replacements-xml", file]) if len(XML(stdout)) > 0:
if len(XML(stdout)) > 0: print("%s is not formatted correctly." % file)
print("%s is not formatted correctly." % file) clangfmt_failed = True
clangfmt_failed = True elif force_cpp:
print("Error: can't find suitable clang-format version. Required with --force-cpp.")
return True


if rustfmt_failed or clangfmt_failed: if rustfmt_failed or clangfmt_failed:
print("Run `./mach fmt` to fix the formatting") print("Run `./mach fmt` to fix the formatting")
Expand Down Expand Up @@ -476,13 +479,11 @@ def update_manifest(self, **kwargs):
@Command('fmt', @Command('fmt',
description='Format the Rust and CPP source files with rustfmt and clang-format', description='Format the Rust and CPP source files with rustfmt and clang-format',
category='testing') category='testing')
@CommandArgument('--no-cpp', default=False, action="store_true", help="Skip CPP files") def format_code(self):
def format_code(self, no_cpp):


if not no_cpp: available, cmd, files = setup_clangfmt()
available, cmd, files = setup_clangfmt() if available and len(files) > 0:
if available and len(files) > 0: check_call([cmd, "-i"] + files)
check_call([cmd, "-i"] + files)


self.install_rustfmt() self.install_rustfmt()
return self.call_rustup_run(["cargo", "fmt"]) return self.call_rustup_run(["cargo", "fmt"])
Expand Down Expand Up @@ -802,8 +803,8 @@ def setup_clangfmt():
try: try:
version = subprocess.check_output([cmd, "--version"]).rstrip() version = subprocess.check_output([cmd, "--version"]).rstrip()
print(version) print(version)
if not version.startswith("clang-format version 6."): if not version.startswith("clang-format version {}.".format(CLANGFMT_VERSION)):
print("clang-format: wrong version (v6 required). Skipping CPP formatting.") print("clang-format: wrong version (v{} required). Skipping CPP formatting.".format(CLANGFMT_VERSION))
return False, None, None return False, None, None
except OSError: except OSError:
print("clang-format not installed. Skipping CPP formatting.") print("clang-format not installed. Skipping CPP formatting.")
Expand Down

0 comments on commit 60c34ee

Please sign in to comment.