Comments (11)
@PlagueHO Yes please, we could improve the logic to find module root.
from dscresource.tests.
Aha! I wondered why this was happening. Gradually, it takes longer and longer to start a PowerShell session when autoloading modules - due to the hundreds of entries in the PSModulePath. Good catch :)
from dscresource.tests.
Thanks for logging this @rchaganti - appreciate it!
I totally agree, this is definitely a problem and needs to be fixed ASAP! Thanks for investigating it.
The original test methodolgy was to move the module to the existing PSModulePath folder, but this introduced it's own issues:
- If the same module already existed on the test machine in the PSModulePath then the existing version(s) would first have to be moved out to a temporary location before being tested. This becomes more complex when multiple different versions exist.
- If the unit tests were terminated by the user then the content of the PSModulePath would be left in an unknown state.
So reverting to the original process (moving the module toPSModuleRoot) might not be the ideal solution either. I'd say the path detection needs to be fixed primarily - so that in your case c:\Temp is set as the path rather than C:\ .
The existing Unit/Integration test templates are all wrapped in a try/catch/finally block with the finally block calling the Restore-TestEnvironment
function. This was intended to preserve the environment no matter what occurred - if it isn't managing this then that needs to be fixed as well.
@tysonjhayes - have you got any thoughts on this one?
from dscresource.tests.
Looking at the code it seems to me that the problem might be that the detection method used to detect the root folder of the module could be at fault. Specifically one of these two lines:
https://github.com/PowerShell/DscResource.Tests/blob/dev/DscResourceTestHelper/TestHelper.psm1#L322
https://github.com/PowerShell/DscResource.Tests/blob/dev/DscResourceTestHelper/TestHelper.psm1#L325
@rchaganti - are you able to specify which Resource module you were testing?
from dscresource.tests.
This happened while I was testing xVMNetworkAdapter resource that I pushed to xHyper-V.
from dscresource.tests.
@PlagueHO why can't we simply rename the target folder if there is a name conflict and copy the new one that we need to run tests on? And, in the clean up code, we can restore the original name.
from dscresource.tests.
This is for the PR I submitted in xHyper-V. The resource is xVMNetworkAdapter.
Get Outlook for Androidhttps://aka.ms/ghei36
On Wed, May 18, 2016 at 1:18 AM -0700, "Daniel Scott-Raynsford" <[email protected]mailto:[email protected]> wrote:
Looking at the code it seems to me that the problem might be that the detection method used to detect the root folder of the module could be at fault. Specifically one of these two lines:
https://github.com/PowerShell/DscResource.Tests/blob/dev/DscResourceTestHelper/TestHelper.psm1#L322
https://github.com/PowerShell/DscResource.Tests/blob/dev/DscResourceTestHelper/TestHelper.psm1#L325
@rchagantihttps://github.com/rchaganti - are you able to specify which Resource module you were testing?
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHubhttps://github.com//issues/55#issuecomment-219957604
from dscresource.tests.
@rchaganti
So your folder structure was
C:\temp\xHyper-v\DscResources\xVMNetworkAdapter ?
If that's the case then indeed we should have added C:\temp to the PSModulePath, not the C:\ ,so the culprit may be what @dcrreynolds pointed at.
Simply renaming the folder in case of the conflict won't work since if you interrupt tests we will be left with the renamed folder - we are already unwinding our changes to PSModulePath in the finally block and looks like it doesn't work the way we expect, that's another area to investigate though.
from dscresource.tests.
@rchaganti - I found the problem. Your Unit tests must be in a sub folder called Unit if you're using the standard test templates.
So you should have a path like this:
/Tests/Unit/MSFT_xVMNetworkAdapter.tests.ps1
See xNetworking for an example.
That said, the code should deal with this situation better and perhaps do a better job at detecting the root of the DSC module, so even if the tests are in a path that is not exepected the root would still be detected. This could be done by simply walking up the tree and looking for the right PSD1 file (because we know the name of the Resource module we're in already).
Also, no matter what happens the test code should always return the environment back to it's original state as @KarolKaczmarek mentioned. The only time it might not if it was terminated unexpectedly via a crash or killing the task. I have confirmed that using CTRL+C will still fire the Finally block and return the environment back to normal.
from dscresource.tests.
@KarolKaczmarek - is it worth me making the change I suggested? E.g. so that we locate the Root of the module by walking up the tree from the test file until we find the Resource Module filename?
I'm not sure what we can do about fixing the problem with the environment being reset though.
from dscresource.tests.
Cool - I'll get onto it.
from dscresource.tests.
Related Issues (20)
- Nuget Spec Generated by AppVeyor invalid for PS Module Repository HOT 1
- Additional localization tests
- When opt-in to markdown links check, the cloned DscResource.Tests is also checked HOT 1
- Remove manual step in auto-documentation HOT 1
- Auto-documentation should document helper functions inside the Modules folder HOT 4
- Refactor DscResource.DocumentationHelper/PowerShellHelp.psm1/New-DscResourcePowerShellHelp
- New-DscResourcePowerShellHelp: Should output the help keyword .EXAMPLE in upper-case HOT 1
- Test-PublishMetadata: Exception Raised If the Example being tested has an invalid GUID
- Invoke-AppveyorAfterTestTask: Exception Calling New-DscResourcePowerShellHelp when Type is 'Wiki' HOT 2
- Wikik documentation should separate read-only parameters from the parameters table
- Wiki documentation should create code quotes for variables in parameter descriptions
- New-DscResourcePowerShellHelp: Generates white space on blank rows in the .DESCRIPTION section
- New-DscResourcePowerShellHelp: Files are generated as UTF-8 with BOM
- The custom rules should be listed and reference the style guideline rule it belongs to HOT 1
- Code formatting: newlines before and after if statement block HOT 1
- Add Tests to Ensure DSC Resource Names are added to DSCResourcesToExport in Manifest
- Generation of Wikipages throws an error HOT 3
- New-DscResourceWikiSite: Array DataTypes Have Changed Format HOT 3
- Get-MofSchemaObject: Credential Attribute Output DataType has Changed
- Common Tests - File Formatting: References missing cmdlets HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dscresource.tests.