Skip to content

Commit

Permalink
feature-intern-ResolveDependencyConflictsNew to main (#10343)
Browse files Browse the repository at this point in the history
* Adding NugetDependencySolver Experiment

* TEMP redirecting smoke tests branch

* Fixed formatting

---------

Co-authored-by: Nadia Bugarin <[email protected]>
  • Loading branch information
NadiamB and Nadia Bugarin authored Aug 13, 2024
1 parent ac0185e commit d09bc1e
Show file tree
Hide file tree
Showing 12 changed files with 1,772 additions and 37 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ git.store
Dockerfile*
*.md
CODEOWNERS
**/.vs
**/NuGetUpdater/artifacts
2 changes: 1 addition & 1 deletion .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:

env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SMOKE_TEST_BRANCH: main
SMOKE_TEST_BRANCH: feature-DependencySolver
jobs:
discover:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ coverage/
# Ignore spoom coverage report
spoom_data/
spoom_report.html
.vs/
2 changes: 2 additions & 0 deletions nuget/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/.vs
**/NuGetUpdater/artifacts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ private static async Task Run(Func<string, string[]> getArgs, (string Path, stri
try
{
await MockNuGetPackagesInDirectory(packages, path);

var args = getArgs(path);
var result = await Program.Main(args);
if (result != 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
);
}

[Fact]
public async Task UpdateVersionChildElement_InProjectFile_ForPackageReferenceInclude()
[Theory]
[InlineData("true")]
[InlineData(null)]
public async Task UpdateVersionChildElement_InProjectFile_ForPackageReferenceIncludeTheory(string variableValue)
{
// update Some.Package from 9.0.1 to 13.0.1
using var env = new TemporaryEnvironment([("UseNewNugetPackageResolver", variableValue)]);
await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
packages:
[
Expand Down Expand Up @@ -91,6 +94,43 @@ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
);
}

[Fact]
public async Task CallingResolveDependencyConflictsNew()
{
// update Microsoft.CodeAnalysis.Common from 4.9.2 to 4.10.0
using var env = new TemporaryEnvironment([("UseNewNugetPackageResolver", "true")]);
await TestUpdateForProject("Microsoft.CodeAnalysis.Common", "4.9.2", "4.10.0",
// initial
projectContents: $"""
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Compilers" Version="4.9.2" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.9.2" />
</ItemGroup>
</Project>
""",
// expected
expectedProjectContents: $"""
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Compilers" Version="4.10.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.10.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.10.0" />
</ItemGroup>
</Project>
"""
);
}

[Fact]
public async Task UpdateVersions_InProjectFile_ForDuplicatePackageReferenceInclude()
{
Expand Down Expand Up @@ -489,9 +529,12 @@ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
);
}

[Fact]
public async Task AddPackageReference_InProjectFile_ForTransientDependency()
[Theory]
[InlineData(null)]
[InlineData("true")]
public async Task AddPackageReference_InProjectFile_ForTransientDependency(string variableValue)
{
using var env = new TemporaryEnvironment([("UseNewNugetPackageResolver", variableValue)]);
// add transient package Some.Transient.Dependency from 5.0.1 to 5.0.2
await TestUpdateForProject("Some.Transient.Dependency", "5.0.1", "5.0.2", isTransitive: true,
packages:
Expand Down Expand Up @@ -2862,9 +2905,13 @@ await TestUpdateForProject("Some.Package", "12.0.1", "13.0.1",
);
}

[Fact]
public async Task NoChange_IfThereAreIncoherentVersions()
[Theory]
[InlineData("true")]
[InlineData(null)]
public async Task NoChange_IfThereAreIncoherentVersions(string variableValue)
{
using var env = new TemporaryEnvironment([("UseNewNugetPackageResolver", variableValue)]);

// trying to update `Transitive.Dependency` to 1.1.0 would normally pull `Some.Package` from 1.0.0 to 1.1.0,
// but the TFM doesn't allow it
await TestNoChangeforProject("Transitive.Dependency", "1.0.0", "1.1.0",
Expand Down Expand Up @@ -2948,9 +2995,13 @@ await TestUpdateForProject("Some.Package", "7.0.1", "13.0.1",
);
}

[Fact]
public async Task UnresolvablePropertyDoesNotStopOtherUpdates()
[Theory]
[InlineData("true")]
[InlineData(null)]
public async Task UnresolvablePropertyDoesNotStopOtherUpdates(string variableValue)
{
using var env = new TemporaryEnvironment([("UseNewNugetPackageResolver", variableValue)]);

// the property `$(SomeUnresolvableProperty)` cannot be resolved
await TestUpdateForProject("Some.Package", "7.0.1", "13.0.1",
packages:
Expand Down Expand Up @@ -2984,9 +3035,13 @@ await TestUpdateForProject("Some.Package", "7.0.1", "13.0.1",
);
}

[Fact]
public async Task UpdatingPackageAlsoUpdatesAnythingWithADependencyOnTheUpdatedPackage()
[Theory]
[InlineData("true")]
[InlineData(null)]
public async Task UpdatingPackageAlsoUpdatesAnythingWithADependencyOnTheUpdatedPackage(string variableValue)
{
using var env = new TemporaryEnvironment([("UseNewNugetPackageResolver", variableValue)]);

// updating Some.Package from 3.3.30 requires that Some.Package.Extensions also be updated
await TestUpdateForProject("Some.Package", "3.3.30", "3.4.3",
packages:
Expand Down
Loading

0 comments on commit d09bc1e

Please sign in to comment.