From e4df047464f0ec3fa8391b54434ea68ea5033823 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 5 Jun 2015 16:41:43 -0700 Subject: [PATCH] Use Xunit assertions * Update monad-ext submodule with Xunit dlls * Point Makefile xunit targets to monad-ext/xunit * Add xunit.assert target to Makefile * Add xunit.assert as dependency of ps_test.exe * Add corerun as dependency of ps_test.exe * Link ps_test.exe with xunit.assert * Temporarily remove libps.so from ps_test.exe dependencies (WIP) * Use Xunit in ps_test.cs * Remove Assert mock * Temporarily remove Platform.UserName (WIP) With this patch, `make cleanall && make prepare && make run-test` executes our (few) tests correctly using Xunit (without needing to `make run` first). --- scripts/Makefile | 15 +++++++++------ src/monad-ext | 2 +- src/ps_test/ps_test.cs | 15 +++------------ 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/scripts/Makefile b/scripts/Makefile index cc5c5c352..724d85397 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -109,19 +109,22 @@ dotnetlibs/ps_hello_world.exe: ../src/ps_hello_world/ps_hello_world.cs dotnetlib # testing c# stuff -dotnetlibs/xunit.core.dll: xunit.extensibility.core.2.0.0/lib/portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS/xunit.core.dll +dotnetlibs/xunit.core.dll: $(MONAD_EXT)/xunit/xunit.core.dll cp -f $^ $@ -dotnetlibs/xunit.abstractions.dll: xunit.abstractions.2.0.0/lib/portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS/xunit.abstractions.dll +dotnetlibs/xunit.abstractions.dll: $(MONAD_EXT)/xunit/xunit.abstractions.dll cp -f $^ $@ -dotnetlibs/xunit.console.exe: xunit.runner.console.2.0.0/tools/xunit.console.exe +dotnetlibs/xunit.assert.dll: $(MONAD_EXT)/xunit/xunit.assert.dll cp -f $^ $@ -dotnetlibs/ps_test.exe: ../src/ps_test/ps_test.cs dotnetlibs/System.Management.Automation.dll dotnetlibs/Microsoft.PowerShell.Commands.Management.dll dotnetlibs/$(ASSEMBLY_LOAD_CONTEXT_TARGET) - mcs -out:$@ -noconfig -nostdlib -target:exe -r:dotnetlibs/System.Management.Automation.dll -r:dotnetlibs/$(ASSEMBLY_LOAD_CONTEXT_TARGET) -r:dotnetlibs/xunit.core.dll ${COREREF} ../src/ps_test/ps_test.cs +dotnetlibs/xunit.console.exe: $(MONAD_EXT)/xunit/xunit.console.netcore.exe + cp -f $^ $@ -run-test: dotnetlibs/ps_test.exe dotnetlibs/libps.so +dotnetlibs/ps_test.exe: ../src/ps_test/ps_test.cs dotnetlibs/System.Management.Automation.dll dotnetlibs/Microsoft.PowerShell.Commands.Management.dll dotnetlibs/$(ASSEMBLY_LOAD_CONTEXT_TARGET) dotnetlibs/xunit.core.dll dotnetlibs/xunit.assert.dll + mcs -out:$@ -noconfig -nostdlib -target:exe -r:dotnetlibs/System.Management.Automation.dll -r:dotnetlibs/$(ASSEMBLY_LOAD_CONTEXT_TARGET) -r:dotnetlibs/xunit.core.dll -r:dotnetlibs/xunit.assert.dll ${COREREF} ../src/ps_test/ps_test.cs + +run-test: dotnetlibs/ps_test.exe dotnetlibs/corerun cd dotnetlibs && LD_LIBRARY_PATH=. ./corerun ps_test.exe # the pinvoke library libps.so diff --git a/src/monad-ext b/src/monad-ext index 2c42c8857..fd4beee8d 160000 --- a/src/monad-ext +++ b/src/monad-ext @@ -1 +1 @@ -Subproject commit 2c42c8857118c1baad328b77ea4da735efbe8ecb +Subproject commit fd4beee8d70dba4e97a79fd74b975c6118f0968a diff --git a/src/ps_test/ps_test.cs b/src/ps_test/ps_test.cs index 22ac96420..9789462f6 100644 --- a/src/ps_test/ps_test.cs +++ b/src/ps_test/ps_test.cs @@ -1,18 +1,8 @@ -//using Xunit; +using Xunit; using System; namespace PSTests { - public static class Assert - { - public static void Equal(T a, T b) where T : System.IComparable - { - if (a.CompareTo(b) != 0) - throw new Exception("Assert failed: a == b (" + a.ToString() + " == " + b.ToString()); - Console.WriteLine("Assert.Equal OK"); - } - } - public class BlahTests { @@ -25,7 +15,8 @@ namespace PSTests public static void testPlatform() { Assert.Equal(System.Management.Automation.Platform.IsLinux(),true); - Assert.Equal(System.Management.Automation.Platform.UserName,"peter2"); + // UserName not yet implemented + // Assert.Equal(System.Management.Automation.Platform.UserName,"peter2"); } static void Main(string[] args)