fix the race condition when generating deps.json, and add some coverage of this scenario
update reporter to verbose fix fix usings for test update the test
This commit is contained in:
parent
803fef6a8b
commit
d3d64a4033
2 changed files with 84 additions and 18 deletions
|
@ -18,6 +18,11 @@ using FluentAssertions;
|
|||
using NuGet.Frameworks;
|
||||
using NuGet.Versioning;
|
||||
using NuGet.ProjectModel;
|
||||
using Microsoft.DotNet.ProjectModel.Graph;
|
||||
using Microsoft.DotNet.ProjectModel.Compilation;
|
||||
using NuGet.ProjectModel;
|
||||
|
||||
using LockFile = Microsoft.DotNet.ProjectModel.Graph.LockFile;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||
{
|
||||
|
@ -184,6 +189,37 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
|||
depsJsonFile.Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Generate_deps_json_method_doesnt_overwrite_when_deps_file_already_exists()
|
||||
{
|
||||
var context = ProjectContext.Create(Path.Combine(s_liveProjectDirectory, "project.json"), s_toolPackageFramework);
|
||||
|
||||
var nugetPackagesRoot = context.PackagesDirectory;
|
||||
var toolPathCalculator = new ToolPathCalculator(nugetPackagesRoot);
|
||||
|
||||
var lockFilePath = toolPathCalculator.GetLockFilePath(
|
||||
"dotnet-portable",
|
||||
new NuGetVersion("1.0.0"),
|
||||
s_toolPackageFramework);
|
||||
|
||||
var lockFile = LockFileReader.Read(lockFilePath, designTime: false);
|
||||
|
||||
var depsJsonFile = Path.Combine(
|
||||
Path.GetDirectoryName(lockFilePath),
|
||||
"dotnet-portable.deps.json");
|
||||
|
||||
if (File.Exists(depsJsonFile))
|
||||
{
|
||||
File.Delete(depsJsonFile);
|
||||
}
|
||||
File.WriteAllText(depsJsonFile, "temp");
|
||||
|
||||
var projectToolsCommandResolver = SetupProjectToolsCommandResolver();
|
||||
projectToolsCommandResolver.GenerateDepsJsonFile(lockFile, depsJsonFile);
|
||||
|
||||
File.ReadAllText(depsJsonFile).Should().Be("temp");
|
||||
}
|
||||
|
||||
private ProjectToolsCommandResolver SetupProjectToolsCommandResolver(
|
||||
IPackagedCommandSpecFactory packagedCommandSpecFactory = null)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue