diff --git a/src/Tests/Common/Program.cs b/src/Tests/Common/Program.cs index b3d9c8819643..ea46bf08e729 100644 --- a/src/Tests/Common/Program.cs +++ b/src/Tests/Common/Program.cs @@ -26,6 +26,7 @@ public static int Main(string[] args) if (!testCommandLine.ShouldShowHelp) { + newArgs.AddRange(TestCommandLine.GetXunitArgsFromTestConfig(testCommandLine.TestConfigFile)); BeforeTestRun(newArgs); } diff --git a/src/Tests/Microsoft.NET.TestFramework/TestCommandLine.cs b/src/Tests/Microsoft.NET.TestFramework/TestCommandLine.cs index 48967fb7584f..48e24276d4f8 100644 --- a/src/Tests/Microsoft.NET.TestFramework/TestCommandLine.cs +++ b/src/Tests/Microsoft.NET.TestFramework/TestCommandLine.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Xml.Linq; namespace Microsoft.NET.TestFramework { @@ -27,6 +28,8 @@ public class TestCommandLine public string TestExecutionDirectory { get; set; } + public string TestConfigFile { get; private set; } + public bool ShowSdkInfo { get; private set; } public static TestCommandLine Parse(string[] args) @@ -70,6 +73,10 @@ public static TestCommandLine Parse(string[] args) { ret.TestExecutionDirectory = argStack.Pop(); } + else if (arg.Equals("-testConfigFile", StringComparison.CurrentCultureIgnoreCase)) + { + ret.TestConfigFile = argStack.Pop(); + } else if (arg.Equals("-showSdkInfo", StringComparison.CurrentCultureIgnoreCase)) { ret.ShowSdkInfo = true; @@ -102,6 +109,32 @@ public static TestCommandLine Parse(string[] args) return ret; } + public static List GetXunitArgsFromTestConfig(string testConfigFile) + { + List ret = new List(); + if (!string.IsNullOrEmpty(testConfigFile)) + { + var testConfig = XDocument.Load(testConfigFile); + foreach (var item in testConfig.Root.Elements()) + { + if (item.Name.LocalName.Equals("Method", StringComparison.OrdinalIgnoreCase)) + { + var methodToSkip = item.Attribute("Name")?.Value; + + if (!string.IsNullOrEmpty(methodToSkip) && + bool.TryParse(item.Attribute("Skip").Value, out bool shouldSkip) && + shouldSkip) + { + ret.Add("-nomethod"); + ret.Add(methodToSkip); + } + } + } + } + + return ret; + } + public static TestCommandLine HandleCommandLine(string [] args) { TestCommandLine commandLine = Parse(args);