Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion test/CppTests/OpenDebug/CrossPlatCpp/DebuggerRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
8 changes: 6 additions & 2 deletions test/CppTests/TestConfigurations/config_msys_gdb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
Name="GdbMingw64"
Type="Gdb_MinGW"
Path="D:\a\_temp\msys64\mingw64\bin\gdb.exe"
AdapterPath="OpenDebugAD7.exe"
/>
AdapterPath="OpenDebugAD7.exe">
<Environment>
<!--If running tests outside of a cygwin shell, uncomment this and adjust paths-->
<!--<Path>C:\msys64\mingw64\bin;C:\msys64\usr\bin;%PATH%</Path>-->
</Environment>
</Debugger>
</Debuggers>
</TestMachineConfiguration>
6 changes: 5 additions & 1 deletion test/DebuggerTesting/Attribution/DebuggerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public DebuggerSettings(
string debuggerAdapterPath,
string miMode,
SupportedArchitecture debuggeeArchitecture,
IDictionary<string, string> debuggerProperties)
IDictionary<string, string> debuggerProperties,
IDictionary<string, string> environmentVariables = null)
{
this.DebuggeeArchitecture = debuggeeArchitecture;
this.DebuggerName = debuggerName;
Expand All @@ -30,6 +31,7 @@ public DebuggerSettings(
if (!string.IsNullOrWhiteSpace(miMode))
this.MIMode = miMode;
this.Properties = debuggerProperties ?? new Dictionary<string, string>(StringComparer.Ordinal);
this.EnvironmentVariables = environmentVariables ?? new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
}

#endregion
Expand Down Expand Up @@ -119,6 +121,8 @@ public override string ToString()

public IDictionary<string, string> Properties { get; private set; }

public IDictionary<string, string> EnvironmentVariables { get; private set; }

#endregion
}
}
5 changes: 3 additions & 2 deletions test/DebuggerTesting/Attribution/TestSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ internal TestSettings(
string debuggerPath,
string debuggerAdapterPath,
string miMode,
IDictionary<string, string> debuggerProperties)
IDictionary<string, string> debuggerProperties,
IDictionary<string, string> 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)
Expand Down
23 changes: 21 additions & 2 deletions test/DebuggerTesting/Attribution/TestSettingsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ public static IEnumerable<ITestSettings> 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));

Expand Down Expand Up @@ -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();
Expand All @@ -215,6 +217,23 @@ private static IDictionary<string, string> GetPropertiesDictionary(this XElement
?.ToDictionary(p => p.GetAttributeValue("Name"), p => SafeExpandEnvironmentVariables(p.Value), StringComparer.Ordinal);
}

/// <summary>
/// Reads the Environment element and returns its child element names and values as a dictionary.
/// For example: <Environment><Path>value</Path></Environment> yields {"Path": "value"}
/// </summary>
private static IDictionary<string, string> GetEnvironmentDictionary(this XElement element)
{
var envElement = element.Element("Environment");
if (envElement == null)
return null;

Dictionary<string, string> 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<SupportedCompilerAttribute> compilers, ICompilerSettings settings)
{
return compilers.Any(ca => ca.Compiler.HasFlag(settings.CompilerType) && ca.Architecture.HasFlag(settings.DebuggeeArchitecture));
Expand Down
2 changes: 2 additions & 0 deletions test/DebuggerTesting/IDebuggerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public interface IDebuggerSettings

IDictionary<string, string> Properties { get; }

IDictionary<string, string> EnvironmentVariables { get; }

#endregion
}
}
Loading