Open KarstenHabay opened 3 months ago
I got a similar error when I did not made it a local git repo referencing LibGit2Sharp
. 🤔 Though this might be a separate bug.
Unhandled exception. System.IO.DirectoryNotFoundException: Cannot find the .git directory
at GitVersion.Git.GitRepositoryInfo.GetProjectRootDirectory() in /private/tmp/gitversion-20240722-7185-xp03bq/GitVersion-6.0.0/src/GitVersion.LibGit2Sharp/Git/GitRepositoryInfo.cs:line 88
Update: Tracking it in issue #482.
@KarstenHabay I can't reproduce the same error you got for the task BUILD MODULEOUTPUT MODULEBUILDER
. But I did have to run this to be able to get pass the git error I mentioned in the previous comment:
git init -b main
git add .
git commit -m 'First commmit'
I do have gitversion
installed too.
Can I send you a zip file with the full project? (should be around 500kb without the output folder) I can't seem to get around the problem 🙁 I made a supplemental folder 'Manual' in the test folder with just 1 Pester file which dot sourced the ps1 file. If I run that I get no errors, but that that gets around the whole point of using the Sampler module.
Van: Johan Ljunggren @.> Verzonden: zaterdag 27 juli 2024 23:18 Aan: gaelcolas/Sampler @.> CC: Karsten Habay @.>; Mention @.> Onderwerp: Re: [gaelcolas/Sampler] Pester Mocking seems to not working while running Sampler Build. Am I missing something? (Issue #481)
@KarstenHabayhttps://github.com/KarstenHabay I can't reproduce the same error you got for the task BUILD MODULEOUTPUT MODULEBUILDER. But I did have to run this to be able to get pass the git error I mentioned in the previous comment:
git init -b main git add . git commit -m 'First commmit'
— Reply to this email directly, view it on GitHubhttps://github.com/gaelcolas/Sampler/issues/481#issuecomment-2254256653, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARXXTLUXG422B3NKFVGPRDDZOQFA7AVCNFSM6AAAAABLQL2R2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJUGI2TMNRVGM. You are receiving this because you were mentioned.Message ID: @.***>
Can I send you a zip file with the full project?
Can you set up a public repo on Github that I can clone?
I made a supplemental folder 'Manual' in the test folder with just 1 Pester file which dot sourced the ps1 file. If I run that I get no errors, but that that gets around the whole point of using the Sampler module.
I'm confused what the problem you are having, I thought it was the unhandled exception in the task BUILD MODULEOUTPUT MODULEBUILDER
, but that is unrelated to testing - so now I'm confused. 🙂
Also, you have an error in your test script on line 5, it should be Import-Module -Name $script:ModuleName -Force
.
https://github.com/KarstenHabay/Parl.Utility
Also, you have an error in your test script on line 5, it should be
Import-Module -Name $script:ModuleName -Force
.
Not an error, $Module is a reference to the line before.
As you can see it's a new repo with all the code so far for this project.
I keep getting this error message:
Describing Show-ParlObjectUsingANSIColor
Name : TestObject
Value :
Count : 43
Status :
[-] Should display property names in green when they have values 25ms (21ms|4ms)
Expected Write-Host to be called 4 times exactly, but was called 0 times
at Should -Invoke Write-Host -Times 4 -Exactly, H:\PowerShell\Source\Parl.Utility\tests\Unit\Public\Show-ParlObjectUsingANSIColor.tests.ps1:36
at <ScriptBlock>, H:\PowerShell\Source\Parl.Utility\tests\Unit\Public\Show-ParlObjectUsingANSIColor.tests.ps1:36
Tests completed in 31.45s
In the code you see that Write-Host is mocked. In the output of .\build.ps1 it outputs the object before giving the error, clearly showing it's not being mocked. Hope the repo helps. Created also a VS Code profile with no extensions, to no avail.
You need to tell Pester in what scope to mock commands. Also there seemed not possible to use $Object
as it is a List, so need to compare using the first index in the list. Lastly it was a minor diff in the string being compared.
The PR https://github.com/KarstenHabay/Parl.Utility/pull/1/files works.
This was not an error in Sampler though.
Problem description
I have a function Show-ParlObjectUsingANSIColor and a test (see both below). When I run them directly (in a PowerShell console) with Pester both as inline or as dot sourced, they run fine and the test passes. When I run both files in a Sampler project using the .\build.ps1 command/script, I get error messages. I use Sampler 0.118.1 and Pester 5.6.1.
Am I missing something? Do I need to configure something somewhere in a config file? If so, I couldn't find it in the documentation of Sampler, or it wasn't clear enough for me. In the latter case, I'm sorry to have bothered you with this problem, as long as you can point me in the right direction ;-)
Function:
Pester test:
Verbose logs
How to reproduce
Create a sampler project, put the function in a public folder and then the test in a public test folder. Run .\build.ps1 -resolveDependency -Tasks noop Run .\build.ps1
Expected behavior
Passing test
Current behavior
Error message
Suggested solution
Need help
Operating system the target node is running
PowerShell version and build the target node is running
Module version used