Skip to content

Commit

Permalink
Skyline: Fixed broken TestPerf tutorial audit log names (#3320)
Browse files Browse the repository at this point in the history
- Added test mode that very quickly checks audit logs are named correctly
  • Loading branch information
brendanx67 authored Jan 5, 2025
1 parent 639d03e commit aa14e94
Show file tree
Hide file tree
Showing 36 changed files with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions pwiz_tools/Skyline/TestUtil/TestFunctional.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,8 @@ public bool IsRecordAuditLogForTutorials
get { return IsTutorial && RecordAuditLogs; }
}

public bool IsTestAuditLogPlacement => false;

public static bool IsShowMatchingTutorialPages { get; set; }

public static bool IsDemoMode { get { return Program.DemoMode; } }
Expand Down Expand Up @@ -1963,6 +1965,12 @@ protected void RunFunctionalTest(string defaultUiMode = UiModes.PROTEOMIC)
{
return; // Don't want to run this lengthy test right now
}
if (IsTestAuditLogPlacement)
{
// Just testing if audit logs are where they are expected to be
AssertAuditLogCorrectlyPlaced();
return;
}

RunFunctionalTestAttempt(defaultUiMode);

Expand Down Expand Up @@ -2174,16 +2182,14 @@ private void VerifyAuditLogCorrect()
return;

// Ensure expected tutorial log file exists unless recording
var projectFile = GetLogFilePath(AuditLogTutorialDir);
bool existsInProject = File.Exists(projectFile);
if (!IsRecordAuditLogForTutorials)
{
Assert.IsTrue(existsInProject,
"Log file for test \"{0}\" does not exist at \"{1}\", set IsRecordAuditLogForTutorials=true to create it",
TestContext.TestName, projectFile);
AssertProjectLogFileExists();
}

// Compare file contents
var projectFile = GetLogFilePath(AuditLogTutorialDir);
bool existsInProject = File.Exists(projectFile);
var expected = existsInProject ? ReadTextWithNormalizedLineEndings(projectFile) : string.Empty;
var actual = ReadTextWithNormalizedLineEndings(recordedFile);
if (AreEquivalentAuditLogs(expected, actual))
Expand Down Expand Up @@ -2233,6 +2239,28 @@ private void VerifyAuditLogCorrect()
}
}

private void AssertAuditLogCorrectlyPlaced()
{
if (AuditLogCompareLogs)
{
AssertProjectLogFileExists();

Console.Write(@" found audit log ");
}
else
{
Console.Write(@" no audit log comparison ");
}
}

private void AssertProjectLogFileExists()
{
var projectFile = GetLogFilePath(AuditLogTutorialDir);
Assert.IsTrue(File.Exists(projectFile),
"Log file for test \"{0}\" does not exist at \"{1}\", set IsRecordAuditLogForTutorials=true to create it",
TestContext.TestName, projectFile);
}

private static bool AreEquivalentAuditLogs(string expected, string actual)
{
try
Expand Down

0 comments on commit aa14e94

Please sign in to comment.