, m_host_interface()
, m_tfm(get_app(fx_definitions).get_runtime_config().get_tfm())
{
- make_cstr_arr(m_clr_keys, &m_clr_keys_cstr);
- make_cstr_arr(m_clr_values, &m_clr_values_cstr);
make_cstr_arr(m_probe_paths, &m_probe_paths_cstr);
int fx_count = fx_definitions.size();
make_cstr_arr(m_fx_dirs, &m_fx_dirs_cstr);
make_cstr_arr(m_fx_requested_versions, &m_fx_requested_versions_cstr);
make_cstr_arr(m_fx_found_versions, &m_fx_found_versions_cstr);
+ make_cstr_arr(m_clr_keys, &m_clr_keys_cstr);
+ make_cstr_arr(m_clr_values, &m_clr_values_cstr);
}
const pal::string_t& tfm() const
// Add versions in the exe folders
AddAvailableSharedFxVersions(_exeSharedFxBaseDir, "9999.0.0");
- AddAvailableSharedUberFxVersions(_exeSharedUberFxBaseDir, "9999.0.0", "7777.0.0");
+ AddAvailableSharedUberFxVersions(_exeSharedUberFxBaseDir, "9999.0.0", null, "7777.0.0");
// Version: NetCoreApp 9999.0.0
// UberFramework 7777.0.0
// Add a newer version to verify roll-forward
AddAvailableSharedFxVersions(_exeSharedFxBaseDir, "9999.0.1");
- AddAvailableSharedUberFxVersions(_exeSharedUberFxBaseDir, "9999.0.0", "7777.0.1");
+ AddAvailableSharedUberFxVersions(_exeSharedUberFxBaseDir, "9999.0.0", null, "7777.0.1");
// Version: NetCoreApp 9999.0.0
// UberFramework 7777.0.0
}
[Fact]
- public void Multiple_SharedFxLookup_Propagated_RuntimeConfig_Value()
+ public void Multiple_SharedFxLookup_Propagated_RuntimeConfig_Values()
{
var fixture = PreviouslyBuiltAndRestoredPortableTestProjectFixture
.Copy();
// Add versions in the exe folders
AddAvailableSharedFxVersions(_exeSharedFxBaseDir, "9999.1.0");
- AddAvailableSharedUberFxVersions(_exeSharedUberFxBaseDir, "9999.0.0", "7777.0.0");
+ AddAvailableSharedUberFxVersions(_exeSharedUberFxBaseDir, "9999.0.0", "UberValue", "7777.0.0");
// Version: NetCoreApp 9999.0.0
// UberFramework 7777.0.0
.And
.HaveStdErrContaining("It was not possible to find any compatible framework version");
- // Add the rollForwardOnNoCandidateFx value to the Uber runtimeconfig which should carry over to NetCoreApp
- SetRuntimeConfigJson(runtimeConfig, "7777.0.0", rollFwdOnNoCandidateFx: 1, useUberFramework: true);
+ // Enable rollForwardOnNoCandidateFx
+ SetRuntimeConfigJson(runtimeConfig, "7777.0.0", rollFwdOnNoCandidateFx: 1, testConfigPropertyValue : null, useUberFramework: true);
// Version: NetCoreApp 9999.0.0
// UberFramework 7777.0.0
.And
.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.1.0"))
.And
- .HaveStdErrContaining(Path.Combine(_exeFoundUberFxMessage, "7777.0.0"));
+ .HaveStdErrContaining(Path.Combine(_exeFoundUberFxMessage, "7777.0.0"))
+ .And
+ .HaveStdErrContaining("Property TestProperty = UberValue");
+
+ // Change the app's TestProperty value which should override the uber's config value
+ SetRuntimeConfigJson(runtimeConfig, "7777.0.0", rollFwdOnNoCandidateFx: 1, testConfigPropertyValue: "AppValue", useUberFramework: true);
+
+ // Version: NetCoreApp 9999.0.0
+ // UberFramework 7777.0.0
+ // Exe: NetCoreApp 9999.1.0
+ // UberFramework 7777.0.0
+ // Expected: 9999.1.0
+ // 7777.0.0
+ dotnet.Exec(appDll)
+ .WorkingDirectory(_currentWorkingDir)
+ .EnvironmentVariable("COREHOST_TRACE", "1")
+ .CaptureStdOut()
+ .CaptureStdErr()
+ .Execute()
+ .Should()
+ .Pass()
+ .And
+ .HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.1.0"))
+ .And
+ .HaveStdErrContaining(Path.Combine(_exeFoundUberFxMessage, "7777.0.0"))
+ .And
+ .HaveStdErrContaining("Property TestProperty = AppValue");
DeleteAvailableSharedFxVersions(_exeSharedFxBaseDir, "9999.1.0");
DeleteAvailableSharedFxVersions(_exeSharedUberFxBaseDir, "7777.0.0");
// Add versions in the exe folders
AddAvailableSharedFxVersions(_exeSharedFxBaseDir, "9999.0.0");
- AddAvailableSharedUberFxVersions(_exeSharedUberFxBaseDir, "9999.0.0", "7777.0.0");
+ AddAvailableSharedUberFxVersions(_exeSharedUberFxBaseDir, "9999.0.0", null, "7777.0.0");
// The System.Collections.Immutable.dll is located in the UberFramework and NetCoreApp
// The System.Collections.dll is only located in NetCoreApp
// This method adds a list of new framework version folders in the specified
// sharedFxUberBaseDir. A runtimeconfig file is created that references
// Microsoft.NETCore.App version=sharedFxBaseVersion
- private void AddAvailableSharedUberFxVersions(string sharedUberFxBaseDir, string sharedFxBaseVersion, params string[] availableUberVersions)
+ private void AddAvailableSharedUberFxVersions(string sharedUberFxBaseDir, string sharedFxBaseVersion, string testConfigPropertyValue = null, params string[] availableUberVersions)
{
DirectoryInfo sharedFxUberBaseDirInfo = new DirectoryInfo(sharedUberFxBaseDir);
CopyDirectory(_builtSharedUberFxDir, newSharedFxDir);
string runtimeBaseConfig = Path.Combine(newSharedFxDir, "Microsoft.UberFramework.runtimeconfig.json");
- SetRuntimeConfigJson(runtimeBaseConfig, sharedFxBaseVersion);
+ SetRuntimeConfigJson(runtimeBaseConfig, sharedFxBaseVersion, null, testConfigPropertyValue);
}
}
* }
* }
*/
- private void SetRuntimeConfigJson(string destFile, string version, int? rollFwdOnNoCandidateFx = null, bool? useUberFramework = false)
+ private void SetRuntimeConfigJson(string destFile, string version, int? rollFwdOnNoCandidateFx = null, string testConfigPropertyValue = null, bool? useUberFramework = false)
{
string name = useUberFramework.HasValue && useUberFramework.Value ? "Microsoft.UberFramework" : "Microsoft.NETCore.App";
runtimeOptions.Add("rollForwardOnNoCandidateFx", rollFwdOnNoCandidateFx);
}
+ if (testConfigPropertyValue != null)
+ {
+ runtimeOptions.Add(
+ new JProperty("configProperties",
+ new JObject(
+ new JProperty("TestProperty", testConfigPropertyValue)
+ )
+ )
+ );
+ }
+
FileInfo file = new FileInfo(destFile);
if (!file.Directory.Exists)
{
public AndConstraint<CommandResultAssertions> ExitWith(int expectedExitCode)
{
Execute.Assertion.ForCondition(_commandResult.ExitCode == expectedExitCode)
- .FailWith(AppendDiagnosticsTo($"Expected command to exit with {expectedExitCode} but it did not."));
+ .FailWith("Expected command to exit with {0} but it did not.{1}", expectedExitCode, GetDiagnosticsInfo());
return new AndConstraint<CommandResultAssertions>(this);
}
public AndConstraint<CommandResultAssertions> Pass()
{
Execute.Assertion.ForCondition(_commandResult.ExitCode == 0)
- .FailWith(AppendDiagnosticsTo($"Expected command to pass but it did not."));
+ .FailWith("Expected command to pass but it did not.{0}", GetDiagnosticsInfo());
return new AndConstraint<CommandResultAssertions>(this);
}
public AndConstraint<CommandResultAssertions> Fail()
{
Execute.Assertion.ForCondition(_commandResult.ExitCode != 0)
- .FailWith(AppendDiagnosticsTo($"Expected command to fail but it did not."));
+ .FailWith("Expected command to fail but it did not.{0}", GetDiagnosticsInfo());
return new AndConstraint<CommandResultAssertions>(this);
}
public AndConstraint<CommandResultAssertions> HaveStdOut()
{
Execute.Assertion.ForCondition(!string.IsNullOrEmpty(_commandResult.StdOut))
- .FailWith(AppendDiagnosticsTo("Command did not output anything to stdout"));
+ .FailWith("Command did not output anything to stdout{0}", GetDiagnosticsInfo());
return new AndConstraint<CommandResultAssertions>(this);
}
public AndConstraint<CommandResultAssertions> HaveStdOut(string expectedOutput)
{
Execute.Assertion.ForCondition(_commandResult.StdOut.Equals(expectedOutput, StringComparison.Ordinal))
- .FailWith(AppendDiagnosticsTo($"Command did not output with Expected Output. Expected: {expectedOutput}"));
+ .FailWith("Command did not output with Expected Output. Expected: {0}{1}", expectedOutput, GetDiagnosticsInfo());
return new AndConstraint<CommandResultAssertions>(this);
}
public AndConstraint<CommandResultAssertions> HaveStdOutContaining(string pattern)
{
Execute.Assertion.ForCondition(_commandResult.StdOut.Contains(pattern))
- .FailWith(AppendDiagnosticsTo($"The command output did not contain expected result: {pattern}{Environment.NewLine}"));
+ .FailWith("The command output did not contain expected result: {0}{1}", pattern, GetDiagnosticsInfo());
return new AndConstraint<CommandResultAssertions>(this);
}
public AndConstraint<CommandResultAssertions> HaveStdOutMatching(string pattern, RegexOptions options = RegexOptions.None)
{
Execute.Assertion.ForCondition(Regex.Match(_commandResult.StdOut, pattern, options).Success)
- .FailWith(AppendDiagnosticsTo($"Matching the command output failed. Pattern: {pattern}{Environment.NewLine}"));
+ .FailWith("Matching the command output failed. Pattern: {0}{1}", pattern, GetDiagnosticsInfo());
return new AndConstraint<CommandResultAssertions>(this);
}
public AndConstraint<CommandResultAssertions> HaveStdErr()
{
Execute.Assertion.ForCondition(!string.IsNullOrEmpty(_commandResult.StdErr))
- .FailWith(AppendDiagnosticsTo("Command did not output anything to stderr."));
+ .FailWith("Command did not output anything to stderr.{0}", GetDiagnosticsInfo());
return new AndConstraint<CommandResultAssertions>(this);
}
public AndConstraint<CommandResultAssertions> HaveStdErrContaining(string pattern)
{
Execute.Assertion.ForCondition(_commandResult.StdErr.Contains(pattern))
- .FailWith(AppendDiagnosticsTo($"The command error output did not contain expected result: {pattern}{Environment.NewLine}"));
+ .FailWith("The command error output did not contain expected result: {0}{1}", pattern, GetDiagnosticsInfo());
return new AndConstraint<CommandResultAssertions>(this);
}
public AndConstraint<CommandResultAssertions> NotHaveStdErrContaining(string pattern)
{
Execute.Assertion.ForCondition(!_commandResult.StdErr.Contains(pattern))
- .FailWith(AppendDiagnosticsTo($"The command error output contained a result it should not have contained: {pattern}{Environment.NewLine}"));
+ .FailWith("The command error output contained a result it should not have contained: {0}{1}", pattern, GetDiagnosticsInfo());
return new AndConstraint<CommandResultAssertions>(this);
}
public AndConstraint<CommandResultAssertions> HaveStdErrMatching(string pattern, RegexOptions options = RegexOptions.None)
{
Execute.Assertion.ForCondition(Regex.Match(_commandResult.StdErr, pattern, options).Success)
- .FailWith(AppendDiagnosticsTo($"Matching the command error output failed. Pattern: {pattern}{Environment.NewLine}"));
+ .FailWith("Matching the command error output failed. Pattern: {0}{1}", pattern, GetDiagnosticsInfo());
return new AndConstraint<CommandResultAssertions>(this);
}
public AndConstraint<CommandResultAssertions> NotHaveStdOut()
{
Execute.Assertion.ForCondition(string.IsNullOrEmpty(_commandResult.StdOut))
- .FailWith(AppendDiagnosticsTo($"Expected command to not output to stdout but it was not:"));
+ .FailWith("Expected command to not output to stdout but it was not:{0}", GetDiagnosticsInfo());
return new AndConstraint<CommandResultAssertions>(this);
}
public AndConstraint<CommandResultAssertions> NotHaveStdErr()
{
Execute.Assertion.ForCondition(string.IsNullOrEmpty(_commandResult.StdErr))
- .FailWith(AppendDiagnosticsTo("Expected command to not output to stderr but it was not:"));
+ .FailWith("Expected command to not output to stderr but it was not:{0}", GetDiagnosticsInfo());
return new AndConstraint<CommandResultAssertions>(this);
}
- private string AppendDiagnosticsTo(string s)
+
+ private string GetDiagnosticsInfo()
{
- return s + $"{Environment.NewLine}" +
- $"File Name: {_commandResult.StartInfo.FileName}{Environment.NewLine}" +
- $"Arguments: {_commandResult.StartInfo.Arguments}{Environment.NewLine}" +
- $"Exit Code: {_commandResult.ExitCode}{Environment.NewLine}" +
- $"StdOut:{Environment.NewLine}{_commandResult.StdOut}{Environment.NewLine}" +
- $"StdErr:{Environment.NewLine}{_commandResult.StdErr}{Environment.NewLine}"; ;
+ return $"{Environment.NewLine}" +
+ $"File Name: {_commandResult.StartInfo.FileName}{Environment.NewLine}" +
+ $"Arguments: {_commandResult.StartInfo.Arguments}{Environment.NewLine}" +
+ $"Exit Code: {_commandResult.ExitCode}{Environment.NewLine}" +
+ $"StdOut:{Environment.NewLine}{_commandResult.StdOut}{Environment.NewLine}" +
+ $"StdErr:{Environment.NewLine}{_commandResult.StdErr}{Environment.NewLine}"; ;
}
-
- public AndConstraint<CommandResultAssertions> HaveSkippedProjectCompilation(string skippedProject, string frameworkFullName)
+
+ public AndConstraint<CommandResultAssertions> HaveSkippedProjectCompilation(string skippedProject, string frameworkFullName)
{
- _commandResult.StdOut.Should().Contain($"Project {skippedProject} ({frameworkFullName}) was previously compiled. Skipping compilation.");
+ _commandResult.StdOut.Should().Contain("Project {0} ({1}) was previously compiled. Skipping compilation.", skippedProject, frameworkFullName);
return new AndConstraint<CommandResultAssertions>(this);
}
public AndConstraint<CommandResultAssertions> HaveCompiledProject(string compiledProject, string frameworkFullName)
{
- _commandResult.StdOut.Should().Contain($"Project {compiledProject} ({frameworkFullName}) will be compiled");
+ _commandResult.StdOut.Should().Contain($"Project {0} ({1}) will be compiled", compiledProject, frameworkFullName);
return new AndConstraint<CommandResultAssertions>(this);
}