diff --git a/scripts/Makefile b/scripts/Makefile index 9a1027347e..174a68bd0e 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -181,20 +181,31 @@ run-interactive: $(RUN_TARGETS) internal-prepare-exec_env internal-prepare-relea run-file: $(RUN_TARGETS) internal-prepare-exec_env internal-prepare-release-clr exec_env/app_base/runps.sh --file $(PSSCRIPT) -pester-tests: $(RUN_TARGETS) internal-prepare-exec_env internal-prepare-release-clr - # execute the pester tests, pester needs a TEMP environment variable to be set - exec_env/app_base/runps-simple.sh 'cd ../src/pester-tests; $$env:TEMP="/tmp"; invoke-pester' - -test: $(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) pester-tests dotnetlibs/monad_native - 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 - # run the c++ tests - cd dotnetlibs && ./monad_native - # test the 3rdparty/hashbang sample - PATH=$(PATH):$(shell pwd)/exec_env/app_base 3rdparty/hashbang/script.ps1 +# easy way to run individual PowerShell scripts, `make script.ps1` where the path is relative to monad-linux/scripts (with TEMP set for Pester) +%.ps1: $(RUN_TARGETS) internal-prepare-exec_env internal-prepare-release-clr + TEMP=/tmp exec_env/app_base/runps.sh --file ../../$@ run-debugclr: $(RUN_TARGETS) internal-prepare-exec_env internal-prepare-debug-clr PAL_DBG_CHANNELS="+LOADER.TRACE" exec_env/app_base/runps-simple.sh get-location +native-tests: dotnetlibs/monad_native + # execute the native C++ tests + cd 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 + +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 + exec_env/app_base/runps-simple.sh 'cd ../../../src/pester-tests; $$env:TEMP="/tmp"; invoke-pester' + +hashbang-tests: + # execute the 3rdparty/hashbang example + PATH=$(PATH):$(shell pwd)/exec_env/app_base $(shell pwd)/3rdparty/hashbang/script.ps1 + +test: native-tests xunit-tests pester-tests hashbang-tests + trace: $(RUN_TARGETS) internal-prepare-exec_env internal-prepare-release-clr exec_env/app_base/runps-simple-trace.sh get-location diff --git a/scripts/coreref.mk b/scripts/coreref.mk index 042499f06a..775b928220 100644 --- a/scripts/coreref.mk +++ b/scripts/coreref.mk @@ -2,9 +2,9 @@ # this depends on the MONAD_EXT variable to be correctly set TARGETING_PACK=$(MONAD_EXT)/coreclr/TargetingPack -COREREF=-r:$(TARGETING_PACK)/Microsoft.CSharp.dll -r:$(TARGETING_PACK)/Microsoft.VisualBasic.dll -r:$(TARGETING_PACK)/Microsoft.Win32.Primitives.dll -r:$(TARGETING_PACK)/Microsoft.Win32.Registry.AccessControl.dll -r:$(TARGETING_PACK)/Microsoft.Win32.Registry.dll -r:$(TARGETING_PACK)/System.AppContext.dll -r:$(TARGETING_PACK)/System.Collections.Concurrent.dll -r:$(TARGETING_PACK)/System.Collections.dll -r:$(TARGETING_PACK)/System.Collections.NonGeneric.dll -r:$(TARGETING_PACK)/System.Collections.Specialized.dll -r:$(TARGETING_PACK)/System.ComponentModel.Annotations.dll -r:$(TARGETING_PACK)/System.ComponentModel.dll -r:$(TARGETING_PACK)/System.ComponentModel.EventBasedAsync.dll -r:$(TARGETING_PACK)/System.ComponentModel.Primitives.dll -r:$(TARGETING_PACK)/System.ComponentModel.TypeConverter.dll -r:$(TARGETING_PACK)/System.Console.dll -r:$(TARGETING_PACK)/System.Data.Common.dll -r:$(TARGETING_PACK)/System.Data.SqlClient.dll -r:$(TARGETING_PACK)/System.Diagnostics.Contracts.dll -r:$(TARGETING_PACK)/System.Diagnostics.Debug.dll -r:$(TARGETING_PACK)/System.Diagnostics.FileVersionInfo.dll -r:$(TARGETING_PACK)/System.Diagnostics.Process.dll -r:$(TARGETING_PACK)/System.Diagnostics.TextWriterTraceListener.dll -r:$(TARGETING_PACK)/System.Diagnostics.Tools.dll -r:$(TARGETING_PACK)/System.Diagnostics.TraceSource.dll -r:$(TARGETING_PACK)/System.Diagnostics.Tracing.dll -r:$(TARGETING_PACK)/System.Dynamic.Runtime.dll -r:$(TARGETING_PACK)/System.Globalization.Calendars.dll -r:$(TARGETING_PACK)/System.Globalization.dll -r:$(TARGETING_PACK)/System.Globalization.Extensions.dll -r:$(TARGETING_PACK)/System.IO.Compression.dll -r:$(TARGETING_PACK)/System.IO.Compression.ZipFile.dll -r:$(TARGETING_PACK)/System.IO.dll -r:$(TARGETING_PACK)/System.IO.FileSystem.AccessControl.dll -r:$(TARGETING_PACK)/System.IO.FileSystem.dll -r:$(TARGETING_PACK)/System.IO.FileSystem.DriveInfo.dll -r:$(TARGETING_PACK)/System.IO.FileSystem.Primitives.dll -r:$(TARGETING_PACK)/System.IO.FileSystem.Watcher.dll -r:$(TARGETING_PACK)/System.IO.MemoryMappedFiles.dll -r:$(TARGETING_PACK)/System.IO.Pipes.dll -r:$(TARGETING_PACK)/System.IO.UnmanagedMemoryStream.dll -r:$(TARGETING_PACK)/System.Linq.dll -r:$(TARGETING_PACK)/System.Linq.Expressions.dll -r:$(TARGETING_PACK)/System.Linq.Parallel.dll -r:$(TARGETING_PACK)/System.Linq.Queryable.dll -r:$(TARGETING_PACK)/System.Net.Http.dll -r:$(TARGETING_PACK)/System.Net.Http.WinHttpHandler.dll -r:$(TARGETING_PACK)/System.Net.NameResolution.dll -r:$(TARGETING_PACK)/System.Net.NetworkInformation.dll -r:$(TARGETING_PACK)/System.Net.Primitives.dll -r:$(TARGETING_PACK)/System.Net.Security.dll -r:$(TARGETING_PACK)/System.Net.Sockets.dll -r:$(TARGETING_PACK)/System.Net.Utilities.dll -r:$(TARGETING_PACK)/System.Net.WebHeaderCollection.dll -r:$(TARGETING_PACK)/System.Net.WebSockets.Client.dll -r:$(TARGETING_PACK)/System.Net.WebSockets.dll -r:$(TARGETING_PACK)/System.ObjectModel.dll -r:$(TARGETING_PACK)/System.Reflection.DispatchProxy.dll -r:$(TARGETING_PACK)/System.Reflection.dll -r:$(TARGETING_PACK)/System.Reflection.Emit.dll -r:$(TARGETING_PACK)/System.Reflection.Emit.ILGeneration.dll -r:$(TARGETING_PACK)/System.Reflection.Emit.Lightweight.dll -r:$(TARGETING_PACK)/System.Reflection.Extensions.dll -r:$(TARGETING_PACK)/System.Reflection.Primitives.dll -r:$(TARGETING_PACK)/System.Reflection.TypeExtensions.dll -r:$(TARGETING_PACK)/System.Resources.ReaderWriter.dll -r:$(TARGETING_PACK)/System.Resources.ResourceManager.dll -r:$(TARGETING_PACK)/System.Runtime.CompilerServices.VisualC.dll -r:$(TARGETING_PACK)/System.Runtime.dll -r:$(TARGETING_PACK)/System.Runtime.Extensions.dll -r:$(TARGETING_PACK)/System.Runtime.Handles.dll -r:$(TARGETING_PACK)/System.Runtime.InteropServices.dll -r:$(TARGETING_PACK)/System.Runtime.InteropServices.WindowsRuntime.dll -r:$(TARGETING_PACK)/System.Runtime.Loader.dll -r:$(TARGETING_PACK)/System.Runtime.Numerics.dll -r:$(TARGETING_PACK)/System.Runtime.Serialization.Json.dll -r:$(TARGETING_PACK)/System.Runtime.Serialization.Primitives.dll -r:$(TARGETING_PACK)/System.Runtime.Serialization.Xml.dll -r:$(TARGETING_PACK)/System.Security.AccessControl.dll -r:$(TARGETING_PACK)/System.Security.Claims.dll -r:$(TARGETING_PACK)/System.Security.Cryptography.DeriveBytes.dll -r:$(TARGETING_PACK)/System.Security.Cryptography.Encoding.dll -r:$(TARGETING_PACK)/System.Security.Cryptography.Encryption.Aes.dll -r:$(TARGETING_PACK)/System.Security.Cryptography.Encryption.dll -r:$(TARGETING_PACK)/System.Security.Cryptography.Hashing.Algorithms.dll -r:$(TARGETING_PACK)/System.Security.Cryptography.Hashing.dll -r:$(TARGETING_PACK)/System.Security.Cryptography.RandomNumberGenerator.dll -r:$(TARGETING_PACK)/System.Security.Cryptography.RSA.dll -r:$(TARGETING_PACK)/System.Security.Cryptography.X509Certificates.dll -r:$(TARGETING_PACK)/System.Security.Principal.dll -r:$(TARGETING_PACK)/System.Security.Principal.Windows.dll -r:$(TARGETING_PACK)/System.Security.SecureString.dll -r:$(TARGETING_PACK)/System.ServiceModel.Duplex.dll -r:$(TARGETING_PACK)/System.ServiceModel.Http.dll -r:$(TARGETING_PACK)/System.ServiceModel.NetTcp.dll -r:$(TARGETING_PACK)/System.ServiceModel.Primitives.dll -r:$(TARGETING_PACK)/System.ServiceModel.Security.dll -r:$(TARGETING_PACK)/System.ServiceProcess.ServiceController.dll -r:$(TARGETING_PACK)/System.Text.Encoding.CodePages.dll -r:$(TARGETING_PACK)/System.Text.Encoding.dll -r:$(TARGETING_PACK)/System.Text.Encoding.Extensions.dll -r:$(TARGETING_PACK)/System.Text.RegularExpressions.dll -r:$(TARGETING_PACK)/System.Threading.AccessControl.dll -r:$(TARGETING_PACK)/System.Threading.dll -r:$(TARGETING_PACK)/System.Threading.Overlapped.dll -r:$(TARGETING_PACK)/System.Threading.Tasks.dll -r:$(TARGETING_PACK)/System.Threading.Tasks.Parallel.dll -r:$(TARGETING_PACK)/System.Threading.Thread.dll -r:$(TARGETING_PACK)/System.Threading.ThreadPool.dll -r:$(TARGETING_PACK)/System.Threading.Timer.dll -r:$(TARGETING_PACK)/System.Xml.ReaderWriter.dll -r:$(TARGETING_PACK)/System.Xml.XDocument.dll -r:$(TARGETING_PACK)/System.Xml.XmlDocument.dll -r:$(TARGETING_PACK)/System.Xml.XmlSerializer.dll -r:$(TARGETING_PACK)/System.Xml.XPath.dll -r:$(TARGETING_PACK)/System.Xml.XPath.XDocument.dll -r:$(TARGETING_PACK)/System.Xml.XPath.XmlDocument.dll +COREREF=$(addprefix -r:, $(shell ls $(TARGETING_PACK)/*.dll)) # COREREF_2 is here for dev/testing purposes, it should not be used anywhere (instead use the reference assemblies stored in COREREF) CORECLR_ASSEMBLY_BASE=$(MONAD_EXT)/coreclr/Release -COREREF_2= -r:$(CORECLR_ASSEMBLY_BASE)/Microsoft.CSharp.dll -r:$(CORECLR_ASSEMBLY_BASE)/Microsoft.VisualBasic.dll -r:$(CORECLR_ASSEMBLY_BASE)/Microsoft.Win32.Primitives.dll -r:$(CORECLR_ASSEMBLY_BASE)/Microsoft.Win32.Registry.AccessControl.dll -r:$(CORECLR_ASSEMBLY_BASE)/Microsoft.Win32.Registry.dll -r:$(CORECLR_ASSEMBLY_BASE)/mscorlib.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.AppContext.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Collections.Concurrent.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Collections.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Collections.NonGeneric.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Collections.Specialized.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.ComponentModel.Annotations.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.ComponentModel.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.ComponentModel.EventBasedAsync.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.ComponentModel.Primitives.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.ComponentModel.TypeConverter.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Console.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Core.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Data.Common.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Data.SqlClient.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Diagnostics.Contracts.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Diagnostics.Debug.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Diagnostics.FileVersionInfo.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Diagnostics.Process.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Diagnostics.StackTrace.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Diagnostics.TextWriterTraceListener.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Diagnostics.Tools.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Diagnostics.TraceSource.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Diagnostics.Tracing.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Dynamic.Runtime.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Globalization.Calendars.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Globalization.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Globalization.Extensions.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.IO.Compression.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.IO.Compression.ZipFile.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.IO.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.IO.FileSystem.AccessControl.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.IO.FileSystem.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.IO.FileSystem.DriveInfo.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.IO.FileSystem.Primitives.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.IO.FileSystem.Watcher.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.IO.MemoryMappedFiles.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.IO.Pipes.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.IO.UnmanagedMemoryStream.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Linq.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Linq.Expressions.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Linq.Parallel.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Linq.Queryable.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Net.Http.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Net.Http.WinHttpHandler.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Net.NameResolution.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Net.NetworkInformation.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Net.Primitives.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Net.Requests.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Net.Security.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Net.Sockets.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Net.Utilities.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Net.WebHeaderCollection.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Net.WebSockets.Client.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Net.WebSockets.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.ObjectModel.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Private.CompilerServices.ICastable.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Private.CoreLib.InteropServices.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Private.DataContractSerialization.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Private.Interop.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Private.Networking.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Private.ServiceModel.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Private.Uri.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Reflection.DispatchProxy.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Reflection.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Reflection.Emit.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Reflection.Emit.ILGeneration.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Reflection.Emit.Lightweight.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Reflection.Extensions.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Reflection.Primitives.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Reflection.TypeExtensions.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Resources.ReaderWriter.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Resources.ResourceManager.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Runtime.CompilerServices.VisualC.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Runtime.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Runtime.Extensions.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Runtime.Handles.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Runtime.InteropServices.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Runtime.InteropServices.WindowsRuntime.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Runtime.Loader.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Runtime.Numerics.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Runtime.Serialization.Json.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Runtime.Serialization.Primitives.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Runtime.Serialization.Xml.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Security.AccessControl.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Security.Claims.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Security.Cryptography.DeriveBytes.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Security.Cryptography.Encoding.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Security.Cryptography.Encryption.Aes.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Security.Cryptography.Encryption.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Security.Cryptography.Hashing.Algorithms.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Security.Cryptography.Hashing.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Security.Cryptography.RandomNumberGenerator.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Security.Cryptography.RSA.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Security.Cryptography.X509Certificates.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Security.Principal.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Security.Principal.Windows.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Security.SecureString.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.ServiceModel.Duplex.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.ServiceModel.Http.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.ServiceModel.NetTcp.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.ServiceModel.Primitives.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.ServiceModel.Security.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.ServiceProcess.ServiceController.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Text.Encoding.CodePages.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Text.Encoding.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Text.Encoding.Extensions.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Text.RegularExpressions.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Threading.AccessControl.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Threading.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Threading.Overlapped.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Threading.Tasks.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Threading.Tasks.Parallel.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Threading.Thread.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Threading.ThreadPool.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Threading.Timer.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Xml.ReaderWriter.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Xml.XDocument.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Xml.XmlDocument.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Xml.XmlSerializer.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Xml.XPath.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Xml.XPath.XDocument.dll -r:$(CORECLR_ASSEMBLY_BASE)/System.Xml.XPath.XmlDocument.dll +COREREF_2=$(addprefix -r:, $(shell ls $(CORECLR_ASSEMBLY_BASE)/*.dll)) diff --git a/scripts/gen/SYS_AUTO/ParserStrings.cs b/scripts/gen/SYS_AUTO/ParserStrings.cs index 5735d3e3c8..b8fe6662bc 100644 --- a/scripts/gen/SYS_AUTO/ParserStrings.cs +++ b/scripts/gen/SYS_AUTO/ParserStrings.cs @@ -595,6 +595,15 @@ internal class ParserStrings { } } + /// + /// Looks up a localized string similar to Failed to convert the value of CimProperty {0} to the property value of class {1}.. + /// + internal static string ConvertCimPropertyToObjectPropertyFailed { + get { + return ResourceManager.GetString("ConvertCimPropertyToObjectPropertyFailed", resourceCulture); + } + } + /// /// Looks up a localized string similar to Could not get dispatch ID for {0} (error: {1}).. /// @@ -838,6 +847,15 @@ internal class ParserStrings { } } + /// + /// Looks up a localized string similar to Keyword '{0}' already defined in the configuration.. + /// + internal static string DuplicateKeywordDefinition { + get { + return ResourceManager.GetString("DuplicateKeywordDefinition", resourceCulture); + } + } + /// /// Looks up a localized string similar to Duplicate named arguments '{0}' are not allowed.. /// @@ -1090,6 +1108,15 @@ internal class ParserStrings { } } + /// + /// Looks up a localized string similar to Property {0} of PowerShell class {1} is not declared as array type, but defined in its configuration instance as instance array type.. + /// + internal static string ExpectArrayTypeOfPropertyInPSClass { + get { + return ResourceManager.GetString("ExpectArrayTypeOfPropertyInPSClass", resourceCulture); + } + } + /// /// Looks up a localized string similar to An expression was expected after '('.. /// @@ -1430,6 +1457,15 @@ internal class ParserStrings { } } + /// + /// Looks up a localized string similar to Failed to create an object of PowerShell class {0}.. + /// + internal static string InstantiatePSClassObjectFailed { + get { + return ResourceManager.GetString("InstantiatePSClassObjectFailed", resourceCulture); + } + } + /// /// Looks up a localized string similar to '{0}': Interface name expected.. /// @@ -1538,6 +1574,15 @@ internal class ParserStrings { } } + /// + /// Looks up a localized string similar to The hashtable supplied to the Desired State Configuration resource {0} is not valid. The key or value cannot be null or empty.. + /// + internal static string InvalidHashtable { + get { + return ResourceManager.GetString("InvalidHashtable", resourceCulture); + } + } + /// /// Looks up a localized string similar to The member '{0}' is not valid. Valid members are ///'{1}'.. @@ -1602,6 +1647,15 @@ internal class ParserStrings { } } + /// + /// Looks up a localized string similar to The username supplied to the Desired State Configuration resource {0} is not valid. The username cannot be null or empty.. + /// + internal static string InvalidPassword { + get { + return ResourceManager.GetString("InvalidPassword", resourceCulture); + } + } + /// /// Looks up a localized string similar to The PowerShell data file '{0}' is invalid since it cannot be evaluated into a Hashtable object.. /// @@ -1665,6 +1719,15 @@ internal class ParserStrings { } } + /// + /// Looks up a localized string similar to The username supplied to the Desired State Configuration resource {0} is not valid. The username cannot be null or empty.. + /// + internal static string InvalidUserName { + get { + return ResourceManager.GetString("InvalidUserName", resourceCulture); + } + } + /// /// Looks up a localized string similar to Expression is not allowed in a Using expression.. /// @@ -2925,6 +2988,15 @@ internal class ParserStrings { } } + /// + /// Looks up a localized string similar to Property {0} is not declared in PowerShell class {1}, but defined in its configuration instance.. + /// + internal static string PropertyNotDeclaredInPSClass { + get { + return ResourceManager.GetString("PropertyNotDeclaredInPSClass", resourceCulture); + } + } + /// /// Looks up a localized string similar to The property '{0}' cannot be found on this object. Verify that the property exists and can be set.. /// diff --git a/scripts/gen/SYS_AUTO/ParserStrings.resources b/scripts/gen/SYS_AUTO/ParserStrings.resources index c0d703f77c..7efbef9ebf 100644 Binary files a/scripts/gen/SYS_AUTO/ParserStrings.resources and b/scripts/gen/SYS_AUTO/ParserStrings.resources differ diff --git a/scripts/gen/SYS_AUTO/RemotingErrorIdStrings.cs b/scripts/gen/SYS_AUTO/RemotingErrorIdStrings.cs index 114fdf01b4..c8eb48f795 100644 --- a/scripts/gen/SYS_AUTO/RemotingErrorIdStrings.cs +++ b/scripts/gen/SYS_AUTO/RemotingErrorIdStrings.cs @@ -250,6 +250,15 @@ internal class RemotingErrorIdStrings { } } + /// + /// Looks up a localized string similar to Failed to find vmcompute.dll. The Hyper-V role may not be enabled on this machine.. + /// + internal static string CannotFindVmComputeDll { + get { + return ResourceManager.GetString("CannotFindVmComputeDll", resourceCulture); + } + } + /// /// Looks up a localized string similar to The call to Windows API GetStdHandle to get the Standard Error handle resulted in an error code: {0}.. /// @@ -538,6 +547,15 @@ internal class RemotingErrorIdStrings { } } + /// + /// Looks up a localized string similar to Could not find the toolkit, '{0}'. The toolkit must be a file named '{1}' within a 'Toolkits' directory in a module in the current module path.. + /// + internal static string CouldNotFindToolkit { + get { + return ResourceManager.GetString("CouldNotFindToolkit", resourceCulture); + } + } + /// /// Looks up a localized string similar to {0} is not a valid value for the parameter {1}. The value must be greater than or equal to 0.. /// @@ -767,6 +785,15 @@ internal class RemotingErrorIdStrings { } } + /// + /// Looks up a localized string similar to Could not parse visible command defintion for '{0}'. The visible command definition must be a hashtable with the keys of 'Name' and 'Parameters'. The value of the 'Parameters' key must be a collection of hashtables with the keys 'Name', and optionally either 'ValidateSet' or 'ValidatePattern'.. + /// + internal static string DISCCommandModificationSyntax { + get { + return ResourceManager.GetString("DISCCommandModificationSyntax", resourceCulture); + } + } + /// /// Looks up a localized string similar to Company associated with this session configuration. /// @@ -956,6 +983,15 @@ internal class RemotingErrorIdStrings { } } + /// + /// Looks up a localized string similar to User roles (security groups), and the additional configuration settings that should be applied to them. + /// + internal static string DISCRoleDefinitionsComment { + get { + return ResourceManager.GetString("DISCRoleDefinitionsComment", resourceCulture); + } + } + /// /// Looks up a localized string similar to Version number of the schema used for this configuration file. /// @@ -974,6 +1010,15 @@ internal class RemotingErrorIdStrings { } } + /// + /// Looks up a localized string similar to Toolkits to apply to this session configuration. This toolkit must be defined as a session configuration file named after that toolkit within a 'Toolkits' directory in a module in the current module path.. + /// + internal static string DISCToolkitsToLoadComment { + get { + return ResourceManager.GetString("DISCToolkitsToLoadComment", resourceCulture); + } + } + /// /// Looks up a localized string similar to Specifies the transport options for this session configuration. /// @@ -1629,6 +1674,33 @@ internal class RemotingErrorIdStrings { } } + /// + /// Looks up a localized string similar to The 'Roles' entry must be a hashtable, but was a {0}.. + /// + internal static string InvalidRoleEntry { + get { + return ResourceManager.GetString("InvalidRoleEntry", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The key '{0}' is not valid in a toolkit or role definition.. + /// + internal static string InvalidRoleToolkitKey { + get { + return ResourceManager.GetString("InvalidRoleToolkitKey", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Could not convert the value of the '{0}' role entry to a hashtable. The 'Roles' entry must be a hashtable with group names for keys, where the value associated with each key is another hashtable of session configuration properties for that role.. + /// + internal static string InvalidRoleValue { + get { + return ResourceManager.GetString("InvalidRoleValue", resourceCulture); + } + } + /// /// Looks up a localized string similar to {0} is not a valid schema value. Valid values are "http" and "https".. /// @@ -3053,6 +3125,15 @@ internal class RemotingErrorIdStrings { } } + /// + /// Looks up a localized string similar to Failed to create an instance of RemoteSessionHyperVSocketServer.. + /// + internal static string RemoteSessionHyperVSocketServerConstructorFailure { + get { + return ResourceManager.GetString("RemoteSessionHyperVSocketServerConstructorFailure", resourceCulture); + } + } + /// /// Looks up a localized string similar to Remote transport error: {0}. /// @@ -3837,6 +3918,15 @@ internal class RemotingErrorIdStrings { } } + /// + /// Looks up a localized string similar to WSMan Initialization failed with error code: {0}.. + /// + internal static string WSManInitFailed { + get { + return ResourceManager.GetString("WSManInitFailed", resourceCulture); + } + } + /// /// Looks up a localized string similar to The maximum number of WS-Man URI redirections to allow while connecting to a remote computer. /// diff --git a/scripts/gen/SYS_AUTO/RemotingErrorIdStrings.resources b/scripts/gen/SYS_AUTO/RemotingErrorIdStrings.resources index 7b771f8a5a..f3a113e04a 100644 Binary files a/scripts/gen/SYS_AUTO/RemotingErrorIdStrings.resources and b/scripts/gen/SYS_AUTO/RemotingErrorIdStrings.resources differ diff --git a/scripts/powershell-run.mk b/scripts/powershell-run.mk index 712b75c692..71a7412669 100644 --- a/scripts/powershell-run.mk +++ b/scripts/powershell-run.mk @@ -19,5 +19,3 @@ dotnetlibs/powershell-run.exe: $(POWERSHELL_RUN_SRCS) $(POWERSHELL_RUN_DEPS) dotnetlibs/powershell-simple.exe: $(POWERSHELL_SIMPLE_SRCS) $(POWERSHELL_RUN_DEPS) $(CSC) -out:$@ -noconfig -nostdlib -target:exe $(POWERSHELL_RUN_REFS) $(COREREF) $(POWERSHELL_SIMPLE_SRCS) - - diff --git a/scripts/runps-file.sh b/scripts/runps-file.sh index e3239ccdc8..4dcf52cd13 100755 --- a/scripts/runps-file.sh +++ b/scripts/runps-file.sh @@ -3,4 +3,3 @@ SCRIPTDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) "$SCRIPTDIR/runps.sh" --file "$@" - diff --git a/scripts/runps-simple-debug.sh b/scripts/runps-simple-debug.sh index 6bbe7a82d5..5d3fbe4fb4 100755 --- a/scripts/runps-simple-debug.sh +++ b/scripts/runps-simple-debug.sh @@ -5,5 +5,4 @@ SCRIPTDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) cd "$SCRIPTDIR" echo "launching PS debug now" -PSMODULEPATH="$SCRIPTDIR/Modules" LD_LIBRARY_PATH="$SCRIPTDIR:/usr/lib/llvm-3.6/lib" lldb-3.6 ./host_cmdline -- -c ../coreclr -alc Microsoft.PowerShell.CoreCLR.AssemblyLoadContext.dll -tpa powershell-simple.exe "powershell-simple, version=1.0.0.0, culture=neutral, PublicKeyToken=null" "ps_hello_world.Program" "UnmanagedMain" --working-dir "$CWD" "$@" - +PSMODULEPATH="$SCRIPTDIR/Modules" LD_LIBRARY_PATH="$SCRIPTDIR:/usr/lib/llvm-3.6/lib" lldb-3.6 ./host_cmdline -- -c ../coreclr -alc Microsoft.PowerShell.CoreCLR.AssemblyLoadContext.dll -tpa powershell-simple.exe powershell-simple.exe "$@" diff --git a/scripts/runps-simple-trace.sh b/scripts/runps-simple-trace.sh index d8e08c031a..f2932e827c 100755 --- a/scripts/runps-simple-trace.sh +++ b/scripts/runps-simple-trace.sh @@ -5,5 +5,4 @@ SCRIPTDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) cd "$SCRIPTDIR" echo "launching PS trace now" -PSMODULEPATH="$SCRIPTDIR/Modules" LD_LIBRARY_PATH="$SCRIPTDIR" strace -e trace=file ./host_cmdline -c ../coreclr -alc Microsoft.PowerShell.CoreCLR.AssemblyLoadContext.dll -tpa powershell-simple.exe "powershell-simple, version=1.0.0.0, culture=neutral, PublicKeyToken=null" "ps_hello_world.Program" "UnmanagedMain" --working-dir "$CWD" "$@" - +PSMODULEPATH="$SCRIPTDIR/Modules" LD_LIBRARY_PATH="$SCRIPTDIR" strace -e trace=file ./host_cmdline -c ../coreclr -alc Microsoft.PowerShell.CoreCLR.AssemblyLoadContext.dll -tpa powershell-simple.exe powershell-simple.exe "$@" diff --git a/scripts/runps-simple.sh b/scripts/runps-simple.sh index 214fc64652..63615f271d 100755 --- a/scripts/runps-simple.sh +++ b/scripts/runps-simple.sh @@ -4,5 +4,4 @@ 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 powershell-simple.exe "powershell-simple, version=1.0.0.0, culture=neutral, PublicKeyToken=null" "ps_hello_world.Program" "UnmanagedMain" --working-dir "$CWD" "$@" - +PSMODULEPATH="$SCRIPTDIR/Modules" LD_LIBRARY_PATH="$SCRIPTDIR" ./host_cmdline -c ../coreclr -alc Microsoft.PowerShell.CoreCLR.AssemblyLoadContext.dll -tpa powershell-simple.exe powershell-simple.exe "$@" diff --git a/scripts/runps.sh b/scripts/runps.sh index 5f672c053f..d47a5e77ee 100755 --- a/scripts/runps.sh +++ b/scripts/runps.sh @@ -4,5 +4,4 @@ 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 powershell-run.exe "powershell-run, version=1.0.0.0, culture=neutral, PublicKeyToken=null" "Microsoft.Samples.PowerShell.Host.PSListenerConsoleSample" "UnmanagedMain" --working-dir "$CWD" "$@" - +PSMODULEPATH="$SCRIPTDIR/Modules" LD_LIBRARY_PATH="$SCRIPTDIR" ./host_cmdline -c ../coreclr -alc Microsoft.PowerShell.CoreCLR.AssemblyLoadContext.dll -tpa powershell-run.exe powershell-run.exe "$@" diff --git a/src/monad b/src/monad index df562ce7ec..d541b07343 160000 --- a/src/monad +++ b/src/monad @@ -1 +1 @@ -Subproject commit df562ce7ecd60fb42e30702116123c8a58bf04d4 +Subproject commit d541b073435e55fd96771697e5549cc9a188fa54 diff --git a/src/monad-ext b/src/monad-ext index 20468e65da..ea31eca622 160000 --- a/src/monad-ext +++ b/src/monad-ext @@ -1 +1 @@ -Subproject commit 20468e65dac6fa5a1b4cf6971ff490e548531822 +Subproject commit ea31eca6223992fa9729af67518930b6b45829d3 diff --git a/src/monad-native b/src/monad-native index a99c56eea3..5693da6a46 160000 --- a/src/monad-native +++ b/src/monad-native @@ -1 +1 @@ -Subproject commit a99c56eea3264b8c492bc0edf5e3a65102397af9 +Subproject commit 5693da6a46e8c4d63a49a6dbc6be3081ce7d0d08 diff --git a/src/pester-tests/Test-Environment-Variables.Tests.ps1 b/src/pester-tests/Test-Environment-Variables.Tests.ps1 index 6bde8f2898..4bf643ffea 100644 --- a/src/pester-tests/Test-Environment-Variables.Tests.ps1 +++ b/src/pester-tests/Test-Environment-Variables.Tests.ps1 @@ -1,15 +1,34 @@ Describe "Test-Environment-Variables" { - It "Should have environment variable" { + It "Should have environment variables" { Get-Item ENV: | Should Not BeNullOrEmpty } - It "Should be able to access the members of the environment variable in two ways" { - (Get-Item ENV:HOME).Value | Should be "/root" - (Get-Item ENV:HOSTNAME).Value | Should Not BeNullOrEmpty - (Get-Item ENV:PATH).Value | Should Not BeNullOrEmpty + It "Should have a nonempty PATH" { + $ENV:PATH | Should Not BeNullOrEmpty + } - (ls ENV:HOME).Value | Should be "/root" - (ls ENV:HOSTNAME).Value | Should Not BeNullOrEmpty - (ls ENV:PATH).Value | Should Not BeNullOrEmpty + It "Should contain /bin in the PATH" { + $ENV:PATH | Should Match "/bin" + } + + It "Should be able to access the members of the environment variable" { + $expected = /bin/bash -c "cd ~ && pwd" + + (Get-Item ENV:HOME).Value | Should Be $expected + } + + It "Should be able to set the environment variables" { + $expected = "this is a test environment variable" + { $ENV:TESTENVIRONMENTVARIABLE = $expected } | Should Not Throw + + $ENV:TESTENVIRONMENTVARIABLE | Should Not BeNullOrEmpty + $ENV:TESTENVIRONMENTVARIABLE | Should Be $expected + + } + + It "Should have the correct HOSTNAME" { + $expected = /bin/hostname + + $ENV:HOSTNAME | Should Be $expected } } diff --git a/src/pester-tests/Test-Remove-Item.Tests.ps1 b/src/pester-tests/Test-Remove-Item.Tests.ps1 new file mode 100644 index 0000000000..017a461d7e --- /dev/null +++ b/src/pester-tests/Test-Remove-Item.Tests.ps1 @@ -0,0 +1,139 @@ +Describe "Test-Remove-Item" { + $testpath = "/tmp/" + $testfile = "testfile.txt" + $testfilepath = $testpath + $testfile + Context "File removal Tests" { + BeforeEach { + New-Item -Name $testfile -Path $testpath -ItemType "file" -Value "lorem ipsum" -Force + + Test-Path $testfilepath | Should Be $true + + } + + It "Should be able to be called on a regular file without error using the Path switch" { + { Remove-Item -Path $testfilepath } | Should Not Throw + + Test-Path $testfilepath | Should Be $false + } + + It "Should be able to be called on a file without the Path switch" { + { Remove-Item $testfilepath } | Should Not Throw + + Test-Path $testfilepath | Should Be $false + } + + It "Should be able to call the rm alias" { + { rm $testfilepath } | Should Not Throw + + Test-Path $testfilepath | Should Be $false + } + + It "Should be able to call the del alias" { + { del $testfilepath } | Should Not Throw + + Test-Path $testfilepath | Should Be $false + } + + It "Should be able to call the erase alias" { + { erase $testfilepath } | Should Not Throw + + Test-Path $testfilepath | Should Be $false + } + + It "Should be able to call the ri alias" { + { ri $testfilepath } | Should Not Throw + + Test-Path $testfilepath | Should Be $false + } + + It "Should not be able to remove a read-only document without using the force switch" { + # Set to read only + Set-ItemProperty -Path $testfilepath -Name IsReadOnly -Value $true + + # attempt to remove the file + { Remove-Item $testfilepath -ErrorAction SilentlyContinue } | Should Not Throw + + # validate + Test-Path $testfilepath | Should Be $true + + # remove using the -force switch on the readonly object + Remove-Item $testfilepath -Force + + # Validate + Test-Path $testfilepath | Should Be $false + } + + It "Should be able to remove all files matching a regular expression with the include switch" { + # Create multiple files with specific string + New-Item -Name file1.txt -Path $testpath -ItemType "file" -Value "lorem ipsum" + New-Item -Name file2.txt -Path $testpath -ItemType "file" -Value "lorem ipsum" + New-Item -Name file3.txt -Path $testpath -ItemType "file" -Value "lorem ipsum" + # Create a single file that does not match that string - already done in BeforeEach + + # Delete the specific string + Remove-Item /tmp/* -Include file*.txt + # validate that the string under test was deleted, and the nonmatching strings still exist + Test-path /tmp/file1.txt | Should Be $false + Test-path /tmp/file2.txt | Should Be $false + Test-path /tmp/file3.txt | Should Be $false + Test-Path $testfilepath | Should Be $true + + # Delete the non-matching strings + Remove-Item $testfilepath + + Test-Path $testfilepath | Should Be $false + } + + It "Should be able to not remove any files matching a regular expression with the exclude switch" { + # Create multiple files with specific string + New-Item -Name file1.wav -Path $testpath -ItemType "file" -Value "lorem ipsum" + New-Item -Name file2.wav -Path $testpath -ItemType "file" -Value "lorem ipsum" + + # Create a single file that does not match that string + New-Item -Name file1.txt -Path $testpath -ItemType "file" -Value "lorem ipsum" + + # Delete the specific string + Remove-Item /tmp/file* -Exclude *.wav -Include *.txt + + # validate that the string under test was deleted, and the nonmatching strings still exist + Test-Path /tmp/file1.wav | Should Be $true + Test-Path /tmp/file2.wav | Should Be $true + Test-Path /tmp/file1.txt | Should Be $false + + # Delete the non-matching strings + Remove-Item /tmp/file1.wav + Remove-Item /tmp/file2.wav + + Test-Path /tmp/file1.wav | Should Be $false + Test-Path /tmp/file2.wav | Should Be $false + } + } + + Context "Directory Removal Tests" { + $testdirectory = "/tmp/testdir" + $testsubdirectory = $testdirectory + "/subd" + BeforeEach { + New-Item -Name "testdir" -Path "/tmp/" -ItemType "directory" -Force + + Test-Path $testdirectory | Should Be $true + } + + It "Should be able to remove a directory" { + { Remove-Item $testdirectory } | Should Not Throw + + Test-Path $testdirectory | Should Be $false + } + + It "Should be able to recursively delete subfolders" { + New-Item -Name "subd" -Path $testdirectory -ItemType "directory" + New-Item -Name $testfile -Path $testsubdirectory -ItemType "file" -Value "lorem ipsum" + + $complexDirectory = $testsubdirectory + "/" + $testfile + test-path $complexDirectory | Should Be $true + + { Remove-Item $testdirectory -Recurse} | Should Not Throw + + Test-Path $testdirectory | Should Be $false + } + } +} diff --git a/src/pester-tests/Test-Split-Path.Tests.ps1 b/src/pester-tests/Test-Split-Path.Tests.ps1 index c599b2382d..47dc536a0d 100644 --- a/src/pester-tests/Test-Split-Path.Tests.ps1 +++ b/src/pester-tests/Test-Split-Path.Tests.ps1 @@ -1,36 +1,86 @@ Describe "Test-Split-Path" { -<# - Dependencies: - 1. Split-Path - FUT - 2. ForEach - 3. Object piping - 4. ls/Get-ChildItem - filter output of ls - -#> It "Should return a string object when invoked" { - (Split-Path .).GetType().Name | Should Be "String" - (Split-Path . -Leaf).GetType().Name | Should Be "String" - (Split-Path . -Resolve).GetType().Name | Should Be "String" + ( Split-Path . ).GetType().Name | Should Be "String" + ( Split-Path . -Leaf ).GetType().Name | Should Be "String" + ( Split-Path . -Resolve ).GetType().Name | Should Be "String" } It "Should return the name of the drive when the qualifier switch is used" { - Split-Path / -Qualifier | Should Be "/" + Split-Path / -Qualifier | Should Be "/" + Split-Path /usr/bin -Qualifier | Should Be "/" } - It "Should return the parent folder name when the leaf switch is used" { - Split-Path . -Leaf | Should be "pester-tests" + It "Should error when using the qualifier switch for a windows path while on a nonwindows machine" { + # ErrorAction SilentlyContinue merely suppresses the error from the console. + # Throwing exceptions still seen by Pester. + + Split-Path "C:\Users" -Qualifier -ErrorAction SilentlyContinue | Should Throw + } + + It "Should error when no directory separator characters are used with a qualifier" { + Split-Path "abadTest" -Qualifier -ErrorAction SilentlyContinue | Should Throw + } + + It "Should return the path when the noqualifier switch is used on a Linux system" { + { Split-Path /usr/bin -NoQualifier } | Should Not Throw + Split-Path /usr/bin -NoQualifier | Should Be "/usr/bin" + } + + It "Should return the base name when the leaf switch is used" { + Split-Path /usr/bin -Leaf | Should be "bin" + Split-Path /usr/local/bin -Leaf | Should be "bin" + Split-Path usr/bin -Leaf | Should be "bin" + Split-Path ./bin -Leaf | Should be "bin" + Split-Path bin -Leaf | Should be "bin" } It "Should be able to accept regular expression input and output an array for multiple objects" { - (Split-Path *Get*.ps1 -Leaf -Resolve).GetType().BaseType.Name | Should Be "Array" + $testDir = "./tmp" + Remove-Item $testDir -Recurse -Force -ErrorAction Ignore + + $testFile1 = "testfile1.ps1" + $testFile2 = "testfile2.ps1" + $testFilePath1 = $testDir + "/" + $testFile1 + $testFilePath2 = $testDir + "/" + $testFile2 + + New-Item -ItemType file -Path $testFilePath1, $testFilePath2 -Force + + Test-Path $testFilePath1 | Should Be $true + Test-Path $testFilePath2 | Should Be $true + + $actual = ( Split-Path $testDir/*file*.ps1 -Leaf -Resolve ) | Sort-Object + $actual.GetType().BaseType.Name | Should Be "Array" + $actual[0] | Should Be $testFile1 + $actual[1] | Should Be $testFile2 + + Remove-Item $testDir -Recurse -Force -ErrorAction Ignore + Test-Path $testDir | Should Be $false } It "Should be able to tell if a given path is an absolute path" { - (Split-Path /usr/bin -IsAbsolute) | Should be $true - (Split-Path . -IsAbsolute) | Should be $false + ( Split-Path /usr/bin -IsAbsolute ) | Should be $true + ( Split-Path .. -IsAbsolute ) | Should be $false + ( Split-Path /usr/.. -IsAbsolute ) | Should be $true + ( Split-Path /usr/../ -IsAbsolute ) | Should be $true + ( Split-Path ../ -IsAbsolute ) | Should be $false + ( Split-Path . -IsAbsolute ) | Should be $false + ( Split-Path ~/ -IsAbsolute ) | Should be $false + ( Split-Path ~/.. -IsAbsolute ) | Should be $false + ( Split-Path ~/../.. -IsAbsolute ) | Should be $false + } It "Should support piping" { - ("." | Split-Path -leaf) | Should Be "pester-tests" + ( "/usr/bin" | Split-Path ) | Should Be "/usr" + } + + It "Should return the path up to the parent of the directory when Parent switch is used" { + Split-Path "/usr/bin" -Parent | Should Be "/usr" + Split-Path "/usr/local/bin" -Parent | Should Be "/usr/local" + Split-Path "usr/local/bin" -Parent | Should Be "usr/local" + } + + It "Should throw if a parameterSetName is incorrect" { + { Split-Path "/usr/bin/" -Parentaoeu } | Should Throw "A parameter cannot be found that matches parameter name" } } diff --git a/src/powershell-run/powershell-simple.cs b/src/powershell-run/powershell-simple.cs index ca0b393589..a3455c1b0e 100644 --- a/src/powershell-run/powershell-simple.cs +++ b/src/powershell-run/powershell-simple.cs @@ -456,25 +456,6 @@ namespace ps_hello_world } } - public static void init() - { - //string psBasePath = System.IO.Directory.GetCurrentDirectory(); - //PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(psBasePath); - - //Assembly a = Assembly.Load(new AssemblyName("System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")); - //Console.WriteLine("##########################\nloaded assembly a=" + a + " during init\n#########################"); - - // PH: this debugging requires a change in the core PS stuff that was stashed away - // during source cleanup - /* - PowerShellAssemblyLoadContext asmLoadContext = PowerShellAssemblyLoadContextInitializer.AsmLoadContext; - IEnumerable assemblies = asmLoadContext.GetAssemblies("System.Management.Automation"); - foreach (Assembly a in assemblies) - { - Console.WriteLine("a: " + a); - }*/ - } - static void test1(string[] args) { InitialSessionState iss = InitialSessionState.CreateDefault2(); @@ -525,50 +506,8 @@ namespace ps_hello_world } } - public static int UnmanagedMain(int argc, [MarshalAs(UnmanagedType.LPArray,ArraySubType=UnmanagedType.LPStr,SizeParamIndex=0)] String[] argv) - { - init(); - List allArgs = new List(); - - for (int i = 0; i < argc; ++i) - { - allArgs.Add(argv[i]); - } - - List filteredArgs = new List(); - if (allArgs.Count > 0) - { - for (int i = 0; i < allArgs.Count; ++i) - { - string arg = allArgs[i]; - bool hasNext = (i+1)