Skip to content

Improve _format command #3684

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
Aug 24, 2021
Merged

Conversation

keith
Copy link
Member

@keith keith commented Aug 23, 2021

This makes 2 changes to _format:

  1. Only invoke swift-format once, this is helpful for larger projects
  2. Include the Package.swift file for formatting

This makes 2 changes to `_format`:

1. Only invoke `swift-format` once, this is helpful for larger projects
2. Include the `Package.swift` file for formatting
@neonichu
Copy link
Contributor

@swift-ci please smoke test

@keith
Copy link
Member Author

keith commented Aug 23, 2021

I don't believe the failure here is related

@tomerd
Copy link
Contributor

tomerd commented Aug 23, 2021

@abertelrud this is something we should refactor out a plugin when the framework is ready. could you please review in that light.

@tomerd
Copy link
Contributor

tomerd commented Aug 23, 2021

@swift-ci please smoke test

@neonichu
Copy link
Contributor

Seems like this failure is new and reproduces, but unrelated to this PR:

10:56:17 Test Suite 'IntegrationTestsPackageTests.xctest' started at 2021-08-23 10:55:27.220
10:56:17 Test Suite 'XCBuildTests' started at 2021-08-23 10:55:27.220
10:56:17 Test Case '-[IntegrationTests.XCBuildTests testLibraryProductsAndTargets]' started.
10:56:17 
/Users/buildnode/jenkins/workspace/swift-package-manager-with-xcode-self-hosted-PR-osx/branch-main/swiftpm/IntegrationTests/Tests/IntegrationTests/XCBuildTests.swift:228: error: -[IntegrationTests.XCBuildTests testLibraryProductsAndTargets] : failed - Command failed with exit code: terminated(code: 1) - command: /Users/buildnode/jenkins/workspace/swift-package-manager-with-xcode-self-hosted-PR-osx/branch-main/swiftpm/.build/x86_64-apple-macosx/debug/swift-build --package-path /var/folders/_8/79jmzf2142z2xydc_01btlx00000gn/T/XCBuild_Libraries.WGF8ry/Foo --build-system xcode --target FooLib```

@neonichu
Copy link
Contributor

I can repro the failure locally.

@neonichu
Copy link
Contributor

Looks like some of the builds are simply failing, but we aren't propagating the errors from XCBuild correctly.

@neonichu
Copy link
Contributor

The underlying error is: Found multiple targets named 'FooLib' which is true, there a package product target and a standard target with that name, but this doesn't seem like something we recently changed? Possibly Xcode on CI was an older version and this error exists for a while?

@neonichu
Copy link
Contributor

Seems like this indeed works when using 12.5 as the installed Xcode, so this isn't due to any changes to SwiftPM.

@neonichu
Copy link
Contributor

I think the most reasonable thing for now is to change the test so that it doesn't hit this and then figure out whether SwiftPM and/or XCBuild should change separately. We should also fix SwiftPM's parsing of XCBuild's output so that we don't drop the error on the floor.

@abertelrud
Copy link
Contributor

@abertelrud this is something we should refactor out a plugin when the framework is ready. could you please review in that light.

Absolutely — I didn't actually realize there was a command for this already; the mentioning of swift-format as an example subcommand plugin was based on use cases, not an awareness of this code. This diff seems totally finally in relation to the existing code; when implemented as a plugin, it should have more robust emitting of output, and I'll also want to look closer at what it's using the PackageBuilder output for, since that isn't something plugins have access to now.

@abertelrud
Copy link
Contributor

@abertelrud this is something we should refactor out a plugin when the framework is ready. could you please review in that light.

Absolutely — I didn't actually realize there was a command for this already; the mentioning of swift-format as an example subcommand plugin was based on use cases, not an awareness of this code. This diff seems totally finally in relation to the existing code; when implemented as a plugin, it should have more robust emitting of output, and I'll also want to look closer at what it's using the PackageBuilder output for, since that isn't something plugins have access to now.

Oh wait, PackageBuilder just construct the memory model of a package, it doesn't actually create a build system for building the package — name is confusing.

@neonichu
Copy link
Contributor

@swift-ci please smoke test

@neonichu neonichu merged commit 0b0b22b into swiftlang:main Aug 24, 2021
@keith keith deleted the ks/improve-_format-command branch August 24, 2021 16:41
@keith
Copy link
Member Author

keith commented Aug 24, 2021

Thanks!

@tomerd
Copy link
Contributor

tomerd commented Aug 24, 2021

thank you @keith

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants