Skip to content

Commit

Permalink
Combine NonComponentReferenceForTests, and ComponentReferenceForTests…
Browse files Browse the repository at this point in the history
… into AspireProjectOrPackageReference
  • Loading branch information
radical committed Jul 17, 2024
1 parent d805dc9 commit d5231fd
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 45 deletions.
13 changes: 6 additions & 7 deletions tests/Shared/RepoTesting/Aspire.RepoTesting.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This provides support for running tests outside of the repo, for example on a helix agent.
- For this you need the source of the tests, and any dependencies.
- Instead of direct `ProjectReferences` to the various Aspire hosting, and component projects use
`@(ComponentReferenceForTests)`, and @(NonComponentReferenceForTests)`.
`@(AspireProjectOrPackageReference)`, and @(AspireProjectOrPackageReference)`.
- These are converted to `ProjectReference` when `$(TestsRunningOutsideOfRepo) != true`.
- But converted to `PackageReference` when `$(TestsRunningOutsideOfRepo) == true`.
Expand All @@ -30,8 +30,7 @@
`GeneratedPackagesVersionsPropsPath` - path for the generated `Directory.Packages.Versions.props`
Public Items:
`ComponentReferenceForTests` - maps to projects in `src/Components/
`NonComponentReferenceForTests` - maps to projects in `src/`
`AspireProjectOrPackageReference` - maps to projects in `src/` or `src/Components/`
-->

<PropertyGroup>
Expand All @@ -43,13 +42,13 @@
</PropertyGroup>

<ItemGroup Condition="'$(TestsRunningOutsideOfRepo)' != 'true'">
<ProjectReference Include="@(ComponentReferenceForTests -> '$(RepoRoot)src\Components\%(Identity)\%(Identity).csproj')" />
<ProjectReference Include="@(NonComponentReferenceForTests -> '$(RepoRoot)src\%(Identity)\%(Identity).csproj')" />
<_CandidateProjectReference Include="@(AspireProjectOrPackageReference -> '$(RepoRoot)src\Components\%(Identity)\%(Identity).csproj')" />
<_CandidateProjectReference Include="@(AspireProjectOrPackageReference -> '$(RepoRoot)src\%(Identity)\%(Identity).csproj')" />
<ProjectReference Include="@(_CandidateProjectReference->Exists())" />
</ItemGroup>

<ItemGroup Condition="'$(TestsRunningOutsideOfRepo)' == 'true'">
<PackageReference Include="@(ComponentReferenceForTests)" />
<PackageReference Include="@(NonComponentReferenceForTests)" />
<PackageReference Include="@(AspireProjectOrPackageReference)" />
</ItemGroup>

<ItemGroup Condition="'$(TestsRunningOutsideOfRepo)' == 'true' and '$(RepoRoot)' == '' and '$(IncludeTestPackages)' == 'true'" Label="Test packages">
Expand Down
20 changes: 10 additions & 10 deletions tests/Shared/RepoTesting/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Running tests outside-of-repo

This provides support for running tests outside of the repo, for example on a helix agent.
- For this you need the source of the tests, and any dependencies.
- Instead of direct `ProjectReferences` to the various Aspire hosting, and component projects use
`@(ComponentReferenceForTests)`, and @(NonComponentReferenceForTests)`.
- These are converted to `ProjectReference` when `$(TestsRunningOutsideOfRepo) != true`.
- But converted to `PackageReference` when `$(TestsRunningOutsideOfRepo) == true`.
- For this you need the source of the tests, and any dependencies.
- Instead of direct `ProjectReferences` to the various Aspire hosting, and component projects use
`@(AspireProjectOrPackageReference)`.
- These are converted to `ProjectReference` when `$(TestsRunningOutsideOfRepo) != true`.
- But converted to `PackageReference` when `$(TestsRunningOutsideOfRepo) == true`.

- To allow building such test projects, the build is isolated and patched to build outside the
repo by adding appropriate `Directory.Build.{props,targets}`, and `Directory.Packages.props`
- and using a custom `nuget.config` which resolves the Aspire packages from the locally built packages
- and a `Directory.Packages.Versions.props` is generated with PackageVersions taken from the repo
- This also adds properties named in `@(PropertyForHelixRun)` from the repo, like `$(NetCurrent)`.
- To allow building such test projects, the build is isolated and patched to build outside the
repo by adding appropriate `Directory.Build.{props,targets}`, and `Directory.Packages.props`
- and using a custom `nuget.config` which resolves the Aspire packages from the locally built packages
- and a `Directory.Packages.Versions.props` is generated with PackageVersions taken from the repo
- This also adds properties named in `@(PropertyForHelixRun)` from the repo, like `$(NetCurrent)`.

## Adding new package versions

Expand Down
28 changes: 14 additions & 14 deletions tests/testproject/TestProject.AppHost/TestProject.AppHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
</PropertyGroup>

<ItemGroup>
<NonComponentReferenceForTests Include="Aspire.Hosting.Azure" IsAspireProjectResource="false" />
<NonComponentReferenceForTests Include="Aspire.Hosting.Azure.CosmosDB" IsAspireProjectResource="false" />
<NonComponentReferenceForTests Include="Aspire.Hosting.Azure.EventHubs" IsAspireProjectResource="false" />
<NonComponentReferenceForTests Include="Aspire.Hosting.AppHost" IsAspireProjectResource="false" />
<NonComponentReferenceForTests Include="Aspire.Hosting.Garnet" IsAspireProjectResource="false" />
<NonComponentReferenceForTests Include="Aspire.Hosting.Milvus" IsAspireProjectResource="false" />
<NonComponentReferenceForTests Include="Aspire.Hosting.MongoDB" IsAspireProjectResource="false" />
<NonComponentReferenceForTests Include="Aspire.Hosting.MySql" IsAspireProjectResource="false" />
<NonComponentReferenceForTests Include="Aspire.Hosting.NodeJs" IsAspireProjectResource="false" />
<NonComponentReferenceForTests Include="Aspire.Hosting.Oracle" IsAspireProjectResource="false" />
<NonComponentReferenceForTests Include="Aspire.Hosting.PostgreSQL" IsAspireProjectResource="false" />
<NonComponentReferenceForTests Include="Aspire.Hosting.RabbitMQ" IsAspireProjectResource="false" />
<NonComponentReferenceForTests Include="Aspire.Hosting.Redis" IsAspireProjectResource="false" />
<NonComponentReferenceForTests Include="Aspire.Hosting.SqlServer" IsAspireProjectResource="false" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.Azure" IsAspireProjectResource="false" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.Azure.CosmosDB" IsAspireProjectResource="false" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.Azure.EventHubs" IsAspireProjectResource="false" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.AppHost" IsAspireProjectResource="false" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.Garnet" IsAspireProjectResource="false" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.Milvus" IsAspireProjectResource="false" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.MongoDB" IsAspireProjectResource="false" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.MySql" IsAspireProjectResource="false" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.NodeJs" IsAspireProjectResource="false" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.Oracle" IsAspireProjectResource="false" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.PostgreSQL" IsAspireProjectResource="false" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.RabbitMQ" IsAspireProjectResource="false" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.Redis" IsAspireProjectResource="false" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.SqlServer" IsAspireProjectResource="false" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
</ItemGroup>

<ItemGroup>
<ComponentReferenceForTests Include="Aspire.Microsoft.Azure.Cosmos" />
<ComponentReferenceForTests Include="Aspire.Microsoft.Data.SqlClient" />
<ComponentReferenceForTests Include="Aspire.Milvus.Client" />
<ComponentReferenceForTests Include="Aspire.MongoDB.Driver" />
<ComponentReferenceForTests Include="Aspire.MySqlConnector" />
<ComponentReferenceForTests Include="Aspire.Npgsql" />
<ComponentReferenceForTests Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" />
<ComponentReferenceForTests Include="Aspire.Oracle.EntityFrameworkCore" />
<ComponentReferenceForTests Include="Aspire.Pomelo.EntityFrameworkCore.MySql" />
<ComponentReferenceForTests Include="Aspire.Microsoft.EntityFrameworkCore.SqlServer" />
<ComponentReferenceForTests Include="Aspire.RabbitMQ.Client" />
<ComponentReferenceForTests Include="Aspire.StackExchange.Redis" />
<ComponentReferenceForTests Include="Aspire.Azure.Messaging.EventHubs" />
<ComponentReferenceForTests Include="Aspire.Microsoft.EntityFrameworkCore.Cosmos" />
<AspireProjectOrPackageReference Include="Aspire.Microsoft.Azure.Cosmos" />
<AspireProjectOrPackageReference Include="Aspire.Microsoft.Data.SqlClient" />
<AspireProjectOrPackageReference Include="Aspire.Milvus.Client" />
<AspireProjectOrPackageReference Include="Aspire.MongoDB.Driver" />
<AspireProjectOrPackageReference Include="Aspire.MySqlConnector" />
<AspireProjectOrPackageReference Include="Aspire.Npgsql" />
<AspireProjectOrPackageReference Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" />
<AspireProjectOrPackageReference Include="Aspire.Oracle.EntityFrameworkCore" />
<AspireProjectOrPackageReference Include="Aspire.Pomelo.EntityFrameworkCore.MySql" />
<AspireProjectOrPackageReference Include="Aspire.Microsoft.EntityFrameworkCore.SqlServer" />
<AspireProjectOrPackageReference Include="Aspire.RabbitMQ.Client" />
<AspireProjectOrPackageReference Include="Aspire.StackExchange.Redis" />
<AspireProjectOrPackageReference Include="Aspire.Azure.Messaging.EventHubs" />
<AspireProjectOrPackageReference Include="Aspire.Microsoft.EntityFrameworkCore.Cosmos" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit d5231fd

Please sign in to comment.