Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSOE-98: Save per-page screenshots to files directly to conserve memory #152

Merged
merged 12 commits into from
Apr 8, 2022
5 changes: 3 additions & 2 deletions Lombiq.Tests.UI/Constants/DirectoryPaths.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Linq;

namespace Lombiq.Tests.UI.Constants;

Expand All @@ -9,8 +10,8 @@ public static class DirectoryPaths
public const string Temp = nameof(Temp);
public const string Screenshots = nameof(Screenshots);

public static string GetTempSubDirectoryPath(string contextId, string subDirectoryName) =>
Path.Combine(Environment.CurrentDirectory, Temp, contextId, subDirectoryName);
public static string GetTempSubDirectoryPath(string contextId, params string[] subDirectoryNames) =>
Path.Combine(new[] { Environment.CurrentDirectory, Temp, contextId }.Union(subDirectoryNames).ToArray());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.Union() is a set operator. Only use it if you want to treat your collection as a set. In this case use .Concat().
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right.


public static string GetScreenshotsDirectoryPath(string contextId) =>
GetTempSubDirectoryPath(contextId, Screenshots);
Expand Down
4 changes: 2 additions & 2 deletions Lombiq.Tests.UI/Services/UITestExecutionSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private async ValueTask ShutdownAsync()
{
_context.Scope?.Dispose();

DirectoryHelper.SafelyDeleteDirectoryIfExists(DirectoryPaths.GetTempSubDirectoryPath(_context.Id, string.Empty));
DirectoryHelper.SafelyDeleteDirectoryIfExists(DirectoryPaths.GetTempSubDirectoryPath(_context.Id));
}

_sqlServerManager?.Dispose();
Expand Down Expand Up @@ -504,7 +504,7 @@ private async Task<UITestContext> CreateContextAsync()
{
var contextId = Guid.NewGuid().ToString();

FileSystemHelper.EnsureDirectoryExists(DirectoryPaths.GetTempSubDirectoryPath(contextId, string.Empty));
FileSystemHelper.EnsureDirectoryExists(DirectoryPaths.GetTempSubDirectoryPath(contextId));

SqlServerRunningContext sqlServerContext = null;
AzureBlobStorageRunningContext azureBlobStorageContext = null;
Expand Down