Skip to content

Synthesize display names for de facto suites with raw identifiers. #1105

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented May 4, 2025

This PR ensures that suite types that don't have the @Suite attribute but which do have raw identifiers for names are correctly given display names the same way those with @Suite would be. This PR also ensures that we transform spaces in raw identifiers after they are demangled by the runtime--namely, the runtime replaces ASCII spaces (as typed by the user) with Unicode non-breaking spaces (which aren't otherwise valid in raw identifers) in order to avoid issues with existing uses of spaces in demangled names. We want to make sure that identifiers as presented to the user match what the user has typed, so we need to transform these spaces back. No changes in this area are needed for display names derived during macro expansion because we do the relevant work based on the source text which still has the original ASCII spaces.

This PR also deletes the "raw$" hack that I put in place when originally implementing raw identifier support as the entire toolchain supports them now.

Resolves #1104.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

This PR ensures that suite types that don't have the `@Suite` attribute but which _do_ have raw identifiers for names are correctly given display names the same way those with `@Suite` would be. This PR also ensures that we transform spaces in raw identifiers after they are demangled by the runtime--namely, the runtime replaces ASCII spaces (as typed by the user) with Unicode non-breaking spaces (which aren't otherwise valid in raw identifers) in order to avoid issues with existing uses of spaces in demangled names. We want to make sure that identifiers as presented to the user match what the user has typed, so we need to transform these spaces back. No changes in this area are needed for display names derived during macro expansion because we do the relevant work based on the source text which still has the original ASCII spaces.

This PR also deletes the "raw$" hack that I put in place when originally implementing raw identifier support as the entire toolchain supports them now.

Resolves #1104.
@grynspan grynspan added bug 🪲 Something isn't working macros 🔭 Related to Swift macros such as @Test or #expect discovery 🔎 test content discovery labels May 4, 2025
@grynspan grynspan added this to the Swift 6.x milestone May 4, 2025
@grynspan grynspan self-assigned this May 4, 2025
@grynspan
Copy link
Contributor Author

grynspan commented May 4, 2025

@swift-ci test

@grynspan grynspan closed this May 4, 2025
@grynspan grynspan reopened this May 4, 2025
@grynspan
Copy link
Contributor Author

grynspan commented May 4, 2025

@swift-ci test

@grynspan
Copy link
Contributor Author

grynspan commented May 4, 2025

9sswjj

@grynspan grynspan requested a review from allevato May 4, 2025 03:11
@grynspan
Copy link
Contributor Author

grynspan commented May 5, 2025

https://ci-external.swift.org/job/swift-testing-pull-request-windows/1474/consoleText

Looks like the Windows toolchain doesn't support these identifiers yet @allevato @compnerd.

@grynspan
Copy link
Contributor Author

grynspan commented May 5, 2025

@swift-ci test

@grynspan
Copy link
Contributor Author

grynspan commented May 5, 2025

@swift-ci test

@grynspan
Copy link
Contributor Author

grynspan commented May 5, 2025

@swift-ci test

@allevato
Copy link
Member

allevato commented May 5, 2025

https://ci-external.swift.org/job/swift-testing-pull-request-windows/1474/consoleText

Looks like the Windows toolchain doesn't support these identifiers yet @allevato @compnerd.

I'm not sure what's going on there; I wouldn't have been able to merge the original support if it didn't work on Windows. Both the old C++ parser and the Swift parser handle them. Any ideas @compnerd ?

return nil
}

let result = rawIdentifier.lazy.map { c in
Copy link
Member

Choose a reason for hiding this comment

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

Not important: My experience has led me to operate on Unicode scalar views in situations like this where I don't need grapheme clustering so I don't pay the extra cost of it. It's probably not going to be a big bottleneck here, but that's just my habit 🤷🏻‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working discovery 🔎 test content discovery macros 🔭 Related to Swift macros such as @Test or #expect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Raw identifiers for suite types aren't treated as display names
2 participants