From af1343472d406e6d949aa56326aea9e0012bc328 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Wed, 23 Dec 2015 12:29:08 -0800 Subject: [PATCH] Fix up Get-OmiInstance build and tests Deploying module is a bit funky until dotnet-cli gives us more control over which libraries to build and where. Theoretically we'll be able to package System.Management.Automation and depend on the package instead, so Commands.Omi can be its own project entirely. Cleaned up the Commands.Omi project.json as it had some unnecessary cruft from where it was copied. Also removed the AssemblyInfo as it does not matter for a new module. Moved the Get-OmiInstance Pester test to the project's test folder so it doesn't run with our suite of tests (as it takes a dependency on OMI). --- build.sh | 11 ++++----- .../AssemblyInfo.cs | 4 ---- .../project.json | 23 +++++-------------- .../test/Get-OmiInstance.Tests.ps1 | 18 +++++++++++++++ .../project.json | 8 ++----- src/pester-tests/Get-OmiInstance.Tests.ps1 | 12 ---------- 6 files changed, 30 insertions(+), 46 deletions(-) delete mode 100644 src/Microsoft.PowerShell.Commands.Omi/AssemblyInfo.cs create mode 100644 src/Microsoft.PowerShell.Commands.Omi/test/Get-OmiInstance.Tests.ps1 delete mode 100644 src/pester-tests/Get-OmiInstance.Tests.ps1 diff --git a/build.sh b/build.sh index 466a8f14f8..819f0f1d12 100755 --- a/build.sh +++ b/build.sh @@ -2,13 +2,16 @@ export BIN=$(pwd)/bin -mkdir -p $BIN/Modules/Microsoft.PowerShell.Commands.Omi +mkdir -p $BIN/Modules # Deploy PowerShell modules ( cd $BIN/Modules ln -sf ../../ext-src/pester Pester ln -sf ../../src/monad/monad/miscfiles/modules/Microsoft.PowerShell.Utility . + OMI=Microsoft.PowerShell.Commands.Omi + mkdir -p $OMI + ln -sf $BIN/$OMI.dll $OMI/ ) # Build native components @@ -55,9 +58,3 @@ mkdir -p $BIN/Modules/Microsoft.PowerShell.Commands.Omi ln -sf ../src/monad/monad/miscfiles/display/Registry.format.ps1xml . ln -sf ../src/monad/monad/miscfiles/display/WSMan.format.ps1xml . ) - -# Set up Microsoft.PowerShell.Commands.Omi Module -{ - cd $BIN/Modules/Microsoft.PowerShell.Commands.Omi - ln -sf ../../Microsoft.PowerShell.Commands.Omi.dll . -} diff --git a/src/Microsoft.PowerShell.Commands.Omi/AssemblyInfo.cs b/src/Microsoft.PowerShell.Commands.Omi/AssemblyInfo.cs deleted file mode 100644 index e55ec824d4..0000000000 --- a/src/Microsoft.PowerShell.Commands.Omi/AssemblyInfo.cs +++ /dev/null @@ -1,4 +0,0 @@ -using System.Reflection; - -[assembly:AssemblyFileVersionAttribute("3.0.0.0")] -[assembly:AssemblyVersion("3.0.0.0")] diff --git a/src/Microsoft.PowerShell.Commands.Omi/project.json b/src/Microsoft.PowerShell.Commands.Omi/project.json index a948fcac17..90751a5a6e 100644 --- a/src/Microsoft.PowerShell.Commands.Omi/project.json +++ b/src/Microsoft.PowerShell.Commands.Omi/project.json @@ -1,28 +1,17 @@ { "version": "1.0.0-*", "description": "Microsoft.PowerShell.Commands.Omi Library", - "authors": [ "George Fleming" ], - - "compilationOptions": { - "define": [ - "CORECLR", - "_CORECLR", - "LINUX" - ], - "allowUnsafe": true - }, + "authors": [ "George Fleming", "andschwa" ], "dependencies": { - "NETStandard.Library": "1.0.0-rc2-23616", + "NETStandard.Library": "1.0.0-rc2-23616", + "System.Xml.XDocument": "4.0.11-rc2-23616", + "System.Runtime.InteropServices": "4.0.21-rc2-23616", "System.Management.Automation": { "type": "build", "version": "1.0.0-*" - }, - "System.Xml.XDocument": "4.0.11-rc2-23616", - "System.Runtime.InteropServices": "4.0.21-rc2-23616", + } }, - "frameworks": { "dnxcore50": { } }, - - "compile": [ "../monad-build/gen/COMMANDS_OMI/*.cs" ], + "frameworks": { "dnxcore50": { } } } diff --git a/src/Microsoft.PowerShell.Commands.Omi/test/Get-OmiInstance.Tests.ps1 b/src/Microsoft.PowerShell.Commands.Omi/test/Get-OmiInstance.Tests.ps1 new file mode 100644 index 0000000000..3665ab62c9 --- /dev/null +++ b/src/Microsoft.PowerShell.Commands.Omi/test/Get-OmiInstance.Tests.ps1 @@ -0,0 +1,18 @@ +# Note that omicli must be in PATH and omiserver should be started with +# --ignoreAuthentication option + +Describe "Get-OmiInstance" { + Import-Module Microsoft.PowerShell.Commands.Omi + + It "Should execute basic command correctly" { + $instance = Get-OmiInstance -NameSpace root/omi -ClassName OMI_Identify + + # This test is a workaround + $instance.Value.Contains("OMI") | Should Be $true + + # TODO: test these when available + #$instance.ProductName | Should Be "OMI" + #$instance.ProductVendor | Should Be "Microsoft" + #$instance.OperatingSystem | Should Be "LINUX" + } +} diff --git a/src/Microsoft.PowerShell.Linux.Host/project.json b/src/Microsoft.PowerShell.Linux.Host/project.json index 67592702c2..893fd5375b 100644 --- a/src/Microsoft.PowerShell.Linux.Host/project.json +++ b/src/Microsoft.PowerShell.Linux.Host/project.json @@ -10,7 +10,7 @@ "dependencies": { "NETStandard.Library": "1.0.0-rc2-23616", "Newtonsoft.Json": "8.0.1-beta3", - "Microsoft.PowerShell.Commands.Utility": { + "Microsoft.PowerShell.Commands.Management": { "type": "build", "version": "1.0.0-*" }, @@ -18,15 +18,11 @@ "type": "build", "version": "1.0.0-*" }, - "Microsoft.PowerShell.Commands.Management": { + "Microsoft.PowerShell.Commands.Utility": { "type": "build", "version": "1.0.0-*" } }, - "commands": { - "powershell": "Microsoft.PowerShell.Linux.Host" - }, - "frameworks": { "dnxcore50": { } } } diff --git a/src/pester-tests/Get-OmiInstance.Tests.ps1 b/src/pester-tests/Get-OmiInstance.Tests.ps1 deleted file mode 100644 index cb0d5efe41..0000000000 --- a/src/pester-tests/Get-OmiInstance.Tests.ps1 +++ /dev/null @@ -1,12 +0,0 @@ -# Note that omicli must be in PATH and omiserver should be started with -# --ignoreAuthentication option - -Describe "Get-OmiInstance" { - Import-Module Microsoft.PowerShell.Commands.Omi - - It "Should execute basic command correctly" { - $obj = Get-OmiInstance -NameSpace root/omi -ClassName OMI_Identify - - $obj.Length | Should Be 27 - } -} \ No newline at end of file