Commit 7dd3d27
authored
Simplify the thunk names we generate for test functions. (#750)
Parameterized test functions with the same name but different argument
types currently get the same generated names from swift-syntax, so we do
some additional decorating to ensure uniqueness. This results in very
long symbol names that `swift-demangle` has trouble with.
This PR changes the decorating formula. Previously, we would include a
copy of the test function's signature (stripped of whitespace, Unicode,
and non-identifier-friendly ASCII) and, if the identifier contained
non-ASCII characters, the CRC32 of the identifier for further
uniqueness. This change drops the copy of the identifier name and always
includes the CRC32. Collisions are only possible for fully-qualified
test function names that are _identical_, and I naïvely judge the risk
of those collisions to be sufficiently low that we can make this change.
For `ZipTests.allElementsEqual😀(i:j:)` we currently generate a thunk
named:
```
$s12TestingTests03ZipB0V0022allElementsEqual_oxFJo4TestfMp_43funcallElementsEqual__i_Int_j_Int__5bcb7b35fMu_
```
This change would change it to:
```
$s12TestingTests03ZipB0V0022allElementsEqual_oxFJo4TestfMp_9Z5bcb7b35fMu_
```
Which demangles to:
```
$s12TestingTests03ZipB0V0022allElementsEqual_oxFJo4TestfMp_9Z5bcb7b35fMu_ ---> unique name #1 of Z5bcb7b35 in peer macro @test expansion #1 of allElementsEqual😀 in TestingTests.ZipTests
```
The benefit of the change is that the generated names are shorter and
easier to read when expanding a macro, and play better with the
demangler. There may also be some benefit on Windows where the linker
has a 65KB symbol name cap, although we're not exporting these symbols
so probably not.
### Checklist:
- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.1 parent 987fed7 commit 7dd3d27
File tree
2 files changed
+16
-50
lines changed- Sources/TestingMacros/Support/Additions
- Tests/TestingMacrosTests
2 files changed
+16
-50
lines changedLines changed: 9 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
65 | 67 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
100 | 74 | | |
101 | 75 | | |
102 | | - | |
| 76 | + | |
103 | 77 | | |
104 | 78 | | |
105 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | 30 | | |
37 | 31 | | |
38 | 32 | | |
39 | | - | |
40 | 33 | | |
41 | 34 | | |
42 | 35 | | |
43 | 36 | | |
44 | 37 | | |
45 | 38 | | |
46 | 39 | | |
47 | | - | |
48 | 40 | | |
49 | 41 | | |
50 | 42 | | |
51 | | - | |
52 | 43 | | |
53 | 44 | | |
54 | 45 | | |
55 | 46 | | |
56 | 47 | | |
57 | | - | |
58 | 48 | | |
59 | | - | |
60 | 49 | | |
61 | 50 | | |
62 | 51 | | |
63 | 52 | | |
64 | 53 | | |
65 | 54 | | |
66 | 55 | | |
67 | | - | |
68 | 56 | | |
69 | | - | |
70 | 57 | | |
71 | | - | |
72 | 58 | | |
73 | | - | |
74 | 59 | | |
75 | 60 | | |
76 | 61 | | |
| |||
89 | 74 | | |
90 | 75 | | |
91 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
92 | 84 | | |
0 commit comments