From f0f301bc5e2f97c76382eae18bf4228581bd7389 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Fri, 4 Jan 2019 09:31:24 +0000 Subject: [PATCH] Avoid use of mkdir alias in *.ps1 and *.psm1 (#8582) --- src/Modules/Windows/PSDiagnostics/PSDiagnostics.psm1 | 2 +- .../Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 | 4 ++-- .../Scripting/Debugging/DebuggerScriptTests.Tests.ps1 | 2 +- .../ConstrainedLanguageModules.Tests.ps1 | 2 +- .../ConstrainedLanguageRestriction.Tests.ps1 | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Modules/Windows/PSDiagnostics/PSDiagnostics.psm1 b/src/Modules/Windows/PSDiagnostics/PSDiagnostics.psm1 index 444eebe8a5..53286a970e 100644 --- a/src/Modules/Windows/PSDiagnostics/PSDiagnostics.psm1 +++ b/src/Modules/Windows/PSDiagnostics/PSDiagnostics.psm1 @@ -182,7 +182,7 @@ function Enable-PSWSManCombinedTrace if (!(Test-Path $pshome\Traces)) { - mkdir -Force $pshome\Traces | out-null + New-Item -ItemType Directory -Force $pshome\Traces | out-null } if (Test-Path $logfile) diff --git a/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 b/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 index c21fe45a92..f71dd136b9 100644 --- a/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 +++ b/test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 @@ -301,8 +301,8 @@ Describe 'Negative Parsing Tests' -Tags "CI" { ShouldBeParseError 'class C { [int]foo() { try { throw "foo"} catch [ArgumentException] {} catch {throw $_} } }' MethodHasCodePathNotReturn 15 ShouldBeParseError 'class C { [int]foo() { try { throw "foo"} catch [ArgumentException] {return 1} catch {} } }' MethodHasCodePathNotReturn 15 ShouldBeParseError 'class C { [int]foo() { while ($false) { return 1 } } }' MethodHasCodePathNotReturn 15 - ShouldBeParseError 'class C { [int]foo() { try { mkdir foo } finally { rm -rec foo } } }' MethodHasCodePathNotReturn 15 - ShouldBeParseError 'class C { [int]foo() { try { mkdir foo; return 1 } catch { } } }' MethodHasCodePathNotReturn 15 + ShouldBeParseError 'class C { [int]foo() { try { New-Item -ItemType Directory foo } finally { rm -rec foo } } }' MethodHasCodePathNotReturn 15 + ShouldBeParseError 'class C { [int]foo() { try { New-Item -ItemType Directory foo; return 1 } catch { } } }' MethodHasCodePathNotReturn 15 ShouldBeParseError 'class C { [bool] Test() { if ($false) { return $true; } } }' MethodHasCodePathNotReturn 17 ShouldBeParseError 'class C { [int]$i; [void] foo() {$i = 10} }' MissingThis 33 diff --git a/test/powershell/Language/Scripting/Debugging/DebuggerScriptTests.Tests.ps1 b/test/powershell/Language/Scripting/Debugging/DebuggerScriptTests.Tests.ps1 index 08b94bb997..d4edf44bba 100644 --- a/test/powershell/Language/Scripting/Debugging/DebuggerScriptTests.Tests.ps1 +++ b/test/powershell/Language/Scripting/Debugging/DebuggerScriptTests.Tests.ps1 @@ -498,7 +498,7 @@ Describe "Unit tests for line breakpoints on modules" -Tags "CI" { $moduleDirectory = [io.path]::Combine($moduleRoot, $moduleName) $moduleFile = [io.path]::Combine($moduleDirectory, $moduleName + ".psm1") - mkdir $moduleDirectory 2> $null + New-Item -ItemType Directory $moduleDirectory 2> $null write-output ' function ModuleFunction1 diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageModules.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageModules.Tests.ps1 index c9a7bfa575..2bb4c7c160 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageModules.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageModules.Tests.ps1 @@ -41,7 +41,7 @@ try $modulePathName = "modulePath_$(Get-Random -Max 9999)" $modulePath = Join-Path $testdrive $modulePathName - mkdir $modulePath + New-Item -ItemType Directory $modulePath $trustedModuleFile = Join-Path $modulePath "T1TestModule_System32.psm1" $script | Out-File -FilePath $trustedModuleFile } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 index d042c8528f..7257a4ab46 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 @@ -27,13 +27,13 @@ try $trustedModuleName1 = "TrustedModule$(Get-Random -Max 999)_System32" $trustedModulePath1 = Join-Path $TestDrive $trustedModuleName1 - mkdir $trustedModulePath1 + New-Item -ItemType Directory $trustedModulePath1 $trustedModuleFilePath1 = Join-Path $trustedModulePath1 ($trustedModuleName1 + ".psm1") $trustedModuleManifestPath1 = Join-Path $trustedModulePath1 ($trustedModuleName1 + ".psd1") $trustedModuleName2 = "TrustedModule$(Get-Random -Max 999)_System32" $trustedModulePath2 = Join-Path $TestDrive $trustedModuleName2 - mkdir $trustedModulePath2 + New-Item -ItemType Directory $trustedModulePath2 $trustedModuleFilePath2 = Join-Path $trustedModulePath2 ($trustedModuleName2 + ".psm1") $trustedModuleScript1 = @'