Skip to content

Commit

Permalink
support the gdUnitMono tests
Browse files Browse the repository at this point in the history
  • Loading branch information
van800 committed Mar 11, 2024
1 parent 74258c0 commit 67ea232
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
28 changes: 28 additions & 0 deletions resharper/src/UnitTesting/GodotGdUnitTestRunnerHost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using JetBrains.Annotations;
using JetBrains.Collections.Viewable;
using JetBrains.ReSharper.Feature.Services.Protocol;
using JetBrains.ReSharper.UnitTestFramework.Execution.TestRunner;
using JetBrains.Rider.Model.Godot.FrontendBackend;
using JetBrains.Util;

namespace JetBrains.ReSharper.Plugins.Godot.UnitTesting
{
public class GodotGdUnitTestRunnerHost : DefaultTestRunnerHost
{
[NotNull] public new static readonly ITestRunnerHost Instance = new GodotGdUnitTestRunnerHost();
private const string godotPathEnvVarName = "GODOT_BIN";

public override IPreparedProcess StartProcess(ProcessStartInfo startInfo, ITestRunnerContext context)
{
var solution = context.RuntimeEnvironment.Project.GetSolution();
var model = solution.GetProtocolSolution().GetGodotFrontendBackendModel();
if (model.GodotPath.HasValue())
startInfo.EnvironmentVariables.Add(godotPathEnvVarName, model.GodotPath.Value);

return base.StartProcess(startInfo, context);
}
}
}
5 changes: 5 additions & 0 deletions resharper/src/UnitTesting/GodotTestRunnerHostProvider.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using JetBrains.ProjectModel;
using JetBrains.ProjectModel.Impl;
using JetBrains.ReSharper.Feature.Services.Protocol;
Expand All @@ -18,6 +19,10 @@ public GodotTestRunnerHostProvider(ISolution solution)

public ITestRunnerHost TryGetHost(IProject project, TargetFrameworkId targetFrameworkId)
{
if (!(project.ProjectProperties.DotNetCorePlatform?.Sdk != null &&
project.ProjectProperties.DotNetCorePlatform.Sdk.StartsWith("Godot.NET.SDK", StringComparison.OrdinalIgnoreCase)))
return null;
if (project.GetModuleReference("gdUnit4Api") != null) return GodotGdUnitTestRunnerHost.Instance;
var assemblyNameVersion = (project.GetModuleReference("GodotSharp") as ProjectToAssemblyReference)?.ReferenceTarget.AssemblyName.Version;
if (assemblyNameVersion != null && project.IsGodotProject() && assemblyNameVersion.Major >= 4) return GodotCoreTestRunnerHost.Instance;
return project.IsGodotProject() ? GodotTestRunnerHost.Instance : null;
Expand Down

0 comments on commit 67ea232

Please sign in to comment.