dsccommunity / DscResource.Test

Module to test your Projects against the HQRM guidelines
MIT License
5 stars 8 forks source link

Should expand relative paths in Pester path properties #121

Open johlju opened 2 years ago

johlju commented 2 years ago

If the property OutputPath is used in the build.yaml with a relative path (to the project path), it will not be made an absolute path by the task, meaning in this case, the test result file end up in the wrong place.

DscTest:
  Pester:
    Configuration:
      TestResult:
        OutputPath: ./output/testResults/NUnitXml_HQRM_Tests.xml

The variable $DscTestOutputFolder is set to the absolute path of the projects './output/testResults' folder here:

https://github.com/dsccommunity/DscResource.Test/blob/27c70ec121b41eff95f17747f0dc2176f89cdfa8/source/tasks/Invoke_HQRM_Tests.build.ps1#L90-L93

So here for each property that is a path, e.g. OutputPath, should be checked whether it is an absolute path. If not, join the relative path with the path in the variable above.

https://github.com/dsccommunity/DscResource.Test/blob/27c70ec121b41eff95f17747f0dc2176f89cdfa8/source/tasks/Invoke_HQRM_Tests.build.ps1#L240

gaelcolas commented 2 years ago

To expand the path as needed, we could use Get-SamplerAbsolutePath. Either copy the code or add dependency.

johlju commented 2 years ago

Get-SamplerAbsolutePath is a public function in Sampler so we can just use that. Maybe we should add Sampler to RequiredModules too: https://github.com/dsccommunity/DscResource.Test/blob/73d6c3290572a0b065084a1adcaa1eb5a8da5994/source/DscResource.Test.psd1#L46