Skip to content

Commit

Permalink
GD-86: Fixes space in folder name prevents tests from running (#88)
Browse files Browse the repository at this point in the history
# Why
#86

# What
* fixed the arguments that include paths by surrounding by quotes.
* set working directory to project path
* use current working directory to set the `--path .` argument
* introduce package version properties to centralize the API versions
* bump adapter version to v1.1.1
  • Loading branch information
MikeSchulze authored Apr 17, 2024
1 parent a311bb3 commit 89e051a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
2 changes: 2 additions & 0 deletions PackageVersions.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
<MicrosoftSdkVersion>17.9.0</MicrosoftSdkVersion>
<MicrosoftCodeAnalysisCSharpVersion>4.9.2</MicrosoftCodeAnalysisCSharpVersion>
<MoqVersion>4.18.4</MoqVersion>
<GdUnitAPIVersion>4.2.3</GdUnitAPIVersion>
<GdUnitTestAdapterVersion>1.1.1</GdUnitTestAdapterVersion>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions api/gdUnit4Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<PropertyGroup>
<Title>gdUnit4Api</Title>
<Version>4.2.3</Version>
<Version>$(GdUnitAPIVersion)</Version>
<Description>
GdUnit4 API is the C# extention to enable GdUnit4 to run/write unit tests in C#.
</Description>
Expand Down Expand Up @@ -34,7 +34,7 @@
<IsPackable>true</IsPackable>
<PackageProjectUrl>https://github.com/MikeSchulze/gdUnit4Net</PackageProjectUrl>
<PackageId>gdUnit4.api</PackageId>
<PackageVersion>4.2.3</PackageVersion>
<PackageVersion>$(GdUnitAPIVersion)</PackageVersion>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReleaseNotes>GdUnit4 API release candidate.</PackageReleaseNotes>
Expand Down
2 changes: 1 addition & 1 deletion example/exampleProject.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftSdkVersion)" />
<PackageReference Include="gdUnit4.api" Version="4.2.*" />
<PackageReference Include="gdUnit4.test.adapter" Version="1.*-*" />
<PackageReference Include="gdUnit4.test.adapter" Version="1.*" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions testadapter/gdUnit4TestAdapter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<PropertyGroup>
<Title>gdUnit4TestAdapter</Title>
<Version>1.1.0</Version>
<Version>$(GdUnitTestAdapterVersion)</Version>
<Description>
GdUnit4 Test Adapter is the test adapter to run GdUnit4 tests in C#.
</Description>
Expand Down Expand Up @@ -33,7 +33,7 @@
<IsPackable>true</IsPackable>
<PackageProjectUrl>https://github.com/MikeSchulze/gdUnit4Net</PackageProjectUrl>
<PackageId>gdUnit4.test.adapter</PackageId>
<PackageVersion>1.1.0</PackageVersion>
<PackageVersion>$(GdUnitTestAdapterVersion)</PackageVersion>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReleaseNotes>GdUnit4 Test Adapter beta.</PackageReleaseNotes>
Expand Down
14 changes: 10 additions & 4 deletions testadapter/src/execution/TestExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ public void Run(IFrameworkHandle frameworkHandle, IRunContext runContext, IEnume

var workingDirectory = LookupGodotProjectPath(groupedTests.First().Key);
_ = workingDirectory ?? throw new InvalidOperationException($"Cannot determine the godot.project! The workingDirectory is not set");
InstallTestRunnerAndBuild(frameworkHandle, workingDirectory);

frameworkHandle.SendMessage(TestMessageLevel.Informational, @$"Run tests -------->");
if (Directory.Exists(workingDirectory))
{
Directory.SetCurrentDirectory(workingDirectory);
frameworkHandle.SendMessage(TestMessageLevel.Informational, "Current directory set to: " + Directory.GetCurrentDirectory());
}
InstallTestRunnerAndBuild(frameworkHandle, workingDirectory);
var configName = WriteTestRunnerConfig(groupedTests);
var debugArg = runContext.IsBeingDebugged ? "-d" : "";

Expand All @@ -62,7 +66,9 @@ public void Run(IFrameworkHandle frameworkHandle, IRunContext runContext, IEnume
// }) == false)
// : testCases;
var testRunnerScene = "res://gdunit4_testadapter/TestAdapterRunner.tscn";//Path.Combine(workingDirectory, @$"{temp_test_runner_dir}/TestRunner.tscn");
var processStartInfo = new ProcessStartInfo(@$"{GodotBin}", @$"{debugArg} --path {workingDirectory} {testRunnerScene} --testadapter --configfile='{configName}' {gdUnit4Settings.Parameters}")
var arguments = $"{debugArg} --path . {testRunnerScene} --testadapter --configfile=\"{configName}\" {gdUnit4Settings.Parameters}";
frameworkHandle.SendMessage(TestMessageLevel.Informational, @$"Run with args {arguments}");
var processStartInfo = new ProcessStartInfo(@$"{GodotBin}", arguments)
{
StandardOutputEncoding = Encoding.Default,
RedirectStandardOutput = true,
Expand Down Expand Up @@ -114,7 +120,7 @@ private void InstallTestRunnerAndBuild(IFrameworkHandle frameworkHandle, string
}
frameworkHandle.SendMessage(TestMessageLevel.Informational, "Install GdUnit4 TestRunner");
InstallTestRunnerClasses(destinationFolderPath);
var processStartInfo = new ProcessStartInfo(@$"{GodotBin}", @$"--path {workingDirectory} --headless --build-solutions --quit-after 20")
var processStartInfo = new ProcessStartInfo(@$"{GodotBin}", @$"--path . --headless --build-solutions --quit-after 20")
{
RedirectStandardOutput = false,
RedirectStandardError = false,
Expand Down

0 comments on commit 89e051a

Please sign in to comment.