Skip to content

Update --suite-name-format default value to preserve#2441

Merged
calda merged 4 commits intodevelopfrom
copilot/add-disable-option-for-swift-testing-rule
Mar 12, 2026
Merged

Update --suite-name-format default value to preserve#2441
calda merged 4 commits intodevelopfrom
copilot/add-disable-option-for-swift-testing-rule

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 11, 2026

swiftTestingTestCaseNames supports suiteNameFormat: .preserve to prevent stripping display name strings from @Suite. This PR makes preserve the default for suiteNameFormat, and adds tests to document the interaction between the two rules—specifically that redundantSwiftTestingSuite only removes @Suite("Name") after swiftTestingTestCaseNames strips the string argument, not independently.

Changes

  • Options.swift: Changed the default value of suiteNameFormat from .standardIdentifiers to .preserve. This means @Suite("Name") is preserved by default; users must opt into --suite-name-format standard-identifiers or raw-identifiers to have the display name stripped.

  • Rules.md: Regenerated to reflect the updated default, now showing "preserve" (default) for --suite-name-format.

  • RedundantSwiftTestingSuiteTests: Added testKeepSuiteWithDisplayNameWhenSuiteNameFormatIsPreserve — runs both rules together with suiteNameFormat: .preserve and verifies @Suite("Display Name") is left untouched (the string stays, so the attribute isn't redundant).

  • SwiftTestingTestCaseNamesTests: Added testSuitePreserveKeepsDisplayNameWithBothRules — same scenario from the other rule's perspective; both rules active with suiteNameFormat: .preserve leave @Suite("My Feature Tests") unchanged.

  • Test updates: Updated tests that previously relied on the .standardIdentifiers default to explicitly pass suiteNameFormat: .standardIdentifiers.

The existing testRemovesTestSuiteWithOnlyStringArgument (both rules, with explicit suiteNameFormat: .standardIdentifiers) covers the opt-in case: swiftTestingTestCaseNames strips the string → redundantSwiftTestingSuite removes the now-empty @Suite.

Original prompt

Ensure the swiftTestingTestCaseNames rule has a way to disable the behavior where a suite's string name is removed. Does the preserve option already work that way? Also include tests that redundantSwiftTestingSuite doesn't remove a suite like @Suite("Name") unless the other rule removes the string argument first.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Add testKeepSuiteWithDisplayNameWhenSuiteNameFormatIsPreserve in
  RedundantSwiftTestingSuiteTests: verifies both rules together with
  suiteNameFormat: .preserve keep @suite("Name") intact
- Add testSuitePreserveKeepsDisplayNameWithBothRules in
  SwiftTestingTestCaseNamesTests: verifies both rules with preserve
  leave the display name unchanged

Co-authored-by: calda <1811727+calda@users.noreply.github.com>
Copilot AI changed the title [WIP] Add option to disable name removal in swiftTestingTestCaseNames Add tests verifying suiteNameFormat: .preserve prevents @Suite("Name") removal Mar 11, 2026
@calda
Copy link
Copy Markdown
Collaborator

calda commented Mar 11, 2026

@copilot, let's also make preserve the default for this option please

@calda
Copy link
Copy Markdown
Collaborator

calda commented Mar 11, 2026

Fixes #2439

- Update default value in Options.swift
- Update tests that relied on standardIdentifiers default to
  explicitly pass suiteNameFormat: .standardIdentifiers

Co-authored-by: calda <1811727+calda@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 11, 2026

@copilot, let's also make preserve the default for this option please

Done in dedb229. Changed suiteNameFormat default from .standardIdentifiers to .preserve in Options.swift, and updated all tests that relied on the old default to explicitly pass suiteNameFormat: .standardIdentifiers.

Copilot AI changed the title Add tests verifying suiteNameFormat: .preserve prevents @Suite("Name") removal Make suiteNameFormat default to preserve and add tests for @Suite("Name") interaction Mar 11, 2026
@calda calda marked this pull request as ready for review March 11, 2026 17:09
@calda calda changed the title Make suiteNameFormat default to preserve and add tests for @Suite("Name") interaction Update --suite-name-format default value to preserve Mar 11, 2026
@calda
Copy link
Copy Markdown
Collaborator

calda commented Mar 11, 2026

@copilot please fix test failures

Rules.md is auto-generated; running MetadataTests.testGenerateRulesDocumentation
regenerated it to show "preserve (default)" instead of "standard-identifiers (default)".

Co-authored-by: calda <1811727+calda@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 11, 2026

@copilot please fix test failures

Fixed in e8dbbba. The MetadataTests.testGenerateRulesDocumentation() failure was because Rules.md (auto-generated) still showed standard-identifiers (default) for --suite-name-format. Running the test regenerated it to show preserve (default).

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.29%. Comparing base (f771e19) to head (e8dbbba).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #2441   +/-   ##
========================================
  Coverage    95.28%   95.29%           
========================================
  Files          165      165           
  Lines        25147    25147           
========================================
+ Hits         23962    23964    +2     
+ Misses        1185     1183    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@calda calda merged commit 4cf685f into develop Mar 12, 2026
18 checks passed
@calda calda deleted the copilot/add-disable-option-for-swift-testing-rule branch March 12, 2026 00:08
calda added a commit that referenced this pull request Apr 11, 2026
Co-authored-by: calda <1811727+calda@users.noreply.github.com>
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.

2 participants