Avoid use of mkdir alias in *.ps1 and *.psm1 (#8582)

This commit is contained in:
xtqqczze
2019-01-04 14:31:24 +05:00
committed by Ilya
parent bb2440cdac
commit f0f301bc5e
5 changed files with 7 additions and 7 deletions
@@ -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)
@@ -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
@@ -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
@@ -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
}
@@ -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 = @'