Skip to content

Conversation

@iSazonov
Copy link
Collaborator

@iSazonov iSazonov commented Nov 12, 2018

Motivation

I have a PR where there are many new xUnit tests.
It would also be useful to create new xUnit tests for public APIs.
The number of xUnit tests will increase and their ordering is required.

PR Summary

  • Move C# xUnit tests in new folder. This allows to put new xUnit tests in directory structure in accordance with directory structure where cs files are.
  • Use an xUnit TestCaseOrderer attribute to sequentially process tests for powershell.config.json.
  • Update README.md
  • A race condition was fixed which allowed to run all XUnit tests in single batch job.

PR Checklist

@iSazonov iSazonov changed the title Move xUnit tests in new folder Move xUnit tests to new folder Nov 12, 2018
@iSazonov
Copy link
Collaborator Author

@daxian-dbw daxian-dbw added Area-Maintainers-Build specific to affecting the build and removed Area-Maintainers-Build specific to affecting the build labels Nov 12, 2018
@iSazonov iSazonov force-pushed the move-xunit-tests branch 5 times, most recently from e767b7b to c2fce12 Compare November 13, 2018 13:13
@iSazonov iSazonov requested a review from BrucePay as a code owner November 13, 2018 13:13
@iSazonov
Copy link
Collaborator Author

Fixed race condition when access powershell.config.json
https://ci.appveyor.com/project/PowerShell/powershell/builds/20262667/job/ta0qkiiemeyxkhyb#L644

Starting test execution, please wait...
645
dotnet : [xUnit.net 00:00:03.35]     PSTests.Parallel.FileSystemProviderTests.TestClearProperty [FAIL]
646
At C:\projects\powershell\build.psm1:1431 char:13
647
+             dotnet test --configuration $Options.configuration --no-r ...
648
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
649
    + CategoryInfo          : NotSpecified: ([xUnit.net 00:0...Property [FAIL]:String) [], RemoteException
650
    + FullyQualifiedErrorId : NativeCommandError
651
 
652
Failed   PSTests.Parallel.FileSystemProviderTests.TestClearProperty
653
Error Message:
654
 System.IO.IOException : The process cannot access the file 'C:\projects\powershell\test\xUnit\bin\Release\netcoreapp2.1\powershell.config.json' because it is being used by another process.
655
Stack Trace:
656
   at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
657
   at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
658
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
659
   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
660
   at System.Management.Automation.Configuration.PowerShellConfig.ReadValueFromFile[T](ConfigScope scope, String key, T defaultValue, Func`4 readImpl) in C:\projects\powershell\src\System.Management.Automation\engine\PSConfiguration.cs:line 358
661
   at System.Management.Automation.Utils.GetPolicySettingFromConfigFile[T](ConfigScope[] preferenceOrder) in C:\projects\powershell\src\System.Management.Automation\engine\Utils.cs:line 534
662
   at System.Management.Automation.Utils.GetPolicySetting[T](ConfigScope[] preferenceOrder) in C:\projects\powershell\src\System.Management.Automation\engine\Utils.cs:line 520
663
   at System.Management.Automation.Host.PSHostUserInterface.GetSystemTranscriptOption(TranscriptionOption currentTranscript) in C:\projects\powershell\src\System.Management.Automation\engine\hostifaces\MshHostUserInterface.cs:line 910
664
   at System.Management.Automation.Host.PSHostUserInterface.CheckSystemTranscript() in C:\projects\powershell\src\System.Management.Automation\engine\hostifaces\MshHostUserInterface.cs:line 430
665
   at System.Management.Automation.Internal.Host.InternalHostUserInterface..ctor(PSHostUserInterface externalUI, InternalHost parentHost) in C:\projects\powershell\src\System.Management.Automation\engine\hostifaces\InternalHostUserInterface.cs:line 23
666
   at System.Management.Automation.Internal.Host.InternalHost..ctor(PSHost externalHost, ExecutionContext executionContext) in C:\projects\powershell\src\System.Management.Automation\engine\hostifaces\InternalHost.cs:line 51
667
   at System.Management.Automation.ExecutionContext.InitializeCommon(AutomationEngine engine, PSHost hostInterface) in C:\projects\powershell\src\System.Management.Automation\engine\ExecutionContext.cs:line 1453
668
   at PSTests.Parallel.FileSystemProviderTests.GetExecutionContext() in C:\projects\powershell\test\xUnit\csharp\test_FileSystemProvider.cs:line 45
669
   at PSTests.Parallel.FileSystemProviderTests.GetProvider() in C:\projects\powershell\test\xUnit\csharp\test_FileSystemProvider.cs:line 49
670
   at PSTests.Parallel.FileSystemProviderTests.TestClearProperty() in C:\projects\powershell\test\xUnit\csharp\test_FileSystemProvider.cs:line 151
671
Results File: C:\projects\powershell\ParallelXUnitTestResults.xml
672
673
Total tests: 35. Passed: 34. Failed: 1. Skipped: 0.
674
Test Run Failed.
675
676

@iSazonov iSazonov changed the title Move xUnit tests to new folder WIP: Move xUnit tests to new folder Nov 13, 2018
@iSazonov
Copy link
Collaborator Author

I'll move some fixes in separate PRs.

@iSazonov iSazonov changed the title WIP: Move xUnit tests to new folder Move xUnit tests to new folder Nov 14, 2018
@iSazonov
Copy link
Collaborator Author

The PR contains commits from #8249 to fix race conditions. After merging #8249 I will rebase.

Please review the PR.

@iSazonov iSazonov added the CL-Test Indicates that a PR should be marked as a test change in the Change Log label Nov 16, 2018
DarwinJS and others added 5 commits November 29, 2018 09:18
…url` (PowerShell#8225)

install-powershell.sh now autodetects whether curl or wget is installed to download secondary script when it is not found locally.
…Shell#7660)

The cmdlet syntax is as follows:
```
Join-String [[-Property] <pspropertyexpression>] [[-Separator] <string>] [-OutputPrefix <string>] [-OutputSuffix <string>] [-UseCulture] [-InputObject <psobject>] [<CommonParameters>]

Join-String [[-Property] <pspropertyexpression>] [[-Separator] <string>] [-OutputPrefix <string>] [-OutputSuffix <string>] [-SingleQuote] [-UseCulture] [-InputObject <psobject>] [<CommonParameters>]

Join-String [[-Property] <pspropertyexpression>] [[-Separator] <string>] [-OutputPrefix <string>] [-OutputSuffix <string>] [-DoubleQuote] [-UseCulture] [-InputObject <psobject>] [<CommonParameters>]

Join-String [[-Property] <pspropertyexpression>] [[-Separator] <string>] [-OutputPrefix <string>] [-OutputSuffix <string>] [-FormatString <string>] [-UseCulture] [-InputObject <psobject>] [<CommonParameters>]
```
…tforms (PowerShell#8232)

There a some differences in support of named pipes for Windows and non-Windows.  Named pipes on Unix have a 104 character path limit.  On macOS, the `$env:TMPDIR` (on my system) is already 49 characters; corefx adds 12 more.  Since AppDomainName isn't really used, changed it from `DefaultAppDomain` to `None` to shorten the name.  Need to keep it since Windows PowerShell expects it.  Changed `starttime` part of pipe name to 8 hex characters which is to provide uniqueness to the pipe name.
* Add 6.1.1 change log
* Add 6.0.5 change log
* Change filters for spelling CI
iSazonov and others added 21 commits November 29, 2018 09:18
Remove old code from AssemblyInfo.cs
Bumps System.Data.SqlClient from 4.5.1 to 4.6.0.
…ve (PowerShell#8287)

support being started by Windows Shell (Open Here) where a trailing slash followed by a quote is handled incorrectly
* CommonUtilities
* CredSSP
* WsManHelper.cs
* InternalHost
Enable building tar.gz package for Alpine in release builds.

## PR Checklist

- [x] [PR has a meaningful title](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
    - Use the present tense and imperative mood when describing your changes
- [x] [Summarized changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
- [x] [Change is not breaking](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#making-breaking-changes)
- [x] [Make sure all `.h`, `.cpp`, `.cs`, `.ps1` and `.psm1` files have the correct copyright header](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
- [x] This PR is ready to merge and is not [Work in Progress](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---work-in-progress).
    - If the PR is work in progress, please add the prefix `WIP:` to the beginning of the title and remove the prefix when the PR is ready.
- **User-facing changes**
    - [x] Not Applicable
    - **OR**
    - [ ] User-facing [Documentation needed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
        - [ ] Issue filed - Issue link:
- **Testing - New and feature**
    - [x] Not Applicable or can only be tested interactively
    - **OR**
    - [ ] [Make sure you've added a new test if existing tests do not effectively test the code changed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#before-submitting)
        - [ ] [Add `[feature]` if the change is significant or affects feature tests](https://github.com/PowerShell/PowerShell/blob/master/docs/testing-guidelines/testing-guidelines.md#requesting-additional-tests-for-a-pr)
…hell#8316)

Compare the PowerShell modules dependencies on PowerShell Gallery and sync them to AzDevOps artifacts feed if a newer is available. The release builds pick up modules from AzDevOps feed.
Remove unneeded dotnet restore

Add  --no-restore

Add extraParams for MacOS

Fix TestRunspaceWithPowerShellAndInitialSessionState

Fix race condition to access powershell.config.json

Reduce an impact of the inter process race condition

Fix race condition to access powershell.config.json (PowerShell#8249)
@iSazonov
Copy link
Collaborator Author

Close and open new PR #8356

@iSazonov iSazonov closed this Nov 29, 2018
@iSazonov iSazonov deleted the move-xunit-tests branch November 29, 2018 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Test Indicates that a PR should be marked as a test change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.