Update param validation and skipOnFalseEnv/skipOnTrueEnv logic
This commit is contained in:
parent
8ec128e7e0
commit
1c7e46ebe0
3 changed files with 14 additions and 22 deletions
|
@ -44,9 +44,9 @@ public class ArtifactsSizeTest : SmokeTests
|
|||
[SkippableFact(Config.IncludeArtifactsSizeEnv, skipOnFalseEnv: true)]
|
||||
public void CompareArtifactsToBaseline()
|
||||
{
|
||||
OutputHelper.LogAndThrowIfNullOrEmpty(Config.SourceBuiltArtifactsPath, Config.SourceBuiltArtifactsPathEnv);
|
||||
OutputHelper.LogAndThrowIfNullOrEmpty(Config.SdkTarballPath, Config.SdkTarballPathEnv);
|
||||
OutputHelper.LogAndThrowIfNullOrEmpty(Config.TargetRid, Config.TargetRidEnv);
|
||||
Utilities.ValidateNotNullOrWhiteSpace(Config.SourceBuiltArtifactsPath, Config.SourceBuiltArtifactsPathEnv);
|
||||
Utilities.ValidateNotNullOrWhiteSpace(Config.SdkTarballPath, Config.SdkTarballPathEnv);
|
||||
Utilities.ValidateNotNullOrWhiteSpace(Config.TargetRid, Config.TargetRidEnv);
|
||||
|
||||
var tarEntries = ProcessSdkAndArtifactsTarballs();
|
||||
|
||||
|
|
|
@ -30,18 +30,15 @@ internal class SkippableFactAttribute : FactAttribute
|
|||
setSkip($"Skipping because `{envName}` is null or whitespace");
|
||||
break;
|
||||
}
|
||||
else if ((skipOnTrueEnv || skipOnFalseEnv) && bool.TryParse(envValue, out bool boolValue))
|
||||
else if (skipOnTrueEnv && bool.TryParse(envValue, out bool boolValue) && boolValue)
|
||||
{
|
||||
if (skipOnTrueEnv && boolValue)
|
||||
{
|
||||
setSkip($"Skipping because `{envName}` is set to True");
|
||||
break;
|
||||
}
|
||||
else if (skipOnFalseEnv && !boolValue)
|
||||
{
|
||||
setSkip($"Skipping because `{envName}` is set to False");
|
||||
break;
|
||||
}
|
||||
setSkip($"Skipping because `{envName}` is set to True");
|
||||
break;
|
||||
}
|
||||
else if (skipOnFalseEnv && (!bool.TryParse(envValue, out boolValue) || !boolValue))
|
||||
{
|
||||
setSkip($"Skipping because `{envName}` is set to False or an invalid value");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -115,16 +115,11 @@ public static class Utilities
|
|||
outputHelper.WriteLine("##vso[task.complete result=SucceededWithIssues;]");
|
||||
}
|
||||
|
||||
public static void LogAndThrowIfNullOrEmpty(this ITestOutputHelper outputHelper, string? variable, string variableName)
|
||||
public static void ValidateNotNullOrWhiteSpace(string? variable, string variableName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(variable) || string.IsNullOrWhiteSpace(variable))
|
||||
if (string.IsNullOrWhiteSpace(variable))
|
||||
{
|
||||
string prefix = "##vso[task.logissue type=error;]";
|
||||
string message = $"{variableName} is null, empty, or whitespace.";
|
||||
|
||||
outputHelper.WriteLine($"{Environment.NewLine}{prefix}{message}.{Environment.NewLine}");
|
||||
|
||||
throw new ArgumentException(message);
|
||||
throw new ArgumentException($"{variableName} is null, empty, or whitespace.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue