-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Fix for #2442 - automounted drives in modules #3034
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
Conversation
| { | ||
| result = AutomountFileSystemDrive(name); | ||
| // first try to automount as a file system drive | ||
| result = AutomountFileSystemDrive(name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old code only created file system drives if the current scope was global.
Will your change create the drive in global scope or module scope?
Personally, I would expect the drive to be in global scope.
I would also like to see tests to cover that scenario either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this change, new drives will be created in global scope; I've added a check for this to tests.
| { | ||
| Remove-Module $m | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files should end with a newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
| } | ||
| Dismount-VHD $VHDPath | ||
| Remove-Item $VHDPath | ||
| } No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files should end with a newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
| & $powershell -noprofile -command "$AutomountVHDDriveScriptPath -useModule -VHDPath $vhdPath" | Should Be "Drive found" | ||
| } | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files should end with a newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
| Context "Validating automounting FileSystem drives" { | ||
|
|
||
| It "Test automounting using subst.exe" -Skip:$SubstNotFound { | ||
| & $powershell -noprofile -command "$AutomountSubstDriveScriptPath -FullPath $substDir" | Should Be "Drive found" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could fail in a couple ways if there are spaces in the path, a fix would look something like this:
You can use:
& $powershell -noprofile -command "& '$AutomountSubstDriveScriptPath' -FullPath '$substDir'" | Should Be "Drive found"There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated; Thank you.
This fixes #2442
Added tests using: 1) 'subst.exe' utility 2) New-VHD/Mount-VHD cmdlets .
Also added tests that verify automounted drives without modules in the picture to use as baseline.
Test results on Hyper-V machine after fix:


Test results on Non-Hyper-V machine after fix:
For reference - test results on Hyper-V machine before fix:


For reference - test results on Non-Hyper-V machine before fix: