Browse Source

Use same configs in ya style and style-tests
853c2293128f6f534d97c1a5c97204e1f72868cf

mikhnenko 11 months ago
parent
commit
d3b7159d42

+ 3 - 1
build/config/tests/cpp_style/config.clang-format

@@ -3,7 +3,9 @@ AccessModifierOffset: -4
 ConstructorInitializerIndentWidth: 4
 AlignEscapedNewlinesLeft: false
 AlignEscapedNewlines: Left
-AlignTrailingComments: true
+AlignTrailingComments:
+    Kind: Always
+    OverEmptyLines: 0
 AllowAllParametersOfDeclarationOnNextLine: true
 AllowShortBlocksOnASingleLine: false
 AllowShortIfStatementsOnASingleLine: false

+ 0 - 90
build/config/tests/cpp_style/config.clang-format-16

@@ -1,90 +0,0 @@
-Language:        Cpp
-AccessModifierOffset: -4
-ConstructorInitializerIndentWidth: 4
-AlignEscapedNewlinesLeft: false
-AlignEscapedNewlines: Left
-AlignTrailingComments:
-    Kind: Always
-    OverEmptyLines: 0
-AllowAllParametersOfDeclarationOnNextLine: true
-AllowShortBlocksOnASingleLine: false
-AllowShortIfStatementsOnASingleLine: false
-AllowShortLoopsOnASingleLine: false
-AllowShortFunctionsOnASingleLine: None
-AlwaysBreakTemplateDeclarations: true
-AlwaysBreakBeforeMultilineStrings: false
-BreakBeforeBinaryOperators: false
-BreakBeforeTernaryOperators: true
-BreakConstructorInitializersBeforeComma: true
-BinPackParameters: true
-ColumnLimit:     0
-ConstructorInitializerAllOnOneLineOrOnePerLine: false
-DerivePointerAlignment: false
-ExperimentalAutoDetectBinPacking: false
-IndentCaseLabels: true
-IndentWrappedFunctionNames: false
-IndentFunctionDeclarationAfterType: false
-MaxEmptyLinesToKeep: 1
-KeepEmptyLinesAtTheStartOfBlocks: false
-NamespaceIndentation: All
-ObjCSpaceAfterProperty: false
-ObjCSpaceBeforeProtocolList: true
-PenaltyBreakBeforeFirstCallParameter: 19
-PenaltyBreakComment: 300
-PenaltyBreakString: 1000
-PenaltyBreakFirstLessLess: 120
-PenaltyExcessCharacter: 1000000
-PenaltyReturnTypeOnItsOwnLine: 60
-PointerAlignment: Left
-SpacesBeforeTrailingComments: 1
-Cpp11BracedListStyle: true
-Standard:        c++20
-IndentWidth:     4
-TabWidth:        4
-UseTab:          Never
-BreakBeforeBraces: Attach
-
-BraceWrapping:
- AfterClass: false
- AfterControlStatement: false
- AfterEnum: false
- AfterFunction: false
- AfterNamespace: false
- AfterObjCDeclaration: false
- AfterStruct: false
- AfterUnion: false
- BeforeCatch: false
- BeforeElse: false
- IndentBraces: true
-
-SpacesInParentheses: false
-SpacesInAngles:  false
-SpaceInEmptyParentheses: false
-SpacesInCStyleCastParentheses: false
-SpacesInContainerLiterals: true
-SpaceBeforeAssignmentOperators: true
-ContinuationIndentWidth: 4
-CommentPragmas:  '^ IWYU pragma:'
-ForEachMacros:   [
-    foreach,
-    Q_FOREACH,
-    BOOST_FOREACH,
-    # Is not a foreach, but correct formatting is achieved
-    Y_DEFER
-]
-IfMacros: [
-    with_lock  # Is not an if, but correct formatting is achieved
-]
-SpaceBeforeParens: ControlStatements
-DisableFormat:   false
-SortIncludes: false
-IndentPPDirectives: BeforeHash
-
-NamespaceMacros: [Y_UNIT_TEST_SUITE, Y_UNIT_TEST]
-SpaceBeforeInheritanceColon: false
-AttributeMacros: [Y_PRINTF_FORMAT, Y_NO_SANITIZE, Y_FORCE_INLINE, Y_NO_INLINE, Y_WARN_UNUSED_RESULT, Y_HIDDEN, Y_PUBLIC, Y_PURE_FUNCTION]
-IndentExternBlock: Indent
-TypenameMacros: [Y_THREAD, Y_STATIC_THREAD, Y_POD_THREAD, Y_POD_STATIC_THREAD]
-SpacesInLineCommentPrefix:
- Minimum: 0
- Maximum: -1

+ 0 - 1
build/config/tests/cpp_style/ya.make

@@ -2,7 +2,6 @@ LIBRARY()
 
 RESOURCE_FILES(
     config.clang-format
-    config.clang-format-16
 )
 
 END()

+ 4 - 8
library/python/cpp_test/test_cpp.py

@@ -10,20 +10,16 @@ from library.python.testing.style import rules
 import library.python.resource as lpr
 
 
-STYLE_CONFIG_JSON_14 = json.dumps(yaml.safe_load(lpr.find('resfs/file/config.clang-format')))
-STYLE_CONFIG_JSON_16 = json.dumps(yaml.safe_load(lpr.find('resfs/file/config.clang-format-16')))
+# keep in sync with the logic in https://a.yandex-team.ru/arcadia/devtools/ya/handlers/style/cpp_style.py?rev=r12543375#L21
+STYLE_CONFIG_JSON = json.dumps(yaml.safe_load(lpr.find('resfs/file/config.clang-format')))
 
 RES_FILE_PREFIX = '/cpp_style/files/'
 CHECKED_PATHS = list(lpr.iterkeys(RES_FILE_PREFIX, strip_prefix=True))
 
 
 def check_style(filename, actual_source):
-    try:
-        clang_format_binary = yatest.common.binary_path('contrib/libs/clang14/tools/clang-format/clang-format')
-        config = STYLE_CONFIG_JSON_14
-    except Exception:
-        clang_format_binary = yatest.common.binary_path('contrib/libs/clang16/tools/clang-format/clang-format')
-        config = STYLE_CONFIG_JSON_16
+    clang_format_binary = yatest.common.binary_path('contrib/libs/clang16/tools/clang-format/clang-format')
+    config = STYLE_CONFIG_JSON
 
     command = [clang_format_binary, '-assume-filename=' + filename, '-style=' + config]
     styled_source = subprocess.check_output(command, input=actual_source)