public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute) { if (!DiscovererHelpers.IsMonoRuntime) { TestPlatforms testPlatforms = TestPlatforms.Any; RuntimeTestModes stressMode = RuntimeTestModes.Any; RuntimeConfiguration runtimeConfigurations = RuntimeConfiguration.Any; foreach (object arg in traitAttribute.GetConstructorArguments().Skip(1)) // We skip the first one as it is the reason { if (arg is TestPlatforms tp) { testPlatforms = tp; } else if (arg is RuntimeTestModes rtm) { stressMode = rtm; } else if (arg is RuntimeConfiguration rc) { runtimeConfigurations = rc; } } if (DiscovererHelpers.TestPlatformApplies(testPlatforms) && RuntimeConfigurationApplies(runtimeConfigurations) && StressModeApplies(stressMode)) { return(new[] { new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.Failing) }); } } return(Array.Empty <KeyValuePair <string, string> >()); }
public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute) { if (!SkipOnMonoDiscoverer.IsMonoRuntime) { TestPlatforms testPlatforms = TestPlatforms.Any; RuntimeStressTestModes stressMode = RuntimeStressTestModes.Any; foreach (object arg in traitAttribute.GetConstructorArguments().Skip(1)) // We skip the first one as it is the reason { if (arg is TestPlatforms tp) { testPlatforms = tp; } else if (arg is RuntimeStressTestModes rstm) { stressMode = rstm; } } if (DiscovererHelpers.TestPlatformApplies(testPlatforms) && StressModeApplies(stressMode)) { if (IsCheckedRuntime() || (IsRuntimeStressTesting && !stressMode.HasFlag(RuntimeStressTestModes.CheckedRuntime))) { return(new[] { new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.Failing) }); } } } return(Array.Empty <KeyValuePair <string, string> >()); }
/// <summary> /// Gets the trait values from the Category attribute. /// </summary> /// <param name="traitAttribute">The trait attribute containing the trait values.</param> /// <returns>The trait values.</returns> public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute) { TestPlatforms platforms = (TestPlatforms)traitAttribute.GetConstructorArguments().First(); return(DiscovererHelpers.TestPlatformApplies(platforms) ? Array.Empty <KeyValuePair <string, string> >() : new[] { new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.Failing) }); }
/// <summary> /// Gets the trait values from the Category attribute. /// </summary> /// <param name="traitAttribute">The trait attribute containing the trait values.</param> /// <returns>The trait values.</returns> public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute) { TargetFrameworkMonikers frameworks = (TargetFrameworkMonikers)traitAttribute.GetConstructorArguments().First(); return(DiscovererHelpers.TestFrameworkApplies(frameworks) ? new[] { new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.Failing) } : Array.Empty <KeyValuePair <string, string> >()); }
/// <summary> /// Gets the trait values from the Category attribute. /// </summary> /// <param name="traitAttribute">The trait attribute containing the trait values.</param> /// <returns>The trait values.</returns> public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute) { IEnumerable <object> ctorArgs = traitAttribute.GetConstructorArguments(); if (ctorArgs.Count() < 2) { return(new[] { new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.OuterLoop) }); } return(DiscovererHelpers.EvaluateArguments(ctorArgs, XunitConstants.OuterLoop)); }
/// <summary> /// Gets the trait values from the Category attribute. /// </summary> /// <param name="traitAttribute">The trait attribute containing the trait values.</param> /// <returns>The trait values.</returns> public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute) { IEnumerable <object> ctorArgs = traitAttribute.GetConstructorArguments(); Debug.Assert(ctorArgs.Count() >= 2); string issue = ctorArgs.First().ToString(); TestPlatforms platforms = TestPlatforms.Any; TargetFrameworkMonikers frameworks = TargetFrameworkMonikers.Any; TestRuntimes runtimes = TestRuntimes.Any; Type calleeType = null; string[] conditionMemberNames = null; foreach (object arg in ctorArgs.Skip(1)) // First argument is the issue number. { if (arg is TestPlatforms) { platforms = (TestPlatforms)arg; } else if (arg is TargetFrameworkMonikers) { frameworks = (TargetFrameworkMonikers)arg; } else if (arg is TestRuntimes) { runtimes = (TestRuntimes)arg; } else if (arg is Type) { calleeType = (Type)arg; } else if (arg is string[]) { conditionMemberNames = (string[])arg; } } if (calleeType != null && conditionMemberNames != null) { if (!DiscovererHelpers.Evaluate(calleeType, conditionMemberNames)) { yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.Failing)); } } else if (DiscovererHelpers.TestPlatformApplies(platforms) && DiscovererHelpers.TestRuntimeApplies(runtimes) && DiscovererHelpers.TestFrameworkApplies(frameworks)) { yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.Failing)); } }
internal static IEnumerable <KeyValuePair <string, string> > EvaluateArguments(IEnumerable <object> ctorArgs, string category, int skipFirst = 1) { Debug.Assert(ctorArgs.Count() >= 2); TestPlatforms platforms = TestPlatforms.Any; TargetFrameworkMonikers frameworks = TargetFrameworkMonikers.Any; TestRuntimes runtimes = TestRuntimes.Any; Type calleeType = null; string[] conditionMemberNames = null; foreach (object arg in ctorArgs.Skip(skipFirst)) // First argument is the issue number or reason. { if (arg is TestPlatforms) { platforms = (TestPlatforms)arg; } else if (arg is TargetFrameworkMonikers) { frameworks = (TargetFrameworkMonikers)arg; } else if (arg is TestRuntimes) { runtimes = (TestRuntimes)arg; } else if (arg is Type) { calleeType = (Type)arg; } else if (arg is string[]) { conditionMemberNames = (string[])arg; } } if (calleeType != null && conditionMemberNames != null) { if (DiscovererHelpers.Evaluate(calleeType, conditionMemberNames)) { yield return(new KeyValuePair <string, string>(XunitConstants.Category, category)); } } else if (DiscovererHelpers.TestPlatformApplies(platforms) && DiscovererHelpers.TestRuntimeApplies(runtimes) && DiscovererHelpers.TestFrameworkApplies(frameworks)) { yield return(new KeyValuePair <string, string>(XunitConstants.Category, category)); } }
/// <summary> /// Gets the trait values from the Category attribute. /// </summary> /// <param name="traitAttribute">The trait attribute containing the trait values.</param> /// <returns>The trait values.</returns> public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute) { IEnumerable <object> ctorArgs = traitAttribute.GetConstructorArguments(); Debug.Assert(ctorArgs.Count() >= 2); string issue = ctorArgs.First().ToString(); TestPlatforms platforms = TestPlatforms.Any; TargetFrameworkMonikers frameworks = (TargetFrameworkMonikers)0; foreach (object arg in ctorArgs.Skip(1)) // First argument is the issue number. { if (arg is TestPlatforms) { platforms = (TestPlatforms)arg; } else if (arg is TargetFrameworkMonikers) { frameworks = (TargetFrameworkMonikers)arg; } } if (DiscovererHelpers.TestPlatformApplies(platforms)) { if (frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp)) { yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcoreappTest)); } if (frameworks.HasFlag(TargetFrameworkMonikers.NetFramework)) { yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetfxTest)); } if (frameworks.HasFlag(TargetFrameworkMonikers.Uap)) { yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonUapTest)); } if (frameworks.HasFlag(TargetFrameworkMonikers.Mono)) { yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonMonoTest)); } if (frameworks == (TargetFrameworkMonikers)0) { yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.Failing)); } yield return(new KeyValuePair <string, string>(XunitConstants.ActiveIssue, issue)); } }
public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute) { TestPlatforms testPlatforms = (TestPlatforms)0; // First argument is either the TestPlatform or the test platform to skip the test on. if (traitAttribute.GetConstructorArguments().FirstOrDefault() is TestPlatforms tp) { testPlatforms = tp; } if (DiscovererHelpers.TestPlatformApplies(testPlatforms)) { return(new[] { new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.Failing) }); } return(Array.Empty <KeyValuePair <string, string> >()); }
internal static bool EvaluateParameterHelper(IAttributeInfo traitAttribute) { // Parse the traitAttribute. We make sure it contains two parts: // 1. Type 2. nameof(conditionMemberName) object[] conditionArguments = traitAttribute.GetConstructorArguments().ToArray(); Debug.Assert(conditionArguments.Count() == 2); Type calleeType = null; string[] conditionMemberNames = null; if (ConditionalTestDiscoverer.CheckInputToSkipExecution(conditionArguments, ref calleeType, ref conditionMemberNames)) { return(true); } return(DiscovererHelpers.Evaluate(calleeType, conditionMemberNames)); }
/// <summary> /// Gets the trait values from the Category attribute. /// </summary> /// <param name="traitAttribute">The trait attribute containing the trait values.</param> /// <returns>The trait values.</returns> public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute) { IEnumerable <object> ctorArgs = traitAttribute.GetConstructorArguments(); Debug.Assert(ctorArgs.Count() >= 2); string issue = ctorArgs.First().ToString(); TestPlatforms platforms = TestPlatforms.Any; TargetFrameworkMonikers frameworks = TargetFrameworkMonikers.Any; TestRuntimes runtimes = TestRuntimes.Any; foreach (object arg in ctorArgs.Skip(1)) // First argument is the issue number. { if (arg is TestPlatforms) { platforms = (TestPlatforms)arg; } else if (arg is TargetFrameworkMonikers) { frameworks = (TargetFrameworkMonikers)arg; } else if (arg is TestRuntimes) { runtimes = (TestRuntimes)arg; } } if (DiscovererHelpers.TestPlatformApplies(platforms) && DiscovererHelpers.TestRuntimeApplies(runtimes) && DiscovererHelpers.TestFrameworkApplies(frameworks)) { return(new[] { new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.Failing) }); } return(Array.Empty <KeyValuePair <string, string> >()); }
/// <summary> /// Gets the trait values from the Category attribute. /// </summary> /// <param name="traitAttribute">The trait attribute containing the trait values.</param> /// <returns>The trait values.</returns> public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute) { IEnumerable <object> ctorArgs = traitAttribute.GetConstructorArguments(); return(DiscovererHelpers.EvaluateArguments(ctorArgs, XunitConstants.Failing)); }