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

Issue when using .gta_settings_helper file #306

Closed
rolivav opened this issue Dec 3, 2019 · 10 comments
Closed

Issue when using .gta_settings_helper file #306

rolivav opened this issue Dec 3, 2019 · 10 comments
Assignees
Labels

Comments

@rolivav
Copy link

rolivav commented Dec 3, 2019

I followed your docs to add a post build event to automatically create a .gta_settings_helper file. That works fine.
What I wanted it for was to change the working directory to the one in the project, of course. So I added ::GTA::WorkingDirectory=$(LocalDebuggerWorkingDirectory) to the end. The result is:

echo SolutionPath=$(SolutionPath)::GTA::SolutionDir=$(SolutionDir)::GTA::PlatformName=$(PlatformName)::GTA::ConfigurationName=$(ConfigurationName)::GTA::TheTarget=$(TargetFileName)::GTA::WorkingDirectory=$(LocalDebuggerWorkingDirectory) > $(TargetPath).gta_settings_helper

When I put in the Google Test Adapter settings to use this $(WorkingDirectory), the tests don't run. It seems it just crashes. Am I doing anything wrong? This is the error I get:
The following warnings and errors occured during test discovery (enable debug mode for more information): Option 'Working directory': Apparently, the following placeholders could not be replaced. $(WorkingDirectory)
Not really helpful. Maybe LocalDebuggerWorkingDirectory is the wrong one to use? Nope, just checked the file and it is correct.

Thanks for the help.

@csoltenborn
Copy link
Owner

I just tried to reproduce your problem, but it seems to work fine for me. I checked it using your echo statement, changing the project settings of the HelperFileTests project to <AdditionalTestExecutionParam>-TheTarget=$(TheTarget) -TheDir=$(WorkingDirectory)</AdditionalTestExecutionParam> (in SampleTests.gta.runsettings), and then by placing a breakpoint at the project's main method and looking at the parameters passed to the exeutable: The $(WorkingDirectory) placeholder is resolved just fine in that case.

Is it possible that you are trying to make use of the placeholder outside of project settings? It will only work at the project settings level, but not at the solution settings or global settings level. Hint: Set Output mode setting to Verbose to see the final settings used for your projects after all settings levels are merged.

@csoltenborn
Copy link
Owner

I just double-checked with the Working Dir setting, and apparently there's indeed a problem (but you haven't (yet) run into that one :-) )

Let me know whether the above hints help in your case, or whether you now run into different error messages...

@rolivav
Copy link
Author

rolivav commented Dec 5, 2019

Hi, thanks for taking a look at this :)
Indeed I think you are right, I was setting it in the "Options" menu that I guess is the Global Settings (I am using VS2019). I am unsure where to put the placeholder now :/ I can't find a "Google Test Adapter" section in the project settings.
From your answer I think I probably need a .gta.runsettings file to use the settings helper file. Is that right?

@rolivav
Copy link
Author

rolivav commented Dec 5, 2019

I see there is a "WorkingDir" in the "Solution Settings" in the .gta.runsettings file, is that the one that you say I can use in "Project Settings" and that there is a problem with it?

@csoltenborn
Copy link
Owner

Have a look at the docs ;-)

Project settings are the sections of the .gta.runsettings file having a ProjectRegex. The helper files are project specific, and thus, the placeholders defined in that way can only be used on the project settings level. See the sample solution for a working setup of helper files...

Concerning the problem I ran into: I will soon have a closer look at this. Stay tuned...

@csoltenborn
Copy link
Owner

Ok, I have a workaround for you: make sure that WorkingDirectory is not the last property in your helper file. The reason is that the line break following the line containing the resolved properties is currently contained in the last property`s value, which does not work with the WorkingDir setting.

For instance, this should work (in case you do not make use of the $(TheTarget) placeholder):

echo SolutionPath=$(SolutionPath)::GTA::SolutionDir=$(SolutionDir)::GTA::PlatformName=$(PlatformName)::GTA::ConfigurationName=$(ConfigurationName)::GTA::WorkingDirectory=$(LocalDebuggerWorkingDirectory)::GTA::TheTarget=$(TargetFileName) > $(TargetPath).gta_settings_helper

Bugfix will be released in the not too far future.

@rolivav
Copy link
Author

rolivav commented Dec 9, 2019

Amazing, thanks for the great support! Will try that right away.

@rolivav
Copy link
Author

rolivav commented Dec 9, 2019

Alright, I still didn't get it to work 👎 . This is what I've done so far.
The file now is generated with the workaround on the post event and I added a .gta.runsettings file. In theory I only need it to explicitly set the <WorkingDir/> there with the regex for the tests projects.

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
	<GoogleTestAdapterSettings>
		<ProjectSettings>
			<Settings ProjectRegex=".*_tests.exe">
				<WorkingDir>$(WorkingDirectory)</WorkingDir>
			</Settings>
		</ProjectSettings>
	</GoogleTestAdapterSettings>
</RunSettings>

I don't know if this file is supposed to be picked up by default, in any case I selected it in the Test Explorer window manually. I also found the "verbose" output option, it did not print the result of the merging of the settings. What actually did it was the Test>Logging>Logging level set to "Diagnostic".

Anyway it does not find the settings file I think. This is the result:

 <RunSettings>
  <RunConfiguration>
    <ResultsDirectory>C:\Repositories\editor\projects\win32_debug\TestResults</ResultsDirectory>
    <SolutionDirectory>C:\Repositories\editor\projects\win32_debug\</SolutionDirectory>
    <TargetPlatform>X64</TargetPlatform>
    <CollectSourceInformation>True</CollectSourceInformation>
  </RunConfiguration>
  <GoogleTestAdapterSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <SolutionSettings>
      <Settings>
        <PrintTestOutput>false</PrintTestOutput>
        <TestDiscoveryRegex>.*tests.exe</TestDiscoveryRegex>
        <AdditionalPdbs />
        <TestDiscoveryTimeoutInSeconds>30</TestDiscoveryTimeoutInSeconds>
        <WorkingDir>$(ExecutableDir)</WorkingDir>
        <PathExtension />
        <CatchExceptions>true</CatchExceptions>
        <BreakOnFailure>false</BreakOnFailure>
        <RunDisabledTests>false</RunDisabledTests>
        <NrOfTestRepetitions>1</NrOfTestRepetitions>
        <ShuffleTests>false</ShuffleTests>
        <ShuffleTestsSeed>0</ShuffleTestsSeed>
        <TraitsRegexesBefore />
        <TraitsRegexesAfter />
        <TestNameSeparator />
        <OutputMode>Verbose</OutputMode>
        <TimestampMode>Automatic</TimestampMode>
        <SeverityMode>Automatic</SeverityMode>
        <SummaryMode>WarningOrError</SummaryMode>
        <PrefixOutputWithGta>false</PrefixOutputWithGta>
        <ParseSymbolInformation>true</ParseSymbolInformation>
        <AdditionalTestExecutionParam />
        <ParallelTestExecution>false</ParallelTestExecution>
        <MaxNrOfThreads>0</MaxNrOfThreads>
        <BatchForTestSetup />
        <BatchForTestTeardown />
        <KillProcessesOnCancel>false</KillProcessesOnCancel>
        <SkipOriginCheck>false</SkipOriginCheck>
        <ExitCodeTestCase />
        <MissingTestsReportMode>ReportAsNotFound</MissingTestsReportMode>
        <DebuggerKind>Native</DebuggerKind>
        <DebuggingNamedPipeId>d13dcc2e-5acd-4d1f-aef9-13f43d71f134</DebuggingNamedPipeId>
        <SolutionDir>C:\Repositories\editor\projects\win32_debug</SolutionDir>
      </Settings>
    </SolutionSettings>
    <ProjectSettings />
  </GoogleTestAdapterSettings>
</RunSettings>.

And it explicitly says that it could not find any ProjectSettings.

[09/12/2019 11:16:02.166  Informational] No settings configured for test executable 'C:\Repositories\editor\projects\win32_debug\build\editor-widgets_tests.exe'; running with solution settings

So the .gta.runsettings doesn't seem to be picked up. Am I still doing something wrong? 😃

There is a particularity in this solution, the name of the solution has a space in it. The name is something like Project Editor.sln (sorry for the weird censoring). Not sure if this might be an issue, I had problems with spaces in file names in the past, maybe it doesn't pick it up for that reason. I have no other clue what could be going on.

@csoltenborn
Copy link
Owner

csoltenborn commented Dec 10, 2019

The RunSettings you posted clearly show that your solution settings file is not picked up by GTA for some reason, since it does not contain any ´ProjectSettings` node. I have attached the RunSettings resulting from the SampleTests solution as an example (RunSettings.txt - compare it to the solution's settings file to see that it reflects the exact structure). (edit: I had overread the not in your "does not find" statement for some reason ;-) - that's why I pointed this out).

I also just tried to rename the SampleTests solution as Sample Tests.sln (and of course also renamed SampleTests.gta.runsettings to Sample Tests.gta.runsettings). This worked just fine, so I think that the space contained in your solution name is not the issue.

I'm kind of lost at the moment. Any chance that you you can provide your solution? Feel free to remove everything unnecessary - just make sure that it builds out of the box, and that it contains at least one test. I will then have a closer look...

@csoltenborn
Copy link
Owner

Closed due to inactivity - feel free to reopen...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants