Skip to content

Commit

Permalink
Add support for predefining tests and using them in uet test (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
hach-que authored Nov 23, 2024
1 parent e0ddcdf commit 10d69ab
Show file tree
Hide file tree
Showing 20 changed files with 728 additions and 253 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public CustomPluginTestProvider(

public IRuntimeJson DynamicSettings { get; } = new TestProviderRuntimeJson(TestProviderSourceGenerationContext.WithStringEnum).BuildConfigPluginTestCustom;


public async Task WriteBuildGraphNodesAsync(
IBuildGraphEmitContext context,
XmlWriter writer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public async void CanGenerateBuildGraphForPlugin()
{ $"Allow2019", $"false" },
{ $"EnginePrefix", $"Unreal" },
{ $"ExecutePackage", $"false" },
{ $"ExecuteZip", $"false" },
{ $"VersionNumber", $"10000" },
{ $"VersionName", $"2023.05.17" },
{ $"PackageName", $"Packaged" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public async Task TestPluginTests()
await writer.WriteBuildGraphNodeInclude(
memory,
false,
new BuildConfigPlugin(),
new BuildConfigPluginDistribution
{
Name = "Test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

<!-- Package options -->
<Option Name="ExecutePackage" Restrict="true|false" DefaultValue="true" Description="If false, the default Create Package and Zip Plugin steps are not run" />
<Option Name="ExecuteZip" Restrict="true|false" DefaultValue="true" Description="If false, the Create Package step will not generate a .zip file" />
<Option Name="VersionNumber" Restrict="[0-9]+" DefaultValue="10000" Description="The version number to embed in the packaged .uplugin file" />
<Option Name="VersionName" Restrict="[^ ]+" DefaultValue="Unversioned" Description="The version name to embed in the packaged .uplugin file" />
<Option Name="PackageFolder" Restrict="[^ ]+" DefaultValue="Packaged" Description="The folder to place the packaged plugin in" />
Expand Down Expand Up @@ -606,7 +607,9 @@ $(PackageExclude);
OutputTag="#PackagedPlugin"
If="'$(ExecutePackage)' == 'true'"
/>
<Agent Name="Zip Plugin (Create Final Package)" Type="Win64">
<Property Name="PackageTasks" Value="$(PackageTasks)#PackagedPlugin;" />

<Agent Name="Zip Plugin (Create Final Package)" Type="Win64" If="'$(ExecuteZip)' == 'true'">
<Node Name="Zip Plugin" Requires="#PackagedPlugin" Produces="#PackagedZip">
<Delete Files="$(ProjectRoot)/$(PluginName)-$(Distribution)-$(VersionName).zip" />
<Zip
Expand All @@ -617,7 +620,7 @@ $(PackageExclude);
/>
</Node>
</Agent>
<Property Name="PackageTasks" Value="$(PackageTasks)#PackagedZip;#PackagedPlugin;" />
<Property Name="PackageTasks" Value="$(PackageTasks)#PackagedZip;" If="'$(ExecuteZip)' == 'true'" />
</Do>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,41 @@ private static async Task WriteBuildGraphNodesAsync<TDistribution, TBaseClass>(
XmlWriter writer,
TDistribution buildConfigDistribution,
IDynamicProvider<TDistribution, TBaseClass>[] providers,
BuildConfigDynamic<TDistribution, TBaseClass>[] dynamicSettings)
BuildConfigDynamic<TDistribution, TBaseClass>[] dynamicSettings,
BuildConfigDynamic<TDistribution, TBaseClass>[] predefinedDynamicSettings)
{
foreach (var byType in dynamicSettings.GroupBy(x => x.Type))
var predefinedDynamicSettingsLookup = predefinedDynamicSettings == null
? new Dictionary<string, BuildConfigDynamic<TDistribution, TBaseClass>>()
: predefinedDynamicSettings.ToDictionary(k => k.Name, v => v);

var resolvedDynamicSettings = new List<BuildConfigDynamic<TDistribution, TBaseClass>>();
foreach (var dynamicSetting in dynamicSettings)
{
if (dynamicSetting.Type == BuildConfigConstants.Predefined)
{
if (dynamicSetting.DynamicSettings is string predefinedName)
{
if (predefinedDynamicSettingsLookup.TryGetValue(predefinedName, out var resolvedDynamicSetting))
{
resolvedDynamicSettings.Add(resolvedDynamicSetting);
}
else
{
throw new InvalidOperationException($"Entry '{dynamicSetting.Name}' refers to predefined entry by name '{predefinedName}', but no such predefined entry is available.");
}
}
else
{
throw new InvalidOperationException($"Entry '{dynamicSetting.Name}' has invalid 'Predefined' value; it should be a string value.");
}
}
else
{
resolvedDynamicSettings.Add(dynamicSetting);
}
}

foreach (var byType in resolvedDynamicSettings.GroupBy(x => x.Type))
{
var provider = providers.First(x => x.Type == byType.Key);
await provider.WriteBuildGraphNodesAsync(
Expand All @@ -96,6 +128,7 @@ await provider.WriteBuildGraphNodesAsync(
public async Task WriteBuildGraphNodeInclude(
Stream stream,
bool filterHostToCurrentPlatformOnly,
object buildConfig,
object buildConfigDistribution,
bool executeTests,
bool executeDeployment)
Expand Down Expand Up @@ -124,7 +157,10 @@ await WriteBuildGraphNodesAsync(
writer,
pluginDistribution,
_pluginTests,
pluginDistribution.Tests).ConfigureAwait(false);
pluginDistribution.Tests,
buildConfig is BuildConfigPlugin buildConfigPlugin && buildConfigPlugin.Tests != null
? buildConfigPlugin.Tests
: []).ConfigureAwait(false);
}

if (pluginDistribution.Deployment != null && executeDeployment)
Expand All @@ -134,7 +170,8 @@ await WriteBuildGraphNodesAsync(
writer,
pluginDistribution,
_pluginDeployments,
pluginDistribution.Deployment).ConfigureAwait(false);
pluginDistribution.Deployment,
[]).ConfigureAwait(false);
}
}
else if (buildConfigDistribution is BuildConfigProjectDistribution projectDistribution)
Expand All @@ -146,7 +183,8 @@ await WriteBuildGraphNodesAsync(
writer,
projectDistribution,
_projectTests,
projectDistribution.Tests).ConfigureAwait(false);
projectDistribution.Tests,
[]).ConfigureAwait(false);
}

if (projectDistribution.Deployment != null && executeDeployment)
Expand All @@ -156,7 +194,8 @@ await WriteBuildGraphNodesAsync(
writer,
projectDistribution,
_projectDeployments,
projectDistribution.Deployment).ConfigureAwait(false);
projectDistribution.Deployment,
[]).ConfigureAwait(false);
}
}
else
Expand All @@ -172,6 +211,7 @@ await WriteBuildGraphNodesAsync(
public async Task WriteBuildGraphMacroInclude(
Stream stream,
bool filterHostToCurrentPlatformOnly,
object buildConfig,
object buildConfigDistribution)
{
var emitContext = new BuildGraphEmitContext(
Expand All @@ -198,7 +238,8 @@ await WriteBuildGraphNodesAsync(
writer,
pluginDistribution,
_pluginPrepare,
pluginDistribution.Prepare).ConfigureAwait(false);
pluginDistribution.Prepare,
[]).ConfigureAwait(false);
}
}
else if (buildConfigDistribution is BuildConfigProjectDistribution projectDistribution)
Expand All @@ -210,7 +251,8 @@ await WriteBuildGraphNodesAsync(
writer,
projectDistribution,
_projectPrepare,
projectDistribution.Prepare).ConfigureAwait(false);
projectDistribution.Prepare,
[]).ConfigureAwait(false);
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ public interface IDynamicBuildGraphIncludeWriter
Task WriteBuildGraphNodeInclude(
Stream stream,
bool filterHostToCurrentPlatformOnly,
object buildConfig,
object buildConfigDistribution,
bool executeTests,
bool executeDeployment);

Task WriteBuildGraphMacroInclude(
Stream stream,
bool filterHostToCurrentPlatformOnly,
object buildConfig,
object buildConfigDistribution);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public static BuildConfigSourceGenerationContext Create(
new BuildConfigTestConverter<BuildConfigProjectDistribution>(serviceProvider),
new BuildConfigDeploymentConverter<BuildConfigPluginDistribution>(serviceProvider),
new BuildConfigDeploymentConverter<BuildConfigProjectDistribution>(serviceProvider),
new BuildConfigTestPredefinedConverter<BuildConfigPluginDistribution>(serviceProvider),
new BuildConfigTargetPlatformConverter(),
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class BuildConfigDynamic<TDistribution, TBaseClass>
/// <summary>
/// If set, this will be emitted as a manual job on build servers. Only applies to deployments. Defaults to false.
/// </summary>
[JsonPropertyName("Manual")]
public bool? Manual { get; set; }

/// <summary>
Expand Down
Loading

0 comments on commit 10d69ab

Please sign in to comment.