Skip to content

Commit de947cc

Browse files
committed
Added Test-JitOptimized cmldet
1 parent 3f1790b commit de947cc

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function Test-JitOptimized {
2+
[cmdletbinding()]
3+
param (
4+
[string]$dllPath
5+
)
6+
$dll = [System.Reflection.Assembly]::LoadFile($dllPath)
7+
$type = [System.Type]::GetType("System.Diagnostics.DebuggableAttribute")
8+
$debugAttribute = $dll.GetCustomAttributes($type, $false)
9+
-not $debugAttribute.IsJITOptimizerDisabled
10+
}

Tests/DLLInfo.Tests.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
Clear-Host
12
if (-not $PSScriptRoot) {
23
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
34
}
@@ -29,6 +30,37 @@ Describe 'Get-BuildConfiguration' {
2930
Get-BuildConfiguration $Assembly
3031
}
3132

33+
$Job = Start-Job $RunAs32Bit -RunAs32 -Arg $Assembly
34+
$Job | Wait-Job | Receive-Job | Should -Be $Expected
35+
}
36+
}
37+
}
38+
39+
Describe 'Test-JitOptimized' {
40+
Context "Check test DLLs - x64" {
41+
It "Given valid -Assembly '<Assembly>', it returns <Expected>" -TestCases @(
42+
@{ Assembly = "$PSScriptRoot\bin\Debug\AssemblyInfoTest.dll"; Expected = $false }
43+
@{ Assembly = "$PSScriptRoot\bin\Release\AssemblyInfoTest.dll"; Expected = $true }
44+
@{ Assembly = "$PSScriptRoot\bin\x64\Debug\AssemblyInfoTest.dll"; Expected = $false }
45+
@{ Assembly = "$PSScriptRoot\bin\x64\Release\AssemblyInfoTest.dll"; Expected = $true }
46+
) {
47+
param ($Assembly, $Expected)
48+
Test-JitOptimized $Assembly | Should -Be $Expected
49+
}
50+
}
51+
52+
Context "Check test DLLs - x86" {
53+
It "Given valid -Assembly '<Assembly>', it returns <Expected>" -TestCases @(
54+
@{ Assembly = "$PSScriptRoot\bin\x86\Debug\AssemblyInfoTest.dll"; Expected = $false }
55+
@{ Assembly = "$PSScriptRoot\bin\x86\Release\AssemblyInfoTest.dll"; Expected = $true }
56+
) {
57+
param ($Assembly, $Expected)
58+
$RunAs32Bit = {
59+
param($Assembly)
60+
Import-Module .\DLLInfo\DLLInfo.psm1 -Force
61+
Test-JitOptimized $Assembly
62+
}
63+
3264
$Job = Start-Job $RunAs32Bit -RunAs32 -Arg $Assembly
3365
$Job | Wait-Job | Receive-Job | Should -Be $Expected
3466
}

0 commit comments

Comments
 (0)