Skip to content

Fixup several warnings #9009

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 3 commits into from
Aug 20, 2025
Merged

Conversation

plemarquand
Copy link
Contributor

  • Remove unnecessary try statements for function calls that do not throw
  • Remove unnecessary #expect checks for values that cannot be nil

@plemarquand
Copy link
Contributor Author

@swift-ci test

@plemarquand
Copy link
Contributor Author

@swift-ci test

1 similar comment
@plemarquand
Copy link
Contributor Author

@swift-ci test

@dschaefer2
Copy link
Member

@swift-ci please test windows

Copy link
Contributor

@bkhouri bkhouri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the cleanup. I have some comments, which some possibly being blocking.

@@ -721,7 +721,7 @@ final class MiscellaneousTestCase: XCTestCase {
guard case SwiftPMError.executionFailure(_, _, let stderr) = error else {
return XCTFail("invalid error \(error)")
}
XCTAssert(stderr.contains("error: You don’t have permission"), "expected permissions error. stderr: '\(stderr)'")
XCTAssert(stderr.contains("error: You don’t have permission") || stderr.contains("invalid access"), "expected permissions error. stderr: '\(stderr)'")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (possibly-blocking): I this is also update a test case. do we know if this new expectation is expected, or whether it's a regression?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is unrelated to my patch, but its because this test is failing on main. I had to fix it to get CI to pass. To verify, make sure you do a swift package update first.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand it's failing on main, but could this mean a regression was introduced somewhere? That is, test is there for a reason and may have actually served its purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to track down what specifically caused this to change, but this failure stems from the underlying API moving from the Foundation based file system APIs to the tools-support-core FileSystem.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be ideal to understand the root cause and determine whether the is the expected behaviour or a regression, instead of simply updating the test to reflect the current behaviour - which may be a regression.

Copy link
Contributor Author

@plemarquand plemarquand Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its likely this change: https://github.com/swiftlang/swift-tools-support-core/pull/521/files#diff-4a8cbeddae09f50e3bf71a7b4f098244ee50dad510e6359a24f2678a5bca10d5R506, converting the NSError's produced inside various FileSystem functions into FileSystemErrors.

@bkhouri
Copy link
Contributor

bkhouri commented Aug 13, 2025

@swift-ci test self hosted

@bkhouri
Copy link
Contributor

bkhouri commented Aug 14, 2025

The previous self hosted windows has the following set failures, which appear unrelated to this change

20:21:10  Test Suite 'AsyncProcessTests' started at 2025-08-13 22:52:42.545
20:21:10  Test Case 'AsyncProcessTests.testPopenWithBufferLargerThanAllocated' started at 2025-08-13 22:52:42.546
20:21:10  <EXPR>:0: error: AsyncProcessTests.testPopenWithBufferLargerThanAllocated : threw error "invalid access to C:\Users\ContainerAdministrator\AppData\Local\Temp\TemporaryFile.BADQz2"
20:21:10  Test Case 'AsyncProcessTests.testPopenWithBufferLargerThanAllocated' failed (0.014 seconds)
20:21:10  Test Suite 'AsyncProcessTests' failed at 2025-08-13 22:52:42.560
20:21:10  	 Executed 1 test, with 1 failure (1 unexpected) in 0.014 (0.014) seconds
20:21:10  Test Suite 'Selected tests' failed at 2025-08-13 22:52:42.560
20:21:10  	 Executed 1 test, with 1 failure (1 unexpected) in 0.014 (0.014) seconds
20:21:10  
20:21:10  Test Suite 'Selected tests' started at 2025-08-13 22:54:31.661
20:21:10  Test Suite 'SwiftSDKCommandTests' started at 2025-08-13 22:54:31.664
20:21:10  Test Case 'SwiftSDKCommandTests.testConfigureSubcommand' started at 2025-08-13 22:54:31.664
20:21:10  C:\source\swiftpm\Tests\CommandsTests\SwiftSDKCommandTests.swift:151: error: SwiftSDKCommandTests.testConfigureSubcommand : XCTAssertTrue failed - unexpected failure matching '' against pattern contains("test-sdk.artifactbundle.zip` successfully installed as test-sdk.artifactbundle.")
20:21:10  Test Case 'SwiftSDKCommandTests.testConfigureSubcommand' failed (33.06 seconds)
20:21:10  Test Suite 'SwiftSDKCommandTests' failed at 2025-08-13 22:55:04.724
20:21:10  	 Executed 1 test, with 1 failure (0 unexpected) in 33.06 (33.06) seconds
20:21:10  Test Suite 'Selected tests' failed at 2025-08-13 22:55:04.724
20:21:10  	 Executed 1 test, with 1 failure (0 unexpected) in 33.06 (33.06) seconds

I'm re-triggering build.

@swift-ci test self hosted windows

@plemarquand
Copy link
Contributor Author

@swift-ci test

@bkhouri
Copy link
Contributor

bkhouri commented Aug 14, 2025

@swift-ci test windows

- Remove unnecessary `try` statements for function calls that do not
  throw
- Remove unnecessary `#expect` checks for values that cannot be `nil`
@plemarquand
Copy link
Contributor Author

@swift-ci test

@plemarquand
Copy link
Contributor Author

@swift-ci please test macOS

@plemarquand
Copy link
Contributor Author

@swift-ci please test windows

@plemarquand
Copy link
Contributor Author

@swift-ci please test macOS

@plemarquand plemarquand requested a review from bkhouri August 20, 2025 02:23
@@ -2283,7 +2283,7 @@ struct ModulesGraphTests {
let observability = try loadUnsafeModulesGraph(toolsVersion: .v6_1)

#expect(observability.diagnostics.count == 3)
try testDiagnostics(observability.diagnostics) { result in
testDiagnostics(observability.diagnostics) { result in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Since this suite is SwiftTesting, we should be using expectDiagnostics instead of testDiagnostics

This should probably be handled in a subsequent change

@plemarquand plemarquand merged commit 9e6c764 into swiftlang:main Aug 20, 2025
6 checks passed
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