2023-07-18 13:32:26 -05:00
|
|
|
|
// Licensed to the .NET Foundation under one or more agreements.
|
|
|
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
|
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using Xunit.Abstractions;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.SourceBuild.SmokeTests
|
|
|
|
|
{
|
2023-10-12 09:28:42 -05:00
|
|
|
|
public class PoisonTests : SdkTests
|
2023-07-18 13:32:26 -05:00
|
|
|
|
{
|
|
|
|
|
public PoisonTests(ITestOutputHelper outputHelper) : base(outputHelper) { }
|
|
|
|
|
|
2023-08-28 20:02:11 +05:30
|
|
|
|
[SkippableFact(Config.PoisonReportPathEnv, skipOnNullOrWhiteSpaceEnv: true)]
|
2023-07-18 13:32:26 -05:00
|
|
|
|
public void VerifyUsage()
|
|
|
|
|
{
|
|
|
|
|
if (!File.Exists(Config.PoisonReportPath))
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException($"Poison report '{Config.PoisonReportPath}' does not exist.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string currentPoisonReport = File.ReadAllText(Config.PoisonReportPath);
|
|
|
|
|
currentPoisonReport = RemoveHashes(currentPoisonReport);
|
|
|
|
|
currentPoisonReport = BaselineHelper.RemoveRids(currentPoisonReport);
|
|
|
|
|
currentPoisonReport = BaselineHelper.RemoveRids(currentPoisonReport, true);
|
|
|
|
|
currentPoisonReport = BaselineHelper.RemoveVersions(currentPoisonReport);
|
|
|
|
|
|
2023-07-28 09:48:27 -05:00
|
|
|
|
BaselineHelper.CompareBaselineContents("PoisonUsage.txt", currentPoisonReport, OutputHelper);
|
2023-07-18 13:32:26 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static string RemoveHashes(string source) => Regex.Replace(source, "^\\s*<Hash>.*</Hash>(\r\n?|\n)", string.Empty, RegexOptions.Multiline);
|
|
|
|
|
}
|
|
|
|
|
}
|