merging upstream changes from the develop branch
Merge branch 'develop' of mshttps://msostc.visualstudio.com/DefaultCollection/PS/_git/monad-linux into dev/158-ishardlink-xunit
This commit is contained in:
commit
e2f929c85e
|
@ -41,16 +41,16 @@ MI_REF_ASSEMBLY=-r:$(MONAD_EXT)/PS/PS_refs_modil/microsoft.management.infrastruc
|
|||
MI_ASSEMBLY=dotnetlibs/Microsoft.Management.Infrastructure.dll
|
||||
MI_REF=-r:$(MI_ASSEMBLY)
|
||||
|
||||
PRODUCT_BASE_REFS=${COREREF}
|
||||
PRODUCT_MI_REFS=${COREREF} ${MI_NATIVE_REF}
|
||||
PRODUCT_PS_REFS=${COREREF} ${MI_REF} -r:dotnetlibs/$(ASSEMBLY_LOAD_CONTEXT_TARGET)
|
||||
PRODUCT_COMMANDS_REFS=${COREREF} -r:dotnetlibs/System.Management.Automation.dll
|
||||
PRODUCT_BASE_REFS=$(COREREF)
|
||||
PRODUCT_MI_REFS=$(COREREF) $(MI_NATIVE_REF)
|
||||
PRODUCT_PS_REFS=$(COREREF) $(MI_REF) -r:dotnetlibs/$(ASSEMBLY_LOAD_CONTEXT_TARGET)
|
||||
PRODUCT_COMMANDS_REFS=$(COREREF) -r:dotnetlibs/System.Management.Automation.dll
|
||||
|
||||
MCSOPTS_BASE=-unsafe -nostdlib -noconfig -define:CORECLR -define:_CORECLR
|
||||
MCSOPTS_MI=${MCSOPTS_BASE} -target:library
|
||||
MCSOPTS_LIB=${MCSOPTS_BASE} -target:library
|
||||
MCSOPTS_PS=${STRING_RESOURCES_ORIG} ${MCSOPTS_BASE} -target:library
|
||||
SRCS_ALL=${STRING_RESOURCES} ${SRCS}
|
||||
MCSOPTS_MI=$(MCSOPTS_BASE) -target:library
|
||||
MCSOPTS_LIB=$(MCSOPTS_BASE) -target:library
|
||||
MCSOPTS_PS=$(STRING_RESOURCES_ORIG) $(MCSOPTS_BASE) -target:library
|
||||
SRCS_ALL=$(STRING_RESOURCES) $(SRCS)
|
||||
|
||||
# compilers
|
||||
# - Roslyn's csc is used for all the PS code
|
||||
|
@ -63,28 +63,28 @@ RUN_TARGETS=$(POWERSHELL_RUN_TARGETS) dotnetlibs/Microsoft.PowerShell.Commands.M
|
|||
all: dotnetlibs/System.Management.Automation.dll $(RUN_TARGETS) dotnetlibs/$(ASSEMBLY_LOAD_CONTEXT_TARGET)
|
||||
|
||||
# this is the build rule for SMA.dll
|
||||
dotnetlibs/System.Management.Automation.dll: ${SYS_AUTO_SRCS} dotnetlibs/Microsoft.Management.Infrastructure.dll ../src/assembly-info/System.Management.Automation.assembly-info.cs dotnetlibs/$(ASSEMBLY_LOAD_CONTEXT_TARGET) $(PLATFORM_SRCS) ${SYS_AUTO_RES_SRCS} ${SYS_AUTO_RES_CS_SRCS}
|
||||
$(CSC) -out:$@ ${MCSOPTS_LIB} ${PRODUCT_PS_REFS} ${SYS_AUTO_SRCS} ${SYS_AUTO_RES_REF} ${SYS_AUTO_RES_CS_SRCS} $(PLATFORM_SRCS) ../src/assembly-info/System.Management.Automation.assembly-info.cs
|
||||
dotnetlibs/System.Management.Automation.dll: $(SYS_AUTO_SRCS) dotnetlibs/Microsoft.Management.Infrastructure.dll ../src/assembly-info/System.Management.Automation.assembly-info.cs dotnetlibs/$(ASSEMBLY_LOAD_CONTEXT_TARGET) $(PLATFORM_SRCS) $(SYS_AUTO_RES_SRCS) $(SYS_AUTO_RES_CS_SRCS)
|
||||
$(CSC) -out:$@ $(MCSOPTS_LIB) $(PRODUCT_PS_REFS) $(SYS_AUTO_SRCS) $(SYS_AUTO_RES_REF) $(SYS_AUTO_RES_CS_SRCS) $(PLATFORM_SRCS) ../src/assembly-info/System.Management.Automation.assembly-info.cs
|
||||
|
||||
# this is the build rule for MMI.dll
|
||||
dotnetlibs/Microsoft.Management.Infrastructure.dll: ${MAN_INFRA_SRCS} dotnetlibs/Microsoft.Management.Infrastructure.Native.dll ../src/assembly-info/Microsoft.Management.Infrastructure.assembly-info.cs $(MAN_INFRA_RES_SRCS) $(MAN_INFRA_RES_CS_SRCS)
|
||||
dotnetlibs/Microsoft.Management.Infrastructure.dll: $(MAN_INFRA_SRCS) dotnetlibs/Microsoft.Management.Infrastructure.Native.dll ../src/assembly-info/Microsoft.Management.Infrastructure.assembly-info.cs $(MAN_INFRA_RES_SRCS) $(MAN_INFRA_RES_CS_SRCS)
|
||||
$(CSC) -out:$@ $(MCSOPTS_MI) $(PRODUCT_MI_REFS) $(MAN_INFRA_SRCS) $(MAN_INFRA_RES_REF) $(MAN_INFRA_RES_CS_SRCS) ../src/assembly-info/Microsoft.Management.Infrastructure.assembly-info.cs
|
||||
|
||||
# Commands
|
||||
|
||||
dotnetlibs/Microsoft.PowerShell.Commands.Management.dll: ${COMMANDS_MANAGEMENT_SRCS} dotnetlibs/System.Management.Automation.dll ${COMMANDS_MANAGEMENT_RES_SRCS} ${COMMANDS_MANAGEMENT_RES_CS_SRCS} $(MI_ASSEMBLY)
|
||||
$(CSC) -out:$@ ${MCSOPTS_LIB} ${PRODUCT_COMMANDS_REFS} ${COMMANDS_MANAGEMENT_SRCS} ${COMMANDS_MANAGEMENT_RES_CS_SRCS} $(COMMANDS_MANAGEMENT_RES_REF) $(MI_REF)
|
||||
dotnetlibs/Microsoft.PowerShell.Commands.Management.dll: $(COMMANDS_MANAGEMENT_SRCS) dotnetlibs/System.Management.Automation.dll dotnetlibs/Microsoft.PowerShell.Security.dll $(COMMANDS_MANAGEMENT_RES_SRCS) $(COMMANDS_MANAGEMENT_RES_CS_SRCS) $(MI_ASSEMBLY)
|
||||
$(CSC) -out:$@ $(MCSOPTS_LIB) $(PRODUCT_COMMANDS_REFS) $(COMMANDS_MANAGEMENT_SRCS) $(COMMANDS_MANAGEMENT_RES_CS_SRCS) $(COMMANDS_MANAGEMENT_RES_REF) $(MI_REF) -r:dotnetlibs/Microsoft.PowerShell.Security.dll
|
||||
|
||||
dotnetlibs/Microsoft.PowerShell.Commands.Utility.dll: ${COMMANDS_UTILITY_SRCS} dotnetlibs/System.Management.Automation.dll ${COMMANDS_UTILITY_RES_SRCS} ${COMMANDS_UTILITY_RES_CS_SRCS}
|
||||
$(CSC) -out:$@ ${MCSOPTS_LIB} ${PRODUCT_COMMANDS_REFS} ${COMMANDS_UTILITY_SRCS} ${COMMANDS_UTILITY_RES_CS_SRCS} $(COMMANDS_UTILITY_RES_REF)
|
||||
dotnetlibs/Microsoft.PowerShell.Commands.Utility.dll: $(COMMANDS_UTILITY_SRCS) dotnetlibs/System.Management.Automation.dll $(COMMANDS_UTILITY_RES_SRCS) $(COMMANDS_UTILITY_RES_CS_SRCS)
|
||||
$(CSC) -out:$@ $(MCSOPTS_LIB) $(PRODUCT_COMMANDS_REFS) $(COMMANDS_UTILITY_SRCS) $(COMMANDS_UTILITY_RES_CS_SRCS) $(COMMANDS_UTILITY_RES_REF)
|
||||
|
||||
dotnetlibs/Microsoft.PowerShell.Security.dll: ${SECURITY_SRCS} dotnetlibs/System.Management.Automation.dll ${SECURITY_RES_SRCS} ${SECURITY_RES_CS_SRCS}
|
||||
$(CSC) -out:$@ ${MCSOPTS_LIB} ${PRODUCT_COMMANDS_REFS} ${SECURITY_SRCS} ${SECURITY_RES_CS_SRCS} $(SECURITY_RES_REF)
|
||||
dotnetlibs/Microsoft.PowerShell.Security.dll: $(SECURITY_SRCS) $(SECURITY_RES_SRCS) $(SECURITY_RES_CS_SRCS)
|
||||
$(CSC) -out:$@ $(MCSOPTS_LIB) $(PRODUCT_COMMANDS_REFS) $(SECURITY_SRCS) $(SECURITY_RES_CS_SRCS) $(SECURITY_RES_REF)
|
||||
|
||||
# assembly load context
|
||||
|
||||
dotnetlibs/$(ASSEMBLY_LOAD_CONTEXT_TARGET): $(ASSEMBLY_LOAD_CONTEXT_SRCS)
|
||||
$(CSC) -out:$@ ${MCSOPTS_LIB} ${PRODUCT_BASE_REFS} $(ASSEMBLY_LOAD_CONTEXT_SRCS)
|
||||
$(CSC) -out:$@ $(MCSOPTS_LIB) $(PRODUCT_BASE_REFS) $(ASSEMBLY_LOAD_CONTEXT_SRCS)
|
||||
|
||||
# this will copy whatever the first version of the dll in the globber is
|
||||
buildtemp/System.Reflection.Metadata.dll: buildtemp/System.Reflection.Metadata.*/lib/portable-net45+win8/System.Reflection.Metadata.dll
|
||||
|
@ -101,7 +101,7 @@ dotnetlibs/Microsoft.Management.Infrastructure.Native.dll: ../src/stubs/Microsof
|
|||
MPATH=/usr/lib/mono/4.5/Facades
|
||||
|
||||
buildtemp/TypeCatalogGen.exe: ../src/monad/monad/nttargets/assemblies/core/PSAssemblyLoadContext/TypeCatalogGen/TypeCatalogGen.cs buildtemp/System.Reflection.Metadata.dll buildtemp/System.Collections.Immutable.dll
|
||||
$(MCS) -out:$@ -target:exe ${NUGETREF} -pkg:dotnet -r:${MPATH}/System.Runtime.dll -r:${MPATH}/System.Reflection.Primitives.dll -r:${MPATH}/System.IO.dll $<
|
||||
$(MCS) -out:$@ -target:exe $(NUGETREF) -pkg:dotnet -r:$(MPATH)/System.Runtime.dll -r:$(MPATH)/System.Reflection.Primitives.dll -r:$(MPATH)/System.IO.dll $<
|
||||
|
||||
# generate the Core PS type catalog
|
||||
# this comes from: ../src/monad/monad/nttargets/assemblies/core/PSAssemblyLoadContext/makefile.inc
|
||||
|
@ -194,7 +194,7 @@ native-tests: dotnetlibs/monad_native
|
|||
|
||||
xunit-tests: $(RUN_TARGETS) internal-prepare-exec_env internal-prepare-release-clr $(addprefix $(TESTRUN_FOLDER)/, ps_test.dll xunit.console.netcore.exe xunit.runner.utility.dll xunit.abstractions.dll xunit.execution.dll)
|
||||
# execute the xUnit runner, with XML output
|
||||
cd exec_env/app_base && PSMODULEPATH=$(shell pwd)/exec_env/app_base/Modules LD_LIBRARY_PATH=../coreclr:. ../coreclr/corerun xunit.console.netcore.exe ps_test.dll -xml ../../xunittests.xml
|
||||
exec_env/app_base/runps-test.sh ps_test.dll -xml ../../xunittests.xml
|
||||
|
||||
pester-tests: $(RUN_TARGETS) internal-prepare-exec_env internal-prepare-release-clr
|
||||
# execute the Pester tests, which needs a TEMP environment variable to be set
|
||||
|
|
File diff suppressed because one or more lines are too long
7
scripts/runps-test.sh
Executable file
7
scripts/runps-test.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
CWD=$(pwd)
|
||||
SCRIPTDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
|
||||
cd "$SCRIPTDIR"
|
||||
PSMODULEPATH="$SCRIPTDIR/Modules" LD_LIBRARY_PATH="$SCRIPTDIR" ./host_cmdline -c ../coreclr -alc Microsoft.PowerShell.CoreCLR.AssemblyLoadContext.dll -tpa xunit.console.netcore.exe xunit.console.netcore.exe "$@"
|
|
@ -6,4 +6,4 @@ $(TESTRUN_FOLDER)/xunit%: $(MONAD_EXT)/xunit/xunit%
|
|||
cp -f $^ $@
|
||||
|
||||
$(TESTRUN_FOLDER)/ps_test.dll: $(TEST_SRCS) $(addprefix $(TESTRUN_FOLDER)/, xunit.core.dll xunit.assert.dll) $(addprefix dotnetlibs/, System.Management.Automation.dll Microsoft.PowerShell.Commands.Management.dll $(ASSEMBLY_LOAD_CONTEXT_TARGET))
|
||||
$(CSC) -out:$@ -noconfig -nostdlib -target:library $(addprefix -r:$(TESTRUN_FOLDER)/, xunit.core.dll xunit.assert.dll) $(addprefix -r:dotnetlibs/, System.Management.Automation.dll $(ASSEMBLY_LOAD_CONTEXT_TARGET)) ${COREREF} $(TEST_SRCS)
|
||||
$(CSC) -out:$@ -noconfig -nostdlib -target:library $(addprefix -r:$(TESTRUN_FOLDER)/, xunit.core.dll xunit.assert.dll) $(addprefix -r:dotnetlibs/, System.Management.Automation.dll $(ASSEMBLY_LOAD_CONTEXT_TARGET)) $(COREREF) $(TEST_SRCS)
|
||||
|
|
48
src/ps_test/test_Runspace.cs
Normal file
48
src/ps_test/test_Runspace.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
using Xunit;
|
||||
using System;
|
||||
using System.Management.Automation;
|
||||
using System.Management.Automation.Runspaces;
|
||||
|
||||
namespace PSTests
|
||||
{
|
||||
public static class RunspaceTests
|
||||
{
|
||||
[Fact]
|
||||
public static void TestMethod()
|
||||
{
|
||||
InitialSessionState iss = InitialSessionState.CreateDefault2();
|
||||
|
||||
// NOTE: instantiate custom host myHost for the next line to capture stdout and stderr output
|
||||
// in addition to just the PSObjects
|
||||
using (Runspace rs = RunspaceFactory.CreateRunspace(/*myHost,*/iss))
|
||||
{
|
||||
rs.Open();
|
||||
using (PowerShell ps = PowerShell.Create())
|
||||
{
|
||||
ps.Runspace = rs;
|
||||
|
||||
string script = "get-process | select-object -first 3";
|
||||
ps.AddScript(script);
|
||||
|
||||
// IMPORTANT NOTE: do not call AddCommand("out-host") here or
|
||||
// MergeMyResults, otherwise Invoke will not return any objects
|
||||
|
||||
var results = ps.Invoke();
|
||||
|
||||
// check that there are 3 captured objects
|
||||
int objCount = 0;
|
||||
foreach (var result in results)
|
||||
{
|
||||
// this is how an object would be captured here and looked at,
|
||||
// each result is a PSObject with the data from the pipeline
|
||||
++objCount;
|
||||
Assert.NotNull(result);
|
||||
}
|
||||
Assert.Equal(3,objCount);
|
||||
ps.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in a new issue