Commit graph

1096 commits

Author SHA1 Message Date
Steve Lee 2e901e53c3 fix powershell -version and help (#4958)
PowerShell -v  behavior updated to align with other tools like git, curl, and bash where args after  -v  are silently ignored.

Built-in help updated to reflect changes we've made to the console host in PSCore6 removing unsupported parameters.

* [feature]
removed test that is no longer valid due to change in -version behavior to return error

* [feature]
fixed `-v X` so that it errors out correctly with proper exit code
updated test to catch this

* [feature]
address PR feedback

* [feature]
make -v have behavior consistent with other tools like git, curl, bash where args after -v are ignored
removed duplicate but not exactly help text that wasn't being used in the resource file
removed parameters from help that are not support in PSCore6
2017-10-01 07:39:18 +04:00
Steve Lee a82f6376ab Change CRLF to LF for files that are already in repository (#4956) 2017-09-29 17:43:57 -07:00
Dongbo Wang a4b8dd0a23 Remove Microsoft.PowerShell.CoreCLR.AssemblyLoadContext.dll (#4868)
The code in `AssemblyLoadContext.dll` doesn't need to be in a separate DLL anymore.
S.M.A.dll depends on `AssemblyLoadContext.dll`, so keeping that code out of S.M.A.dll doesn't help make S.M.A smaller size or less dependent. So the code in `AssemblyLoadContext.dll` is moved to `S.M.A.dll` and then we remove `AssemblyLoadContext.dll`.

The changes are:
- Move `CorePsAssemblyLoadContext.cs` to `src\S.M.A\CoreCLR\`
- Update `CorePsAssemblyLoadContext.cs` to get the test took moved to `Utils.InternalTestHooks` and update tests
- Update `build.psm1` and `.csproj` accrodingly
- Update `pwrshcommon.cpp` to remove `AssemblyLoadContext.dll` from the TPA list.
- `S.M.A.AssemblyExtensions` is removed as `PackageManagement` has finished their move to .NET Core 2.0. (I will work with Bryan to get the latest version uploaded to powershell-core)
2017-09-29 17:26:55 -07:00
Steve Lee 2639cd89ce Autocorrected CRLF to LF (#4943)
Also, fix `Parser.Tests.ps1` after correcting CRLF.
2017-09-29 16:28:15 -07:00
Steve Lee 8fdd68fbaa [feature] (#4954)
remove unnecessary error messages from output
2017-09-29 14:35:13 -07:00
Ilya 757c6b5f39 Write an error for powershell -version 2 (#4931)
Write an error for powershell -version <any value>
2017-09-29 23:20:28 +04:00
Chunqing Chen e3a004c036 Change PS to load the assembly with 'Assembly.LoadFrom' before 'Assembly.Load' when the file path is given (#4196)
It's to solve a side-by-side problem we have with powershell core. If a .NET Core version assembly has the same name as it's .NET ancestor in GAC, then even if you specify the file path to `Import-Module`, powershell core will still load the one in GAC because it tries 'Assembly.Load' first.
Now we change it to use `Assembly.LoadFrom` first when a file path is given, so it works for modules that have side-by-side assemblies.
2017-09-29 11:58:56 -07:00
Ilya b07f24e3c9 Exclude '-Comobject' parameter of 'New-Object' on unsupported platforms (#4922) 2017-09-28 17:29:33 -07:00
Steve Lee 99e3fe586e Enable transcription of native commands on non-Windows (#4871)
Transcription was relying on reading the screen buffer to record output from native commands.
This resulted in an unhandled exception calling an unimplemented API on non-Windows.
The fix is to use redirected output/error if reading the screen buffer is not supported.
We check whether screen scraping is supported or not only when the application is running standalone.
2017-09-28 17:15:37 -07:00
Ilya 6e77537181 Get 'PSVersion' and 'GitCommitId' from the 'ProductVersion' attribute of assembly (#4863) 2017-09-28 09:27:43 -07:00
Chunqing Chen f83e238082 add get-help tests for alias (#4895) 2017-09-28 08:47:42 -07:00
James Truher [MSFT] d20d6a606a Add source files for coverage run (#4925)
A number of tests require the sources to be present in order to work correctly.
During cleanup be sure to remove any lingering powershell.exe processes because subsequent runs will not be able to update the test binaries.
2017-09-27 15:36:21 -07:00
Travis Plunk 951e7527eb Add line secret suppression (#4935) 2017-09-27 15:34:12 -07:00
Travis Plunk f02e692a5d Fix credential scan issues (#4927)
* Add file secret suppression
* Add line secret suppression
* This will be consumed in the VSTS daily build.
* Renamed tests with ConvertTo-SecureString to avoid false positives
2017-09-27 11:54:22 -07:00
Mark Kraus a8e8b1f8e4 Change UserAgent App WindowsPowerShell -> PowerShell (#4914)
* Change UserAgent App WindowsPowerShell -> PowerShell

* [Feature] Run Feature tests

* [feature] Address PR Feedback with more precise assertion

* [feature] Address PR Feedback and add PSUserAgent Test

* [feature] add tag to describe block

* [feature] Remove describe block Add pattern to User-Agent specific tests

* [feature] Address PF Feedback

Remove all assertions for User-Agent that are not specifically about the User-Agent header.

* [feature] Match -> MatchExactly
2017-09-27 07:44:20 -07:00
Ilya 7c64c0ff25 Enable network Select-String test (#4921)
* Enable network string test

* Fix typo

* Use Get-Item to add PSDrive property
2017-09-27 07:20:02 +04:00
Mark Kraus dd02aac3d7 [feature] Fix TestValue to avoid double // in Urls (#4920)
•Adds logic in  Get-WebListenerUrl  to only apply the  TestValue  part of the path if it was supplied.
2017-09-26 09:05:55 +04:00
Steve Lee efbdea5cfe Fix importing remote module using version filters and added tests (#4900)
- Add tests for remote import-module
- Fix issue with remotely importing module where it was checking the version filter incorrectly against the proxy module
   - The filters are applied when importing the module remotely
   - After proxy module is generated it always has a module version of 1.0, so the filters will always fail when importing the proxy locally
2017-09-25 21:37:56 -07:00
Steve Lee 901a61bcc1 Enable auto EOL on git repo side, fix some character encoding issues (#4912)
- add ending newline to files missing it using:
`awk -F: '$2 ~ / no line terminators/ {print $1}' ~/text-files.txt | xargs -I{} sh -c 'printf "\n" >> "$1"' - {}`
- update .gitattributes to enforce autocrlf on all text files
- added <copyright> opening element where it was missing
removed file attribute pointing to wrong filename
- fix mis-encoded character to apostrophe
- replace incorrect encoding of copyright symbol with (c)
- updated file hashes in the test
2017-09-25 15:14:39 -07:00
Mark Kraus b30da378e7 Replace httpbin.org/delay Tests with WebListener (#4905) 2017-09-25 12:50:15 -07:00
Steve Lee 65415c3b9e allow * to be used in registry path for remove-item (#4866)
* [feature]
allow * to be used in registry path for remove-item

* [feature]
address PR feedback
have remove-item return error if -literalpath doesn't resolve to path

* [feature]
fix in navigation exposed an issue with WSMan Config Provider tests
that require -Recurse to be used otherwise a confirmation prompt shows
up
2017-09-25 10:15:38 -07:00
Mark Kraus 3237d43b26 Add ResponseHeadersVariable Parameter to Invoke-RestMethod (#4888)
* Add ResponseHeadersVariable to Invoke-RestMethod

* Add Tests for -ResponseHeadersVariable

* [Feature] Run Feature Tests

* Remove test to address PR feedback

* Alais HV -> RHV per request

* [Feature] Rerun CI

* [Feature] Remove Superfluous Assertion
2017-09-25 10:11:12 -07:00
Steve Lee 25a32284dd fix tests not setting back $psdefaultparametervalues back correctly (#4892) 2017-09-23 13:48:51 -07:00
James Truher [MSFT] 40577cb61f Add the timezone offset correctly (#4867)
It must be padded to 3 digits and prepended with either '-' or '+'
An incorrectly formatted string will not be able to be converted back to a datetime
2017-09-22 11:25:48 -07:00
Mark Kraus 65cf571b54 Replace httpbin.org/encoding Tests with WebListener (#4869) 2017-09-22 10:09:49 -07:00
Dongbo Wang c9cf843302 Fix a test issue that causes tests to be skipped in Travis CI run (#4891) 2017-09-21 11:54:48 -07:00
Ilya 93dc591025 Add 'ArgumentCompletionsAttribute' to support more argument completion scenarios (#4835)
- Add 'ArgumentCompletionsAttribute' to support argument completion for parameters that cannot have a ValidateSetAttribute.
- Use 'ArgumentCompletionsAttribute' for the '-Format' parameter of 'Get-Date' to enable useful argument compeltions.
2017-09-21 10:52:21 -07:00
Jonas Andersen f281671375 [Feature]Added Remove-service to Management module (#4858)
* [Feature]Remove-Service added to Management module

* [Feature]Capitalization

* [Feature]Added test cases for Remove-Service, Removed return value

* [Feature]Documentation from copy-paste code corrected to reflect the new function

* [Feature]Erroraction to be sure that an error is thrown in testcase

* [Feature]Removed direct reference to module in Pester test

* [Feature]Removed extra line in test

* [Feature]Use FullyQualifiedErrorId in Remove-Service test without a valid servicename

* [Feature]Exposed Remove-Service

* [Feature]Consistent casing, Named Arguments & Remove incorrect exception on cleanup

* [Feature]Remove-Service test should fail if the service was not removed

* [Feature]Cleanup comments & add Remove-Service for CI

* [Feature]Remove-Service in CI set in alphabetic order

* [Feature]Use ParameterSetName instead of _ParameterSetName and rewrite test which used the function class directly

* Revert "[Feature]Use ParameterSetName instead of _ParameterSetName and rewrite test which used the function class directly"

This reverts commit da41f7deb8.

* [Feature]Remove _ParameterSetName check & added test for pipeline input in
Set-Service
2017-09-20 17:24:39 -07:00
Dongbo Wang 4c29f5768d Fix bugs with expression redirected to file (#4847)
When handling file redirection for CommandExpression, we don't call 'DoComplete' on the underlying PipelineProcessor of the FileRedirection object, and thus the EndProcessing method is not called on Out-File, which causes different behaviors between <expr> > out.txt and <expr> | Out-File out.txt.

The fix is to make sure 'DoComplete' is called after the stream output has been written to the redirection pipe.

Also fix another issue

This PR also fixes an issue that could mess up restoring the original pipes. Here is the repro:

PS> 1 *> b.txt > a.txt; 123
Cannot perform operation because object "PipelineProcessor" has already been disposed
The root cause is that we don't always restore pipes in the correct order. Please see the code changes in Compiler.cs for more details.

Fix #4812
2017-09-20 14:39:02 -07:00
Staffan Gustafsson 916ef56eeb Call to CodeMethod returning void should work (#4850)
Fixes #4826
2017-09-20 14:37:43 -07:00
Paul Higinbotham 7c8b7eff52 Port tests for constrained language mode (#4816)
* Port tests for constrained language mode
* Added 'RequireAdminOnWindows' for registry access
* Restored Wait-UntilTrue to current state
2017-09-19 14:53:29 -07:00
James Truher [MSFT] fb7c7b038b Only run tests on Windows, otherwise skip them. (#4861) 2017-09-19 13:51:21 -07:00
Steve Lee 66552a430f Add CDXML CIM DateTime test (#4796) 2017-09-18 17:10:58 -07:00
Sarith Sutha af798fb644 Add tests for Get-Content (#4723)
* Add tests for Get-Content -Tail #4150

* Incorporated the review comments

* renamed couple of tests

* removed extra spaces

* Tests refactored into a Context and the checks broken down into separate tests

* Made the indents consistent with the other existing tests

* Incorporated the review comments
2017-09-18 16:58:58 -07:00
Steve Lee 23420643e3 Added WSMan Config provider tests (#4756)
* [Feature]
fixed issues in WSMan Config Provider
added tests for get-item, get-childitem, set-item, new-item remove-item, clear-item, dynamic parameters
merged CoreClr and FullClr code

* [feature]
address PR feedback

* [feature]
revert to using microsoft.powershell plugin as base for test
keeps it simple rather than relying on additional scripts or cmdlets since these tests don't require remoting

* [feature]
address Aditya's feedback

* [feature]
address some cosmetic feedback

* [feature]
based on discussion with Jim, we should skip resx checks on non-Windows
2017-09-18 15:44:09 -07:00
Dongbo Wang 192803bfcf Build powershell core using the generic RID 'linux-x64' (#4841) 2017-09-18 09:31:07 -07:00
Mark Kraus a2dd0ca4b5 Replace httpbin.org/redirect Tests with WebListener (#4852) 2017-09-18 09:26:01 -07:00
Dan Travison a3e129c586 Fix tests that incorrectly use ShouldBeErrorId (#4793) 2017-09-18 09:24:55 -07:00
James Truher [MSFT] 0229451148 Validate product resource strings against resx files (#4811) 2017-09-18 09:20:46 -07:00
Dan Travison 0770746e7d Add tests for Get-Content -Tail parameter (#4790) 2017-09-18 08:51:36 -07:00
Jonas Andersen b7ec5da216 Added functionality to set credientials on Set-Service command (#4844)
Now we can specifiy the -Credential parameter on Set-Service cmdlet to change a service's logon account.
2017-09-18 14:23:17 +04:00
Lucas Spits 03e3257b0a Updated default ModuleVersion in ModuleManifest (#4842)
* Updated default ModuleVersion in ModuleManifest to 0.0.1

* updates tests where manifests default versions where still matched agianst the old 1.0 version
2017-09-15 11:44:07 -07:00
Steve Lee b723d6b7f2 fix set-service failing test (#4802)
* Add '-ErrorAction Stop' in Set-Service.Tests.ps1 to correctly test exceptions.
* Refactor StartupType service code and add a throw for disabled startup types (System, Boot).
* Made StartupType(-1) equivalent to Win32 SERVICE_NO_CHANGE.
2017-09-15 12:24:40 +04:00
bergmeister da49841f16 Use a simple file based check for the VC++ 2015 redistributables (#4745)
* A simple and minimal fix of 4665 to check for the Visual Studio C++ 2015 redistributables. Note that this is specific to 2015 (vcruntime140.dll refers to the Visual Studio version 14.0, which maps to Visual Studio 2015).
A previous check registry check of 'SOFTWARE\Microsoft\DevDiv\VC\Servicing\14.0\RuntimeMinimum' failed because when the redistributables are installed via Windows update (which does not use MSI), then the registry entry did not get populated.
The 'Pending' attribute was removed from existing tests since the download links are now present again and the tests were improved using Pester TestCases.

* Fixed typo spotted in code review of PR 4745

* Remove DirectorySearch Id duplication by defining it once and referencing according to this special trick in the official WiX documentation here: http://wixtoolset.org/documentation/manual/v3/howtos/files_and_registry/directorysearchref.html
Renamed property values as suggested.

* Remove replacements of HTTPS with HTTP, i.e. test against exact link. Use -UseBasicParsing switch with the hope of not having failures in the CI environment.
Added comment why there is no assertion about the StatusCode.

* Replace download links with link to pre-requisites page as suggested in PR 4745 because this page is easier to update

* Compilation error CNDL0012 fix: WiX does not allow lowercase characters for file search property Ids because due to them being used for a search property means that they must be public, hence lowercase is not allowed.
2017-09-14 18:42:36 -07:00
Ilya a4cdb806f4 Exclude directories discovered from '-Path' in Select-String (#4829)
Select-String can search in files only so we should skip directories.
2017-09-14 14:57:17 -07:00
James Truher [MSFT] a9db9ba482 Skip Certificate Authentication tests on CentOS and Mac (#4822)
These two tests have been failing on CentOS for some time. It is because the available libcurl library does not support client authentication certificates
2017-09-14 10:52:35 -07:00
Mark Kraus 303a83546b Replace httpbin.org/user-agent with WebListener (#4798)
* Replace httpbin.org/user-agent with WebListener

* [feature] -SkipCertificateCheck To avoid cert issue

* [Feature] Rebase & Rerun CI

Rerun count: II
2017-09-14 09:23:29 +04:00
Mark Kraus 869cdf9ba4 Replace httpbin.org/headers with WebListener Get (#4799)
* Replace httpbin.org/headers with WebListener Get

* [feature] -SkipCertificateCheck to avoid Cert issue

* [Feature] Rebase & Rerun CI
2017-09-14 09:22:52 +04:00
Steve Lee 5fedd9c54f added tests for start/stop/suspend/resume/restart service cmdlets (#4774) 2017-09-13 10:24:04 -07:00
Steve Lee 4ad313aafb Add tests for Get-Module over remoting (#4787)
Some additional tests that are remoting specific based on code coverage
2017-09-12 17:12:52 -07:00