Skip to content

Synthesize Test instances for all suite types. #311

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
Mar 25, 2024

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Mar 22, 2024

This PR extends test discovery to synthesize Test instances for all suite types (that is, types containing other suites or test functions but which do not have the @Suite attribute explicitly applied to them.)

This ensures that deep type hierarchies like the following are fully represented in test plans:

struct AllTests {
  struct FoodTruckTests {
    @Suite struct MechanicalTests {
      struct BatteryTests {
      	@Test func isCharged() { ... }
      }
    }
  }
}

Resolves rdar://125241067.

Checklist:

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

@grynspan grynspan added bug 🪲 Something isn't working tools integration 🛠️ Integration of swift-testing into tools/IDEs labels Mar 22, 2024
@grynspan grynspan self-assigned this Mar 22, 2024
@grynspan
Copy link
Contributor Author

I've XFAILed a test for now as we're not 100% sure what to do with it. We'll take a look after the weekend.

@grynspan
Copy link
Contributor Author

@swift-ci please test

// If the real test is hidden, so shall the synthesized test be hidden.
// Copy the exact traits from the real test in case they someday carry
// any interesting metadata.
let traits = test.traits.compactMap { $0 as? HiddenTrait }
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this no longer needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's redundant as we already recursively apply traits like this one during planning.

This PR extends test discovery to synthesize `Test` instances for all suite
types (that is, types containing other suites or test functions but which do not
have the `@Suite` attribute explicitly applied to them.)

This ensures that deep type hierarchies like the following are fully represented
in test plans:

```swift
struct AllTests {
  struct FoodTruckTests {
    @suite struct MechanicalTests {
      struct BatteryTests {
      	@test func isCharged() { ... }
      }
    }
  }
}
```

Resolves rdar://125241067.
@grynspan grynspan force-pushed the jgrynspan/125241067-synthesize-more-suites branch from f784cd5 to fbe535d Compare March 23, 2024 03:14
@grynspan
Copy link
Contributor Author

@swift-ci please test

@grynspan
Copy link
Contributor Author

@swift-ci please test

@grynspan grynspan merged commit 0112a46 into main Mar 25, 2024
@grynspan grynspan deleted the jgrynspan/125241067-synthesize-more-suites branch March 25, 2024 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working tools integration 🛠️ Integration of swift-testing into tools/IDEs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants