Skip to content

Commit

Permalink
* fixed modified PersistentFilesDir check when IsExtractHere is true
Browse files Browse the repository at this point in the history
* fixed PerfDetectLockmassFunctionTest.cs to delete the lmgt.inf file after running
  • Loading branch information
chambm committed Aug 15, 2024
1 parent fb4ec9f commit badafb1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions pwiz_tools/Skyline/TestPerf/PerfDetectLockmassFunctionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
*/


using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using pwiz.ProteowizardWrapper;
using pwiz.Skyline.Util;
using pwiz.SkylineTestUtil;

namespace TestPerf // Note: tests in the "TestPerf" namespace only run when the global RunPerfTests flag is set
Expand Down Expand Up @@ -70,6 +72,10 @@ protected override void DoTest()
var document = WaitForDocumentLoaded(400000);

// If we get here, problem is solved

// delete lockmass file
var lmgtFile = Path.Combine(GetTestPath(TestFilesPersistent[0]), "lmgt.inf");
FileEx.SafeDelete(lmgtFile);
}
}
}
9 changes: 7 additions & 2 deletions pwiz_tools/Skyline/TestUtil/TestFilesDir.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@ public TestFilesDir(TestContext testContext, string relativePathZip, string dire
}
// where to place persistent (usually large, expensive to extract) files if any
PersistentFiles = persistentFiles;
IsExtractHere = isExtractHere;
if (PersistentFiles != null)
PersistentFilesDir = GetExtractDir(Path.GetDirectoryName(relativePathZip), zipBaseName, isExtractHere);

TestContext.ExtractTestFiles(relativePathZip, FullPath, PersistentFiles, PersistentFilesDir);

// record the size of the persistent directory after extracting
var persistentDirInfo = string.IsNullOrEmpty(PersistentFilesDir) ? null : new DirectoryInfo(PersistentFilesDir);
var targetDir = isExtractHere ? Path.Combine(PersistentFilesDir ?? "", directoryName) : PersistentFilesDir;
var persistentDirInfo = string.IsNullOrEmpty(PersistentFilesDir) ? null : new DirectoryInfo(targetDir);
if (persistentDirInfo != null && Directory.Exists(PersistentFilesDir))
{
var persistentFileInfos = persistentDirInfo.EnumerateFiles("*", SearchOption.AllDirectories).ToList();
Expand All @@ -121,6 +123,7 @@ private static string GetExtractDir(string directoryName, string zipBaseName, bo
public string PersistentFilesDir { get; private set; }

public string[] PersistentFiles { get; private set; }
private bool IsExtractHere { get; }

/// <summary>
/// The sum of all file sizes in the persistent files dir after extracting the ZIP.
Expand Down Expand Up @@ -292,10 +295,12 @@ private void CheckForModifiedPersistentFilesDir()
GC.WaitForPendingFinalizers();
GC.Collect();

var lastDirectoryName = Path.GetFileName(FullPath) ?? "";
var targetDir = IsExtractHere ? Path.Combine(PersistentFilesDir ?? "", lastDirectoryName) : PersistentFilesDir;
List<FileInfo> currentFileInfos;
try
{
var persistentDirInfo = new DirectoryInfo(PersistentFilesDir);
var persistentDirInfo = new DirectoryInfo(targetDir);
currentFileInfos = persistentDirInfo.EnumerateFiles("*", SearchOption.AllDirectories).ToList();
}
catch (Exception ex)
Expand Down

0 comments on commit badafb1

Please sign in to comment.