Unit tests use xUnit runner and [Fact] declaration
- Workaround test executable is now completely removed - make test also depends on $(RUN_TARGETS)
This commit is contained in:
parent
b055743728
commit
694320b656
7 changed files with 18 additions and 37 deletions
|
@ -157,7 +157,9 @@ internal-prepare-exec_env: runps.sh $(POWERSHELL_RUN_TARGETS) dotnetlibs/corerun
|
||||||
cp -r ../ext-src/pester exec_env/app_base/Modules/Pester
|
cp -r ../ext-src/pester exec_env/app_base/Modules/Pester
|
||||||
cp runps.sh exec_env/app_base
|
cp runps.sh exec_env/app_base
|
||||||
|
|
||||||
run: $(POWERSHELL_RUN_TARGETS) dotnetlibs/corerun dotnetlibs/Microsoft.PowerShell.Commands.Management.dll dotnetlibs/Microsoft.PowerShell.Commands.Utility.dll dotnetlibs/Microsoft.PowerShell.Security.dll dotnetlibs/api-ms-win-core-registry-l1-1-0.dll internal-prepare-exec_env
|
RUN_TARGETS=$(POWERSHELL_RUN_TARGETS) dotnetlibs/corerun dotnetlibs/Microsoft.PowerShell.Commands.Management.dll dotnetlibs/Microsoft.PowerShell.Commands.Utility.dll dotnetlibs/Microsoft.PowerShell.Security.dll dotnetlibs/api-ms-win-core-registry-l1-1-0.dll
|
||||||
|
|
||||||
|
run: $(RUN_TARGETS) internal-prepare-exec_env
|
||||||
# check if corerun is the right one (could be the debug version)
|
# check if corerun is the right one (could be the debug version)
|
||||||
if ! diff dotnetlibs/corerun $(MONAD_EXT)/coreclr/Release/corerun; then cp -r $(MONAD_EXT)/coreclr/Release/* dotnetlibs; fi
|
if ! diff dotnetlibs/corerun $(MONAD_EXT)/coreclr/Release/corerun; then cp -r $(MONAD_EXT)/coreclr/Release/* dotnetlibs; fi
|
||||||
# execute a cmdlet, this will auto-load the utility module and print a, b and c in 3 lines
|
# execute a cmdlet, this will auto-load the utility module and print a, b and c in 3 lines
|
||||||
|
@ -179,7 +181,7 @@ pester-tests: $(POWERSHELL_RUN_TARGETS) dotnetlibs/corerun dotnetlibs/Microsoft.
|
||||||
# execute the pester tests, pester needs a TEMP environment variable to be set
|
# execute the pester tests, pester needs a TEMP environment variable to be set
|
||||||
cd exec_env/app_base && PSMODULEPATH=$(shell pwd)/exec_env/app_base/Modules LD_LIBRARY_PATH=. ./corerun powershell-simple.exe 'cd ../../../src/pester-tests; $$env:TEMP="/tmp"; invoke-pester'
|
cd exec_env/app_base && PSMODULEPATH=$(shell pwd)/exec_env/app_base/Modules LD_LIBRARY_PATH=. ./corerun powershell-simple.exe 'cd ../../../src/pester-tests; $$env:TEMP="/tmp"; invoke-pester'
|
||||||
|
|
||||||
test: internal-prepare-exec_env $(addprefix $(TESTRUN_FOLDER)/, ps_test.dll xunit.console.netcore.exe xunit.runner.utility.dll xunit.abstractions.dll xunit.execution.dll) dotnetlibs/corerun
|
test: $(RUN_TARGETS) internal-prepare-exec_env $(addprefix $(TESTRUN_FOLDER)/, ps_test.dll xunit.console.netcore.exe xunit.runner.utility.dll xunit.abstractions.dll xunit.execution.dll) dotnetlibs/corerun
|
||||||
cd exec_env/testrun && PSMODULEPATH=$(shell pwd)/exec_env/app_base/Modules LD_LIBRARY_PATH=../app_base ../app_base/corerun xunit.console.netcore.exe ps_test.dll
|
cd exec_env/testrun && PSMODULEPATH=$(shell pwd)/exec_env/app_base/Modules LD_LIBRARY_PATH=../app_base ../app_base/corerun xunit.console.netcore.exe ps_test.dll
|
||||||
|
|
||||||
# this is an internal target, it's not intended to be called manually
|
# this is an internal target, it's not intended to be called manually
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace PSTests
|
|
||||||
{
|
|
||||||
public static class TestRunner
|
|
||||||
{
|
|
||||||
// TODO: Replace with xUnit test runner
|
|
||||||
// - Add [Fact] attributes to test
|
|
||||||
// - Remove static keywords
|
|
||||||
static void Main()
|
|
||||||
{
|
|
||||||
PlatformTests.TestIsLinux();
|
|
||||||
PlatformTests.TestHasCom();
|
|
||||||
PlatformTests.TestHasAmsi();
|
|
||||||
PlatformTests.TestUsesCodeSignedAssemblies();
|
|
||||||
PlatformTests.TestHasDriveAutoMounting();
|
|
||||||
PlatformTests.TestHasRegistrySupport();
|
|
||||||
|
|
||||||
PSTypeExtensionsTests.TestIsComObject();
|
|
||||||
|
|
||||||
PSEnumerableBinderTests.TestIsComObject();
|
|
||||||
|
|
||||||
SecuritySupportTests.TestScanContent();
|
|
||||||
SecuritySupportTests.TestCurrentDomain_ProcessExit();
|
|
||||||
SecuritySupportTests.TestCloseSession();
|
|
||||||
SecuritySupportTests.TestUninitialize();
|
|
||||||
|
|
||||||
MshSnapinInfoTests mshSnapinInfoTests = new MshSnapinInfoTests();
|
|
||||||
mshSnapinInfoTests.TestReadRegistryInfo();
|
|
||||||
mshSnapinInfoTests.TestReadCoreEngineSnapIn();
|
|
||||||
|
|
||||||
Console.WriteLine("Finished running tests");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,6 +6,7 @@ namespace PSTests
|
||||||
{
|
{
|
||||||
public static class PSEnumerableBinderTests
|
public static class PSEnumerableBinderTests
|
||||||
{
|
{
|
||||||
|
[Fact]
|
||||||
public static void TestIsComObject()
|
public static void TestIsComObject()
|
||||||
{
|
{
|
||||||
// It just needs an arbitrary object
|
// It just needs an arbitrary object
|
||||||
|
|
|
@ -6,31 +6,37 @@ namespace PSTests
|
||||||
{
|
{
|
||||||
public static class PlatformTests
|
public static class PlatformTests
|
||||||
{
|
{
|
||||||
|
[Fact]
|
||||||
public static void TestIsLinux()
|
public static void TestIsLinux()
|
||||||
{
|
{
|
||||||
Assert.True(Platform.IsLinux());
|
Assert.True(Platform.IsLinux());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
public static void TestHasCom()
|
public static void TestHasCom()
|
||||||
{
|
{
|
||||||
Assert.False(Platform.HasCom());
|
Assert.False(Platform.HasCom());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
public static void TestHasAmsi()
|
public static void TestHasAmsi()
|
||||||
{
|
{
|
||||||
Assert.False(Platform.HasAmsi());
|
Assert.False(Platform.HasAmsi());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
public static void TestUsesCodeSignedAssemblies()
|
public static void TestUsesCodeSignedAssemblies()
|
||||||
{
|
{
|
||||||
Assert.False(Platform.UsesCodeSignedAssemblies());
|
Assert.False(Platform.UsesCodeSignedAssemblies());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
public static void TestHasDriveAutoMounting()
|
public static void TestHasDriveAutoMounting()
|
||||||
{
|
{
|
||||||
Assert.False(Platform.HasDriveAutoMounting());
|
Assert.False(Platform.HasDriveAutoMounting());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
public static void TestHasRegistrySupport()
|
public static void TestHasRegistrySupport()
|
||||||
{
|
{
|
||||||
Assert.False(Platform.HasRegistrySupport());
|
Assert.False(Platform.HasRegistrySupport());
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace PSTests
|
||||||
{
|
{
|
||||||
public static class PSTypeExtensionsTests
|
public static class PSTypeExtensionsTests
|
||||||
{
|
{
|
||||||
|
[Fact]
|
||||||
public static void TestIsComObject()
|
public static void TestIsComObject()
|
||||||
{
|
{
|
||||||
// It just needs an arbitrary type
|
// It just needs an arbitrary type
|
||||||
|
|
|
@ -8,6 +8,7 @@ namespace PSTests
|
||||||
public class MshSnapinInfoTests
|
public class MshSnapinInfoTests
|
||||||
{
|
{
|
||||||
// Test that it does not throw an exception
|
// Test that it does not throw an exception
|
||||||
|
[Fact]
|
||||||
public void TestReadRegistryInfo()
|
public void TestReadRegistryInfo()
|
||||||
{
|
{
|
||||||
Version someVersion = null;
|
Version someVersion = null;
|
||||||
|
@ -16,6 +17,7 @@ namespace PSTests
|
||||||
}
|
}
|
||||||
|
|
||||||
// PublicKeyToken is null on Linux
|
// PublicKeyToken is null on Linux
|
||||||
|
[Fact]
|
||||||
public void TestReadCoreEngineSnapIn()
|
public void TestReadCoreEngineSnapIn()
|
||||||
{
|
{
|
||||||
PSSnapInInfo pSSnapInInfo = PSSnapInReader.ReadCoreEngineSnapIn();
|
PSSnapInInfo pSSnapInInfo = PSSnapInReader.ReadCoreEngineSnapIn();
|
||||||
|
|
|
@ -6,21 +6,25 @@ namespace PSTests
|
||||||
{
|
{
|
||||||
public static class SecuritySupportTests
|
public static class SecuritySupportTests
|
||||||
{
|
{
|
||||||
|
[Fact]
|
||||||
public static void TestScanContent()
|
public static void TestScanContent()
|
||||||
{
|
{
|
||||||
Assert.Equal(AmsiUtils.ScanContent("", ""), AmsiUtils.AmsiNativeMethods.AMSI_RESULT.AMSI_RESULT_NOT_DETECTED);
|
Assert.Equal(AmsiUtils.ScanContent("", ""), AmsiUtils.AmsiNativeMethods.AMSI_RESULT.AMSI_RESULT_NOT_DETECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
public static void TestCurrentDomain_ProcessExit()
|
public static void TestCurrentDomain_ProcessExit()
|
||||||
{
|
{
|
||||||
AmsiUtils.CurrentDomain_ProcessExit(null, EventArgs.Empty);
|
AmsiUtils.CurrentDomain_ProcessExit(null, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
public static void TestCloseSession()
|
public static void TestCloseSession()
|
||||||
{
|
{
|
||||||
AmsiUtils.CloseSession();
|
AmsiUtils.CloseSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
public static void TestUninitialize()
|
public static void TestUninitialize()
|
||||||
{
|
{
|
||||||
AmsiUtils.Uninitialize();
|
AmsiUtils.Uninitialize();
|
||||||
|
|
Loading…
Reference in a new issue