diff --git a/test/CppTests/OpenDebug/CrossPlatCpp/DebuggerRunner.cs b/test/CppTests/OpenDebug/CrossPlatCpp/DebuggerRunner.cs index 0ae05f008..adacc6632 100644 --- a/test/CppTests/OpenDebug/CrossPlatCpp/DebuggerRunner.cs +++ b/test/CppTests/OpenDebug/CrossPlatCpp/DebuggerRunner.cs @@ -62,7 +62,8 @@ private DebuggerRunner(ILoggingComponent logger, ITestSettings testSettings, IEn pauseForDebugger: false, isVsDbg: this.DebuggerSettings.DebuggerType == SupportedDebugger.VsDbg, isNative: true, - responseTimeout: 5000); + responseTimeout: 5000, + additionalEnvironmentVariables: this.DebuggerSettings.EnvironmentVariables); if (callbackHandlers != null) { diff --git a/test/CppTests/TestConfigurations/config_msys_gdb.xml b/test/CppTests/TestConfigurations/config_msys_gdb.xml index 695f520f7..d6ee086ad 100644 --- a/test/CppTests/TestConfigurations/config_msys_gdb.xml +++ b/test/CppTests/TestConfigurations/config_msys_gdb.xml @@ -17,7 +17,11 @@ Name="GdbMingw64" Type="Gdb_MinGW" Path="D:\a\_temp\msys64\mingw64\bin\gdb.exe" - AdapterPath="OpenDebugAD7.exe" - /> + AdapterPath="OpenDebugAD7.exe"> + + + + + \ No newline at end of file diff --git a/test/DebuggerTesting/Attribution/DebuggerSettings.cs b/test/DebuggerTesting/Attribution/DebuggerSettings.cs index 3e1c9036b..50fdf2a79 100644 --- a/test/DebuggerTesting/Attribution/DebuggerSettings.cs +++ b/test/DebuggerTesting/Attribution/DebuggerSettings.cs @@ -20,7 +20,8 @@ public DebuggerSettings( string debuggerAdapterPath, string miMode, SupportedArchitecture debuggeeArchitecture, - IDictionary debuggerProperties) + IDictionary debuggerProperties, + IDictionary environmentVariables = null) { this.DebuggeeArchitecture = debuggeeArchitecture; this.DebuggerName = debuggerName; @@ -30,6 +31,7 @@ public DebuggerSettings( if (!string.IsNullOrWhiteSpace(miMode)) this.MIMode = miMode; this.Properties = debuggerProperties ?? new Dictionary(StringComparer.Ordinal); + this.EnvironmentVariables = environmentVariables ?? new Dictionary(StringComparer.OrdinalIgnoreCase); } #endregion @@ -119,6 +121,8 @@ public override string ToString() public IDictionary Properties { get; private set; } + public IDictionary EnvironmentVariables { get; private set; } + #endregion } } diff --git a/test/DebuggerTesting/Attribution/TestSettings.cs b/test/DebuggerTesting/Attribution/TestSettings.cs index e393f1f08..37476de75 100644 --- a/test/DebuggerTesting/Attribution/TestSettings.cs +++ b/test/DebuggerTesting/Attribution/TestSettings.cs @@ -24,10 +24,11 @@ internal TestSettings( string debuggerPath, string debuggerAdapterPath, string miMode, - IDictionary debuggerProperties) + IDictionary debuggerProperties, + IDictionary environmentVariables = null) { this.CompilerSettings = new CompilerSettings(compilerName, compilerType, compilerPath, debuggeeArchitecture, compilerProperties); - this.DebuggerSettings = new DebuggerSettings(debuggerName, debuggerType, debuggerPath, debuggerAdapterPath, miMode, debuggeeArchitecture, debuggerProperties); + this.DebuggerSettings = new DebuggerSettings(debuggerName, debuggerType, debuggerPath, debuggerAdapterPath, miMode, debuggeeArchitecture, debuggerProperties, environmentVariables); } private TestSettings(ITestSettings original, string name) diff --git a/test/DebuggerTesting/Attribution/TestSettingsHelper.cs b/test/DebuggerTesting/Attribution/TestSettingsHelper.cs index 7ca8db5c9..bda80b539 100644 --- a/test/DebuggerTesting/Attribution/TestSettingsHelper.cs +++ b/test/DebuggerTesting/Attribution/TestSettingsHelper.cs @@ -158,7 +158,8 @@ public static IEnumerable LoadSettingsFromConfig(string configPat Path = x.GetAttributeValue("Path"), AdapterPath = x.GetAttributeValue("AdapterPath"), MIMode = x.GetAttributeValue("MIMode"), - Properties = x.GetPropertiesDictionary() + Properties = x.GetPropertiesDictionary(), + EnvironmentVariables = x.GetEnvironmentDictionary() }); Assert.True(null != debuggers && debuggers.Count != 0, "Object loaded from '{0}' is not a TestMachineConfiguration. Missing Debuggers.".FormatInvariantWithArgs(configPath)); @@ -197,7 +198,8 @@ into config SafeExpandEnvironmentVariables(config.Debugger.Path), SafeExpandEnvironmentVariables(config.Debugger.AdapterPath), config.Debugger.MIMode, - config.Debugger.Properties); + config.Debugger.Properties, + config.Debugger.EnvironmentVariables); // Force evaluation return testSettings.ToArray(); @@ -215,6 +217,23 @@ private static IDictionary GetPropertiesDictionary(this XElement ?.ToDictionary(p => p.GetAttributeValue("Name"), p => SafeExpandEnvironmentVariables(p.Value), StringComparer.Ordinal); } + /// + /// Reads the Environment element and returns its child element names and values as a dictionary. + /// For example: value yields {"Path": "value"} + /// + private static IDictionary GetEnvironmentDictionary(this XElement element) + { + var envElement = element.Element("Environment"); + if (envElement == null) + return null; + + Dictionary result = envElement + .Elements() + .ToDictionary(e => e.Name.LocalName, e => SafeExpandEnvironmentVariables(e.Value), StringComparer.OrdinalIgnoreCase); + + return result.Count > 0 ? result : null; + } + private static bool Matches(this IEnumerable compilers, ICompilerSettings settings) { return compilers.Any(ca => ca.Compiler.HasFlag(settings.CompilerType) && ca.Architecture.HasFlag(settings.DebuggeeArchitecture)); diff --git a/test/DebuggerTesting/IDebuggerSettings.cs b/test/DebuggerTesting/IDebuggerSettings.cs index 0117f3579..d9a4e3079 100644 --- a/test/DebuggerTesting/IDebuggerSettings.cs +++ b/test/DebuggerTesting/IDebuggerSettings.cs @@ -26,6 +26,8 @@ public interface IDebuggerSettings IDictionary Properties { get; } + IDictionary EnvironmentVariables { get; } + #endregion } }