Skip to content

[build] Verify that Sourcekit-LSP is correctly formatted #69516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions utils/build-presets.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1878,6 +1878,7 @@ assertions
swiftsyntax
swiftformat
swiftsyntax-lint
sourcekit-lsp-lint

[preset: buildbot_swiftformat_linux]
mixin-preset=mixin_swiftpm_package_linux_platform
Expand Down Expand Up @@ -1907,6 +1908,8 @@ mixin-preset=mixin_swiftpm_package_macos_platform
release
assertions
sourcekit-lsp
swiftformat
sourcekit-lsp-lint

[preset: buildbot_sourcekitlsp_linux,no_sanitize]
mixin-preset=mixin_swiftpm_package_linux_platform
Expand Down
3 changes: 3 additions & 0 deletions utils/build_swift/build_swift/driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,9 @@ def create_argument_parser():
option('--test-sourcekit-lsp-sanitize-all',
toggle_true('test_sourcekitlsp_sanitize_all'),
help='run sourcekit-lsp tests under all sanitizers')
option('--sourcekit-lsp-lint',
toggle_true('sourcekitlsp_lint'),
help='verify that sourcekit-lsp Source code is formatted correctly')
option('--install-swiftsyntax', toggle_true('install_swiftsyntax'),
help='install SwiftSyntax')
option('--swiftsyntax-verify-generated-files',
Expand Down
3 changes: 3 additions & 0 deletions utils/build_swift/tests/expected_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
'test_indexstoredb_sanitize_all': False,
'test_sourcekitlsp_sanitize_all': False,
'build_sourcekitlsp': False,
'sourcekitlsp_lint': False,
'install_llvm': False,
'install_swiftpm': False,
'install_swiftsyntax': False,
Expand Down Expand Up @@ -605,6 +606,8 @@ class BuildScriptImplOption(_BaseOption):
EnableOption('--sourcekit-lsp', dest='build_sourcekitlsp'),
EnableOption('--test-sourcekit-lsp-sanitize-all',
dest='test_sourcekitlsp_sanitize_all'),
EnableOption('--sourcekit-lsp-lint',
dest='sourcekitlsp_lint'),
EnableOption('--install-llvm', dest='install_llvm'),
EnableOption('--install-swiftsyntax', dest='install_swiftsyntax'),
EnableOption('--swiftsyntax-verify-generated-files',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def build(self, host_target):
self.run_build_script_helper('build', host_target)
if self.args.swiftsyntax_lint:
self.lint_swiftsyntax()
if self.args.sourcekitlsp_lint:
self.lint_sourcekitlsp()

def lint_swiftsyntax(self):
linting_cmd = [
Expand All @@ -97,6 +99,17 @@ def lint_swiftsyntax(self):
]
shell.call(linting_cmd)

def lint_sourcekitlsp(self):
linting_cmd = [
os.path.join(self.build_dir, self.configuration(), 'swift-format'),
'lint',
'--parallel',
'--strict',
'--recursive',
os.path.join(os.path.dirname(self.source_dir), 'sourcekit-lsp'),
]
shell.call(linting_cmd)

def should_test(self, host_target):
return self.args.test_swiftformat

Expand Down