mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fixing background jobs for Unix and Windows (#1972)
This commit is contained in:
committed by
Dongbo Wang
parent
594fae475b
commit
2077e42b52
@@ -36,8 +36,13 @@ namespace System.Management.Automation.Runspaces
|
||||
/// </summary>
|
||||
static PowerShellProcessInstance()
|
||||
{
|
||||
#if UNIX
|
||||
s_PSExePath = Path.Combine(Utils.GetApplicationBase(Utils.DefaultPowerShellShellID),
|
||||
"powershell");
|
||||
#else
|
||||
s_PSExePath = Path.Combine(Utils.GetApplicationBase(Utils.DefaultPowerShellShellID),
|
||||
"powershell.exe");
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -71,18 +76,22 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
}
|
||||
|
||||
string processArguments = string.Empty;
|
||||
#if CORECLR
|
||||
string processArguments = " -s -NoLogo -NoProfile";
|
||||
#else
|
||||
// Adding Version parameter to powershell.exe
|
||||
// Version parameter needs to go before all other parameters because the native layer looks for Version or
|
||||
// PSConsoleFile parameters before parsing other parameters.
|
||||
// The other parameters get parsed in the managed layer.
|
||||
Version tempVersion = powerShellVersion ?? PSVersionInfo.PSVersion;
|
||||
processArguments = string.Format(CultureInfo.InvariantCulture,
|
||||
string processArguments = string.Format(CultureInfo.InvariantCulture,
|
||||
"-Version {0}", new Version(tempVersion.Major, tempVersion.Minor));
|
||||
|
||||
processArguments = string.Format(CultureInfo.InvariantCulture,
|
||||
"{0} -s -NoLogo -NoProfile", processArguments);
|
||||
|
||||
#endif
|
||||
|
||||
if (initializationScript != null)
|
||||
{
|
||||
string scripBlockAsString = initializationScript.ToString();
|
||||
@@ -106,7 +115,9 @@ namespace System.Management.Automation.Runspaces
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
CreateNoWindow = true,
|
||||
#if !UNIX
|
||||
LoadUserProfile = true,
|
||||
#endif
|
||||
};
|
||||
|
||||
if (credential != null)
|
||||
|
||||
@@ -1196,7 +1196,11 @@ namespace System.Management.Automation.Internal
|
||||
/// </summary>
|
||||
internal PSRemotingCryptoHelperServer()
|
||||
{
|
||||
#if UNIX
|
||||
_rsaCryptoProvider = null;
|
||||
#else
|
||||
_rsaCryptoProvider = PSRSACryptoServiceProvider.GetRSACryptoServiceProviderForServer();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion Constructors
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
Describe 'Basic Job Tests' -Tags 'CI' {
|
||||
|
||||
BeforeAll {
|
||||
$job = Start-Job {1}
|
||||
}
|
||||
|
||||
It 'Test job creation' {
|
||||
$job | should not be $null
|
||||
}
|
||||
|
||||
It 'Test job State' {
|
||||
Wait-Job $job -Timeout 60
|
||||
$job.JobStateInfo.State -eq 'Completed' | should be $true
|
||||
}
|
||||
|
||||
It 'Job output test' {
|
||||
Receive-Job $job -wait | should be 1
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
Remove-Job $job -Force
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user