Skip to content
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

Experimental Feature to add Temp: drive #8696

Merged
merged 1 commit into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[feature] experimental feature for temp drive
  • Loading branch information
SteveL-MSFT committed Jan 19, 2019
commit ec3a4fc430feb084ee112bc95aa885a78cdab76b
5 changes: 5 additions & 0 deletions src/System.Management.Automation/engine/DriveNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,10 @@ internal static class DriveNames
/// The default FunctionProvider drive name.
/// </summary>
internal const string FunctionDrive = "Function";

/// <summary>
/// The Temp drive name.
/// </summary>
internal const string TempDrive = "Temp";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,27 @@ static ExperimentalFeature()
// Initialize the readonly collection 'EngineExperimentalFeatures'.
var engineFeatures = new ExperimentalFeature[] {
/* Register engine experimental features here. Follow the same pattern as the example:
new ExperimentalFeature(name: "PSFileSystemProviderV2",
description: "Replace the old FileSystemProvider with cleaner design and faster code",
source: EngineSource,
isEnabled: false),
new ExperimentalFeature(
name: "PSFileSystemProviderV2",
description: "Replace the old FileSystemProvider with cleaner design and faster code",
source: EngineSource,
isEnabled: false),
*/
new ExperimentalFeature(name: "PSImplicitRemotingBatching",
description: "Batch implicit remoting proxy commands to improve performance",
source: EngineSource,
isEnabled: false),
new ExperimentalFeature(name: "PSUseAbbreviationExpansion",
description: "Allow tab completion of cmdlets and functions by abbreviation",
source: EngineSource,
isEnabled: false),
new ExperimentalFeature(
name: "PSImplicitRemotingBatching",
description: "Batch implicit remoting proxy commands to improve performance",
source: EngineSource,
isEnabled: false),
new ExperimentalFeature(
name: "PSUseAbbreviationExpansion",
description: "Allow tab completion of cmdlets and functions by abbreviation",
source: EngineSource,
isEnabled: false),
new ExperimentalFeature(
name: "PSTempDrive",
description: "Create TEMP: PS Drive mapped to user's temporary directory path",
source: EngineSource,
isEnabled: false),
};
EngineExperimentalFeatures = new ReadOnlyCollection<ExperimentalFeature>(engineFeatures);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,19 @@ protected override Collection<PSDriveInfo> InitializeDefaultDrives()
}
}

if (ExperimentalFeature.IsEnabled("PSTempDrive"))
{
PSDriveInfo newPSDriveInfo =
new PSDriveInfo(
DriveNames.TempDrive,
ProviderInfo,
Path.GetTempPath(),
SessionStateStrings.TempDriveDescription,
credential: null,
displayRoot: null);
results.Add(newPSDriveInfo);
}

return results;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,9 @@
<data name="VariableDriveDescription" xml:space="preserve">
<value>Drive that contains a view of those variables stored in a session state</value>
</data>
<data name="TempDriveDescription" xml:space="preserve">
<value>Drive that maps to the temporary directory path for the current user</value>
</data>
<data name="ProviderProviderPathFormatException" xml:space="preserve">
<value>The path is not in the correct format. Paths can contain only provider and drive names separated by slashes or backslashes.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,27 @@ Describe "Get-PSDrive" -Tags "CI" {
$dInfo.Used -ge 0 | Should -BeTrue
}
}

Describe "Experimental Feature Temp: drive" -Tag Feature {
BeforeAll {
$configFilePath = Join-Path $testdrive "experimentalfeature.json"

@"
{
"ExperimentalFeatures": [
"PSTempDrive"
]
}
"@ > $configFilePath
}

It "TEMP: drive exists if experimental feature is enabled" {
$res = pwsh -outputformat xml -settingsfile $configFilePath -command "Get-PSDrive Temp"
$res.Name | Should -BeExactly "Temp"
$res.Root | Should -BeExactly ([System.IO.Path]::GetTempPath())
}

It "TEMP: drive does not exist if experimental feature is not enabled" {
{ Get-PSDrive Temp -ErrorAction Stop } | Should -Throw -ErrorId "GetLocationNoMatchingDrive,Microsoft.PowerShell.Commands.GetPSDriveCommand"
}
}