From 89e051a18e9158ea6788f2634921145e69611828 Mon Sep 17 00:00:00 2001 From: Nullpointer Date: Wed, 17 Apr 2024 12:49:08 +0200 Subject: [PATCH] GD-86: Fixes space in folder name prevents tests from running (#88) # Why https://github.com/MikeSchulze/gdUnit4Net/issues/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 --- PackageVersions.props | 2 ++ api/gdUnit4Api.csproj | 4 ++-- example/exampleProject.csproj | 2 +- testadapter/gdUnit4TestAdapter.csproj | 4 ++-- testadapter/src/execution/TestExecutor.cs | 14 ++++++++++---- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/PackageVersions.props b/PackageVersions.props index 949a9169..4fcdc61a 100644 --- a/PackageVersions.props +++ b/PackageVersions.props @@ -5,5 +5,7 @@ 17.9.0 4.9.2 4.18.4 + 4.2.3 + 1.1.1 diff --git a/api/gdUnit4Api.csproj b/api/gdUnit4Api.csproj index 90130ee2..271e8516 100644 --- a/api/gdUnit4Api.csproj +++ b/api/gdUnit4Api.csproj @@ -4,7 +4,7 @@ gdUnit4Api - 4.2.3 + $(GdUnitAPIVersion) GdUnit4 API is the C# extention to enable GdUnit4 to run/write unit tests in C#. @@ -34,7 +34,7 @@ true https://github.com/MikeSchulze/gdUnit4Net gdUnit4.api - 4.2.3 + $(GdUnitAPIVersion) LICENSE README.md GdUnit4 API release candidate. diff --git a/example/exampleProject.csproj b/example/exampleProject.csproj index 85d9ca72..6e5d514f 100644 --- a/example/exampleProject.csproj +++ b/example/exampleProject.csproj @@ -18,6 +18,6 @@ - + diff --git a/testadapter/gdUnit4TestAdapter.csproj b/testadapter/gdUnit4TestAdapter.csproj index 12f34ea5..851c1fba 100644 --- a/testadapter/gdUnit4TestAdapter.csproj +++ b/testadapter/gdUnit4TestAdapter.csproj @@ -4,7 +4,7 @@ gdUnit4TestAdapter - 1.1.0 + $(GdUnitTestAdapterVersion) GdUnit4 Test Adapter is the test adapter to run GdUnit4 tests in C#. @@ -33,7 +33,7 @@ true https://github.com/MikeSchulze/gdUnit4Net gdUnit4.test.adapter - 1.1.0 + $(GdUnitTestAdapterVersion) LICENSE README.md GdUnit4 Test Adapter beta. diff --git a/testadapter/src/execution/TestExecutor.cs b/testadapter/src/execution/TestExecutor.cs index c1d2dd11..67b5e858 100644 --- a/testadapter/src/execution/TestExecutor.cs +++ b/testadapter/src/execution/TestExecutor.cs @@ -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" : ""; @@ -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, @@ -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,