Commit graph

1750 commits

Author SHA1 Message Date
Travis Plunk 5913c88aaf
Mark tests in macOS CI which use applescript as pending/inconclusive (#9352)
Mark tests in macOS CI which use applescript as pending/inconclusive
2019-04-12 18:12:29 -07:00
James Truher [MSFT] 1006db647b Reduce time for stack overflow test (#9302)
Create a small class to do the work.
I saw 100x performance improvement in this test.
2019-04-12 14:21:33 -07:00
Sytze Andringa 4884317d00 Added more tests for import-alias by file regarding parsing difficult aliases strings (#9247) 2019-04-11 10:40:24 -07:00
Reece Dunham 2d87948d8e Move from npm to Yarn for markdown tests (#9312)
Yarn is better because...
* it validates package checksums
* it has emojis 🤟
* it is faster and employs better caching
2019-04-10 14:16:22 -07:00
Dongbo Wang e299a30128 Fixing test run crash by not passing script block to the callback (#9298) 2019-04-08 11:06:27 -07:00
Travis Plunk 98b2e147c1
Only search for functions in Constrained Language help tests (#9301)
Only search for functions in Constrained Language help tests

## PR Context

Searching for only functions is faster
2019-04-08 11:01:33 -07:00
Steve Lee b63696572f Fix skipping of tests in RemoteSession.Basic.Tests.ps1 (#9304)
Moved check if able to write to $PSHome as way to skip test to `BeforeAll` which already contained a check if running on Windows.

## PR Context

As part https://github.com/PowerShell/PowerShell/pull/9279, tests were updated to be skipped if the test requires writing to `$PSHome` but is not able to.  However, these tests already had a skip mechanism in place so the additional check caused the test to run when it should have skipped.

Co-authored-by: Travis Plunk <github@ez13.net>
2019-04-05 17:00:41 -07:00
Ilya b927c46eb4
Add QuoteFields parameter to ConvertTo-Csv and Export-Csv (#9132) 2019-04-05 22:19:01 +05:00
Steve Lee b8317de469 Update tests to account for when $PSHOME is readonly (#9279)
Co-Authored-By: SteveL-MSFT <slee@microsoft.com>


Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
2019-04-04 23:01:01 -07:00
Staffan Gustafsson 4ec36a0d4a Fixing progress for Get-ComputerInfo (#9236) 2019-04-04 16:15:43 -07:00
Joel Sallow (/u/ta11ow) 3f52adb0ae Add Binary Parsing Support & Refactor TryGetNumberValue & ScanNumberHelper (#7993)
Fixes #7557 

* Adds support for binary parsing in format echoing hex: `0b11010110`
  * Works with all existing type suffixes and multipliers.
  * Supports arbitrary length parsing with `n` suffix using BigInteger; details below.
* Adds `NumberFormat` enum to specify hex/binary/base 10 for the tokenizer, replacing old `bool hex`.
* Adds `n` suffix for all numeric literals to support returning value as a `BigInteger` if requested. This bypasses the issue of large literals losing accuracy when they cast through `double`.
* Adds tests for all new behaviours.

---

### Binary / Hex Parsing Implementation

* Mimics old sign bit behaviour for int and long types. Sign bits accepted for 8 or 16-bit Hex parsing, and 8, 16, 32, 64 for binary.
  * i.e., `0xFFFFFFFF -eq ([int]-1)` and `0xFFFFFFFFFFFFFFFF -eq ([long]-1)`, but suffixing `u` creates `int.MaxValue` and `long.MaxValue`, respectively, instead.
* Sign bits higher than this are accepted for bigint-suffixed numerals:
    * Hex: Bigint-suffixed hex treats the high bit of any literal with a length multiple of 8 as the sign bit
    * Binary: Bigint-suffixed binary accepts sign bits at 96 and 128 chars, and from there on every 8 characters.
    * Prefixing the literal with a 0 will bypass this and be treated as unsigned, e.g. `0b011111111`
* Specifying an `u`nsigned suffix (or combination suffix that includes `u`) ignores sign bits, similar to how parsing a hex string using `[Convert]::ToUint32()` would do so.
* Supports negating literals using `-` prefix. This can result in positive numbers due to sign bits being permitted, just like hex literals.

---

### Refactored numeric tokenizer parsing

**New flow:**

1. Check for `real` (`.01`, `0.0`, or `0e0` syntaxes)
    1. If the decimal suffix is present, TryParse directly into decimal. If the TryParse fails, TryGetNumberValue returns `false`.
    2. TryParse as `Double`, and apply multiplier to value. If the TryParse fails, TryGetNumberValue returns `false`.
        1. Check type suffixes and attempt to cast into appropriate type. This will return `false` if the value exceeds the specified type's bounds.
        2. Default to parsing as `double` where no suffix has been applied.
2. Check number format.
    * If binary, manually parse into BigInteger using optimized helper function to directly construct the BigInteger bytes from the string.
    * If hex, TryParse into `BigInteger` using some special casing to retain original behaviours in int/long ranges.
    * If neither binary nor hex, TryParse normally as a `BigInteger`.
3. Apply multiplier value before attempting any casts to ensure type bounds can be appropriately checked without overflows.
4. Check type suffixes.
    * If a specific type suffix is used, check type bounds and attempt to parse into that type.
      * If the value exceeds the type's available values, the parse fails. Otherwise, a straight cast is performed.
5. If no suffix is used, the following types are bounds-checked, in order, resulting in the first successful test determining the type of the number. 
    * `int`
    * `long`
    * `decimal` (base-10 literals only)
    * `double` (base-10 literals only)
    * ~~`BigInteger` for binary or hex literals.~~ If the value is outside `long` range (for hex and binary) or `double` range (for base 10), the parse will fail; higher values must be explicitly requested using the `n`/`N` BigInteger suffix.

---

*This is a breaking change* as binary literals are now read as numbers instead of generic tokens which could potentially have been used as function / cmdlet names or file names.

Notes:
* Binary literal support was approved by the committee in #7557 
* ~~The same issue is still under further discussion for underscore support in numeric literals and whether BigInteger parsing ought to be exposed to the user at all.~~
    * ~~Supporting underscore literals is a further breaking change causing some generic tokens like `1_000_000` to be read as numerals instead.~~ Per @SteveL-MSFT's [comment](https://github.com/PowerShell/PowerShell/pull/7993#issuecomment-442651543) this proposal was rejected.
    * ~~Removing underscore support or preventing standard parsing from accepting BigInteger ranges is a relatively trivial matter. It is my personal opinion that there is no particular reason *not* to hand the user a BigInteger when they enter a sufficiently large literal, but I will defer to the PowerShell Committee's judgement on this.~~
2019-04-03 15:10:02 -07:00
Travis Plunk 5e4b4d1351 Make command searcher not use wildcard search for execution (#9202) 2019-04-02 11:54:11 -07:00
Rene Hernandez 75da390d1e Add ItemSeparator and AltItemSeparator properties in ProviderInfo (#8587)
Add two properties in `ProviderInfo` class: `ItemSeparator` and `AltItemSeparator`.
On windows, the default values for those two properties are `ItemSeparator = '\'` and `AltItemSeparator = '/'`.
On unix, the default values for those two properties are `ItemSeparator = '/'` and `AltItemSeparator = '\'`.

Registry provider is the only exception, both properties for it have the value `\`.
2019-04-02 09:59:36 -07:00
pougetat 0ee5278b40 Fix Get-Module -FullyQualifiedName option to work with paths (#9101) 2019-03-29 15:27:09 -07:00
pougetat e553aef0fb Implement Get-Random -Count without specifying an InputObject list (#9111) 2019-03-26 16:50:20 +05:00
Steve Lee 3255d84627 Enable SecureString cmdlets for non-Windows (#9199)
On Unix systems, fallback to plaintext manipulation instead of using the DPAPI which is not available.

## PR Context

Currently, existing scripts that use SecureString cmdlets fail with an error complaining about crypt32.dll not being available.  This change allows these cmdlets to be used, but there is no encryption of the string.
.Net already [states](https://docs.microsoft.com/en-us/dotnet/api/system.security.securestring?view=netcore-2.1#remarks) that the contents of a SecureString are not encrypted on .Net Core.

Fix https://github.com/PowerShell/PowerShell/issues/1654

Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
2019-03-23 10:11:05 -07:00
Ilya cc6540b614
Cleanup style issues in CoreAdapter and MshObject (#9190) 2019-03-23 09:52:30 +05:00
Travis Plunk 94616f1789
Add Obsolete message to Send-MailMessage (#9178)
Add Obsolete message to Send-MailMessage

## PR Context

See https://github.com/PowerShell/PowerShell-RFC/pull/160

Co-authored-by: Steve Lee <slee@microsoft.com>
Co-authored-by: Ilya <darpa@yandex.ru>
2019-03-22 12:52:41 -07:00
Travis Plunk 185f20e3bd
Add tests for command globbing (#9180)
Add tests for command globbing
  - Also, add `-noprofile` to places where `pwsh` is launched so they don't fail locally.
2019-03-21 13:49:57 -07:00
Staffan Gustafsson 42c289fc8e Improve formatting performance by having better primitives on PSObject (#8785)
By not doing excessive amounts of extra work, formatting can be sped up quite significantly (about 8x faster).
The main change comes from adding new, more efficient, primitive to query an object for the existence of an instance member.
The formatting system has been checking for if an object has properties other than some decorated properties added by PS remoting, and it doesn't this by retrieving all properties which results in heavy allocations and wasted cycles.
By adding `GetFirstOrDefault` to `PSObject` and similar primitives to the underlying Adapters, we are able to return early, without having to get all properties back.
2019-03-20 18:43:52 -07:00
Patrick Meinecke b4ebf63335 Improve type inference of array literals and foreach statement variables (#8100)
Improve type inference for foreach statement variables by:

Inferring strongly typed arrays from explicit array and array literal expressions when elements are of the same inferred type

Fix detection of foreach variable declaration. The previous logic was to check if the variable expression's start offset was after the end offset of the foreach statement, which will never be true in the body

Improve inference of what type the "Condition" of a foreach statement will enumerate as
2019-03-19 13:36:27 -07:00
Dongbo Wang 24d3152f00 Make Start-Job throw terminating exception when -RunAs32 is specified in 64-bit pwsh (#9143) 2019-03-18 10:23:29 -07:00
Staffan Gustafsson e91d6dcf56 Adding CmdletsToExport and AliasesToExport to test module manifests. (#9108) 2019-03-18 11:09:05 +05:00
Jacob Scott 8f6982cc8a Made -Subject parameter of SendMail command no longer mandatory. (#8961) 2019-03-18 08:24:57 +05:00
pougetat 5277c79d67 Clean up Get-Random cmdlet (#9133) 2019-03-16 13:54:35 +05:00
Dongbo Wang cdb28a1067 Make 'Start-Job' throw terminating error when PowerShell is being hosted (#9128) 2019-03-13 17:57:42 -07:00
Reece Dunham 78f4ba5ec1 Update AppVeyor comments in Implicit.Remoting.Tests.ps1 (#9020) 2019-03-13 12:52:35 -07:00
pougetat a79ed1ef0f Make New-ModuleManifest consistent with Update-ModuleManifest (#9104) 2019-03-13 12:01:42 -07:00
Joel Sallow (/u/ta11ow) 18d5037ad2 Fix -NoEnumerate behaviour in Write-Output (#9069)
Fix is to preserve input collection type in output.
The regression was caused by #2038
2019-03-13 13:54:12 +05:00
Ilya e75bd1482f
Add support empty NoteProperty in Group-Object (#9109) 2019-03-13 11:22:05 +05:00
Staffan Gustafsson 9983297254 Removing Hardlink from Mode property in default file system format (#8789) 2019-03-12 15:49:16 -07:00
James Truher [MSFT] e605fbdea7 Fix tab completion test to handle multiple matches (#8891) 2019-03-11 14:51:22 -07:00
Staffan Gustafsson 0ebbdc1cc4 Fixing issue with help progress with Get-Help not calling Completed (#8788) 2019-03-11 11:26:01 -07:00
Tyler James Leonhardt a26d639a47 Fix Enter-PSHostProcess tests flakiness (#9007) 2019-03-11 10:41:06 -07:00
pougetat e3829cb60f Allow Test-ModuleManifest to work when RootModule has no file extension (#8687) 2019-03-10 14:57:19 -07:00
Reece Dunham 43487b4068 Update markdown test dependencies (#9075) 2019-03-09 08:30:14 +05:00
Dongbo Wang 50f3e7f10e
Update the task-based async APIs added to PowerShell to return a Task object directly (#9079)
Update the task-based async APIs added to PowerShell to not use the `aysnc/await` keywords, but to return a `Task` object directly.
There is nothing to continue on after the `Task.Factory.FromAsync` call in those methods, so there is not need to use `aysnc` and `await` keywords, which turns the method into a state machine class unnecessarily.
2019-03-07 11:24:31 -08:00
Aditya Patwardhan 0752a5502a
Add source for install-package to install netDumbster (#9081) 2019-03-06 16:21:03 -08:00
Ilya 2953959dc5 Add UseQuotes parameter (#8951) 2019-03-06 11:59:15 -08:00
Kirk Munro 45aba2acb5 Add 5 'InvokeAsync' overloads and 'StopAsync' to the 'PowerShell' type (#8056) 2019-03-06 10:06:11 -08:00
ThreeFive-O d56e50152a Style fixes for Select-Xml tests (#9037) 2019-03-05 15:07:00 -08:00
ThreeFive-O a2c9482194 Enable cross-platform Send-MailMessage tests for CI (#8859) 2019-03-05 14:29:48 -08:00
Reece Dunham da4930f2dc Added RequireSudoOnUnix tags to PowerShellGet tests and unmark as pending (#8954) 2019-03-05 11:55:20 -08:00
ThreeFive-O 6e383de251 Style fixes for ConvertTo-Xml tests (#9036) 2019-03-05 11:39:58 -08:00
dependabot[bot] 98506db714 Build(deps): Bump SelfSignedCertificate in /test/tools/Modules (#9055) 2019-03-05 11:32:40 -08:00
ThreeFive-O 017e472961 Align name schemes for test files (#9034) 2019-03-05 10:47:04 -08:00
Aditya Patwardhan 7062297e4e
Update version for PowerShell.Native and hosting tests (#8983) 2019-03-04 11:08:19 -08:00
Gaurav Kamath f31b33863c Refactor Shuffle in Get-Random to save a full iteration of the objects. (#8969) 2019-03-01 17:11:37 +05:00
Ilya 18f9a36f2a Pending NamedPipeConnectionInfo test (#9003)
Related #8971. Pending the test until we fix a root case of failure.
2019-02-27 14:51:36 -08:00
mjanko5 7e0411fcd9 Add test for -WhatIf for New-FileCatalog (#8966) 2019-02-27 10:53:08 +05:00