Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
adding tests for templated AdditionalProbingPath
Browse files Browse the repository at this point in the history
  • Loading branch information
ramarag committed May 26, 2017
1 parent a5ac221 commit 7c58389
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,40 @@ public void Muxer_Exec_activation_of_Build_Output_Portable_DLL_with_DepsJson_Loc
.HaveStdOutContaining("Hello World");
}

[Fact]
public void Muxer_Activation_With_Templated_AdditionalProbingPath_Succeeds()
{
var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture
.Copy();

var store_path = CreateAStore(fixture);
var dotnet = fixture.BuiltDotnet;
var appDll = fixture.TestProject.AppDll;

var destRuntimeDevConfig = fixture.TestProject.RuntimeDevConfigJson;
if (File.Exists(destRuntimeDevConfig))
{
File.Delete(destRuntimeDevConfig);
}

var additionalProbingPath = store_path + "/|arch|/|tfm|";

dotnet.Exec(
"exec",
"--additionalprobingpath", additionalProbingPath,
appDll)
.EnvironmentVariable("COREHOST_TRACE", "1")
.CaptureStdErr()
.CaptureStdOut()
.Execute()
.Should()
.Pass()
.And
.HaveStdOutContaining("Hello World")
.And
.HaveStdErrContaining($"Adding tpa entry: {Path.Combine(store_path,fixture.RepoDirProvider.BuildArchitecture, fixture.Framework)}");
}

[Fact]
public void Muxer_Exec_activation_of_Build_Output_Portable_DLL_with_DepsJson_Remote_and_RuntimeConfig_Local_Succeeds()
{
Expand Down Expand Up @@ -255,5 +289,18 @@ private void MoveRuntimeConfigToSubdirectory(TestProjectFixture testProjectFixtu

testProjectFixture.TestProject.RuntimeConfigJson = destRuntimeConfig;
}

private string CreateAStore(TestProjectFixture testProjectFixture)
{
var storeoutputDirectory = Path.Combine(testProjectFixture.TestProject.ProjectDirectory, "store");
if (!Directory.Exists(storeoutputDirectory))
{
Directory.CreateDirectory(storeoutputDirectory);
}

testProjectFixture.StoreProject(outputDirectory :storeoutputDirectory);

return storeoutputDirectory;
}
}
}
3 changes: 3 additions & 0 deletions src/test/TestUtils/TestProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class TestProject
private string _projectFile;
private string _projectAssetsJson;
private string _runtimeConfigJson;
private string _runtimeDevConfigJson;
private string _depsJson;
private string _appDll;
private string _appExe;
Expand All @@ -32,6 +33,7 @@ public class TestProject
public string ProjectFile { get { return _projectFile; } set { _projectFile = value; } }
public string ProjectAssetsJson { get { return _projectAssetsJson; } set { _projectAssetsJson = value; } }
public string RuntimeConfigJson { get { return _runtimeConfigJson; } set { _runtimeConfigJson = value; } }
public string RuntimeDevConfigJson { get { return _runtimeDevConfigJson; } set { _runtimeDevConfigJson = value; } }
public string DepsJson { get { return _depsJson; } set { _depsJson = value; } }
public string AppDll { get { return _appDll; } set { _appDll = value; } }
public string AppExe { get { return _appExe; } set { _appExe = value; } }
Expand Down Expand Up @@ -71,6 +73,7 @@ public void LoadOutputFiles()
_appExe = Path.Combine(_outputDirectory, $"{_projectName}{_exeExtension}");
_depsJson = Path.Combine(_outputDirectory, $"{_projectName}.deps.json");
_runtimeConfigJson = Path.Combine(_outputDirectory, $"{_projectName}.runtimeconfig.json");
_runtimeDevConfigJson = Path.Combine(_outputDirectory, $"{_projectName}.runtimeconfig.dev.json");
_hostPolicyDll = Path.Combine(_outputDirectory, $"{_sharedLibraryPrefix}hostpolicy{_sharedLibraryExtension}");
_hostFxrDll = Path.Combine(_outputDirectory, $"{_sharedLibraryPrefix}hostfxr{_sharedLibraryExtension}");
}
Expand Down
22 changes: 16 additions & 6 deletions src/test/TestUtils/TestProjectFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class TestProjectFixture
private string _testProjectSourceDirectory;
private string _testArtifactDirectory;
private string _currentRid;
private string _framework;

private RepoDirectoriesProvider _repoDirectoriesProvider;

Expand All @@ -38,7 +39,8 @@ public class TestProjectFixture
public string ExeExtension => _exeExtension;
public string SharedLibraryExtension => _sharedLibraryExtension;
public string SharedLibraryPrefix => _sharedLibraryPrefix;

public string Framework => _framework;
public RepoDirectoriesProvider RepoDirProvider => _repoDirectoriesProvider;
public TestProjectFixture(
string testProjectName,
RepoDirectoriesProvider repoDirectoriesProvider,
Expand All @@ -49,7 +51,8 @@ public TestProjectFixture(
string testArtifactDirectory = null,
string dotnetInstallPath = null,
string currentRid = null,
string builtDotnetOutputPath = null)
string builtDotnetOutputPath = null,
string framework = "netcoreapp2.0")
{
ValidateRequiredDirectories(repoDirectoriesProvider);

Expand All @@ -73,7 +76,7 @@ public TestProjectFixture(
_currentRid = currentRid ?? repoDirectoriesProvider.TargetRID;

_builtDotnet = new DotNetCli(repoDirectoriesProvider.BuiltDotnet);

_framework = framework;
InitializeTestProject(
_testProjectName,
_testProjectSourceDirectory,
Expand All @@ -96,6 +99,7 @@ public TestProjectFixture(TestProjectFixture fixtureToCopy)
_currentRid = fixtureToCopy._currentRid;
_builtDotnet = fixtureToCopy._builtDotnet;
_sourceTestProject = fixtureToCopy._sourceTestProject;
_framework = fixtureToCopy._framework;

_testProject = CopyTestProject(
fixtureToCopy.TestProject,
Expand Down Expand Up @@ -196,12 +200,14 @@ private void ValidateRequiredDirectories(RepoDirectoriesProvider repoDirectories
public TestProjectFixture BuildProject(
DotNetCli dotnet = null,
string runtime = null,
string framework = "netcoreapp2.0",
string framework = null,
string outputDirectory = null)
{
dotnet = dotnet ?? _sdkDotnet;
outputDirectory = outputDirectory ?? _testProject.OutputDirectory;
_testProject.OutputDirectory = outputDirectory;
framework = framework ?? _framework;
_framework = framework;

var buildArgs = new List<string>();
if (runtime != null)
Expand Down Expand Up @@ -238,12 +244,14 @@ public TestProjectFixture BuildProject(
public TestProjectFixture StoreProject(
DotNetCli dotnet = null,
string runtime = null,
string framework = "netcoreapp2.0",
string framework = null,
string manifest = null,
string outputDirectory = null)
{
dotnet = dotnet ?? _sdkDotnet;
outputDirectory = outputDirectory ?? _testProject.OutputDirectory;
framework = framework ?? _framework;
_framework = framework;

var storeArgs = new List<string>();
storeArgs.Add("--runtime");
Expand Down Expand Up @@ -297,12 +305,14 @@ public TestProjectFixture StoreProject(
public TestProjectFixture PublishProject(
DotNetCli dotnet = null,
string runtime = null,
string framework = "netcoreapp2.0",
string framework = null,
string outputDirectory = null)
{
dotnet = dotnet ?? _sdkDotnet;
outputDirectory = outputDirectory ?? _testProject.OutputDirectory;
_testProject.OutputDirectory = outputDirectory;
framework = framework ?? _framework;
_framework = framework;

var publishArgs = new List<string>();
if (runtime != null)
Expand Down

0 comments on commit 7c58389

Please sign in to comment.