tests for cache taking multiple input files
This commit is contained in:
parent
ed1ca04f51
commit
e40435920d
7 changed files with 119 additions and 18 deletions
|
@ -0,0 +1,3 @@
|
|||
<CacheArtifacts>
|
||||
<Package Id="FluentAssertions" Version ="4.12.0"/>
|
||||
</CacheArtifacts>
|
5
TestAssets/TestProjects/FluentProfile/FluentProfile.xml
Normal file
5
TestAssets/TestProjects/FluentProfile/FluentProfile.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentAssertions" Version ="4.12.0"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,12 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NewtonSoft.Json" Version="9.0.1" />
|
||||
<PackageReference Include="FluentAssertions" Version="4.12.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
24
TestAssets/TestProjects/MultiDependentProject/Program.cs
Normal file
24
TestAssets/TestProjects/MultiDependentProject/Program.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using FluentAssertions;
|
||||
|
||||
class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
ArrayList argList = new ArrayList(args);
|
||||
JObject jObject = new JObject();
|
||||
|
||||
foreach (string arg in argList)
|
||||
{
|
||||
jObject[arg] = arg;
|
||||
}
|
||||
|
||||
jObject.Count.Should().Be(0);
|
||||
Console.WriteLine(jObject.ToString());
|
||||
}
|
||||
}
|
|
@ -3,12 +3,13 @@
|
|||
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using NuGet.Frameworks;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||
{
|
||||
public sealed class CacheCommand : TestCommand
|
||||
{
|
||||
private string _profileProject;
|
||||
private List<string> _profileProject = new List<string>();
|
||||
private string _framework;
|
||||
private string _output;
|
||||
private string _runtime;
|
||||
|
@ -22,7 +23,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
|
||||
public CacheCommand WithEntries(string profileProject)
|
||||
{
|
||||
_profileProject = profileProject;
|
||||
_profileProject.Add($"--entries {profileProject}");
|
||||
|
||||
return this;
|
||||
}
|
||||
public CacheCommand WithFramework(string framework)
|
||||
|
@ -83,7 +85,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
FrameworkVersionOption);
|
||||
}
|
||||
|
||||
private string ProfileProjectOption => string.IsNullOrEmpty(_profileProject) ? "" : $"--entries {_profileProject}";
|
||||
private string ProfileProjectOption => string.Join(" ", _profileProject) ;
|
||||
|
||||
private string FrameworkOption => string.IsNullOrEmpty(_framework) ? "" : $"-f {_framework}";
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using NuGet.Frameworks;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||
{
|
||||
|
@ -11,7 +12,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
private string _framework;
|
||||
private string _output;
|
||||
private string _runtime;
|
||||
private string _profileproj;
|
||||
private List<string> _profileFilterProject = new List<string>();
|
||||
|
||||
public PublishCommand()
|
||||
: base("dotnet")
|
||||
|
@ -43,7 +44,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
|
||||
public PublishCommand WithProFileProject(string profileproj)
|
||||
{
|
||||
_profileproj = profileproj;
|
||||
_profileFilterProject.Add( $" --filter {profileproj}");
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -74,6 +75,6 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
|
||||
private string RuntimeOption => string.IsNullOrEmpty(_runtime) ? "" : $"-r {_runtime}";
|
||||
|
||||
private string ProfileProjOption => string.IsNullOrEmpty(_profileproj) ? "" : $"--filter {_profileproj}";
|
||||
private string ProfileProjOption => string.Join(" ", _profileFilterProject);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,10 +33,7 @@ namespace Microsoft.DotNet.Cli.Publish.Tests
|
|||
var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
|
||||
var localAssemblyCache = Path.Combine(testProjectDirectory, "localAssemblyCache");
|
||||
var intermediateWorkingDirectory = Path.Combine(testProjectDirectory, "workingDirectory");
|
||||
var profileProjectPath = TestAssets.Get(profileProjectName)
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root.FullName;
|
||||
var profileProjectPath = TestAssets.Get(profileProjectName).Root.FullName;
|
||||
var profileProject = Path.Combine(profileProjectPath, $"{profileProjectName}.xml");
|
||||
|
||||
new RestoreCommand()
|
||||
|
@ -55,12 +52,12 @@ namespace Microsoft.DotNet.Cli.Publish.Tests
|
|||
.Should().Pass();
|
||||
|
||||
var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
|
||||
var profilefilter = Path.Combine(localAssemblyCache, _arch, _tfm, "artifact.xml");
|
||||
var profileFilter = Path.Combine(localAssemblyCache, _arch, _tfm, "artifact.xml");
|
||||
|
||||
new PublishCommand()
|
||||
.WithFramework(_tfm)
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.WithProFileProject(profilefilter)
|
||||
.WithProFileProject(profileFilter)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
|
@ -85,11 +82,8 @@ namespace Microsoft.DotNet.Cli.Publish.Tests
|
|||
.UseCurrentRuntimeFrameworkVersion();
|
||||
|
||||
var testProjectDirectory = testInstance.Root.ToString();
|
||||
var profileProjectPath = TestAssets.Get(profileProjectName)
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.Root.FullName;
|
||||
var profileProject = Path.Combine(profileProjectPath, "NewtonsoftFilterProfile.xml");
|
||||
var profileProjectPath = TestAssets.Get(profileProjectName).Root.FullName;
|
||||
var profileFilter = Path.Combine(profileProjectPath, "NewtonsoftFilterProfile.xml");
|
||||
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
|
@ -101,7 +95,7 @@ namespace Microsoft.DotNet.Cli.Publish.Tests
|
|||
new PublishCommand()
|
||||
.WithFramework(_tfm)
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.WithProFileProject(profileProject)
|
||||
.WithProFileProject(profileFilter)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
|
@ -112,5 +106,65 @@ namespace Microsoft.DotNet.Cli.Publish.Tests
|
|||
.Should().Fail()
|
||||
.And.HaveStdErrContaining("assembly specified in the dependencies manifest was not found -- package: 'newtonsoft.json',");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItPublishesAnAppWithMultipleProfiles()
|
||||
{
|
||||
var testAppName = "MultiDependentProject";
|
||||
var profileProjectName = "NewtonsoftProfile";
|
||||
var profileProjectName1 = "FluentProfile";
|
||||
|
||||
var testInstance = TestAssets.Get(testAppName)
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.UseCurrentRuntimeFrameworkVersion();
|
||||
|
||||
var testProjectDirectory = testInstance.Root.ToString();
|
||||
var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
|
||||
var localAssemblyCache = Path.Combine(testProjectDirectory, "lAC");
|
||||
var intermediateWorkingDirectory = Path.Combine(testProjectDirectory, "workingDirectory");
|
||||
|
||||
var profileProjectPath = TestAssets.Get(profileProjectName).Root.FullName;
|
||||
var profileProject = Path.Combine(profileProjectPath, $"{profileProjectName}.xml");
|
||||
var profileFilter = Path.Combine(profileProjectPath, "NewtonsoftFilterProfile.xml");
|
||||
|
||||
var profileProjectPath1 = TestAssets.Get(profileProjectName1).Root.FullName;
|
||||
var profileProject1 = Path.Combine(profileProjectPath1, $"{profileProjectName1}.xml");
|
||||
var profileFilter1 = Path.Combine(profileProjectPath1, "FluentFilterProfile.xml");
|
||||
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
new CacheCommand()
|
||||
.WithEntries(profileProject)
|
||||
.WithEntries(profileProject1)
|
||||
.WithFramework(_tfm)
|
||||
.WithRuntime(rid)
|
||||
.WithOutput(localAssemblyCache)
|
||||
.WithRuntimeFrameworkVersion(_frameworkVersion)
|
||||
.WithIntermediateWorkingDirectory(intermediateWorkingDirectory)
|
||||
.Execute($"--preserve-working-dir")
|
||||
.Should().Pass();
|
||||
|
||||
var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
|
||||
|
||||
new PublishCommand()
|
||||
.WithFramework(_tfm)
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.WithProFileProject(profileFilter)
|
||||
.WithProFileProject(profileFilter1)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
var outputDll = Path.Combine(testProjectDirectory, "bin", configuration, _tfm, "publish", $"{testAppName}.dll");
|
||||
|
||||
new TestCommand("dotnet")
|
||||
.WithEnvironmentVariable("DOTNET_SHARED_PACKAGES", localAssemblyCache)
|
||||
.ExecuteWithCapturedOutput(outputDll)
|
||||
.Should().Pass()
|
||||
.And.HaveStdOutContaining("{}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue