Remove Env helper class in tests
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 2 Nov 2015 12:48:31 +0000 (13:48 +0100)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 2 Nov 2015 19:42:50 +0000 (20:42 +0100)
It's not used in a lot of places and just makes life more complicated, because
Utilities.IsWindows is hardcoded to true right now (which should be fixed separately).

See https://github.com/dotnet/coreclr/pull/1907 for some details.

15 files changed:
tests/src/Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj
tests/src/Common/CoreCLRTestLibrary/Env.cs [deleted file]
tests/src/Common/CoreCLRTestLibrary/TestFramework.cs
tests/src/CoreMangLib/cti/system/argumentoutofrangeexception/argumentoutofrangeexceptionctor2.cs
tests/src/CoreMangLib/cti/system/argumentoutofrangeexception/argumentoutofrangeexceptionmessage.cs
tests/src/CoreMangLib/cti/system/io/path/pathaltdirectoryseparatorchar.cs
tests/src/CoreMangLib/cti/system/io/path/pathcombine.cs
tests/src/CoreMangLib/cti/system/io/path/pathdirectoryseparatorchar.cs
tests/src/CoreMangLib/cti/system/io/path/pathgetdirectoryname.cs
tests/src/CoreMangLib/cti/system/io/path/pathpathseparator.cs
tests/src/CoreMangLib/cti/system/io/path/pathvolumeseparatorchar.cs
tests/src/CoreMangLib/cti/system/objectdisposedexception/objectdisposedexceptionmessage.cs
tests/src/CoreMangLib/cti/system/runtime/compilerservices/internalsvisibletoattribute/internalsvisibletoattributeassemblyname.cs
tests/src/JIT/Directed/intrinsic/pow/pow1.cs
tests/src/baseservices/exceptions/unittests/trace.cs

index 2043f5d..f0c88c0 100644 (file)
@@ -32,7 +32,6 @@
   <ItemGroup>
     <Compile Include="CalendarHelpers.cs" />
     <Compile Include="EndianessChecker.cs" />
-    <Compile Include="Env.cs" />
     <Compile Include="Generator.cs" />
     <Compile Include="GlobLocHelper.cs" />
     <Compile Include="Logging.cs" />
diff --git a/tests/src/Common/CoreCLRTestLibrary/Env.cs b/tests/src/Common/CoreCLRTestLibrary/Env.cs
deleted file mode 100644 (file)
index e7f1819..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-using System;
-using System.IO;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Security;
-using System.Text;
-
-namespace TestLibrary
-{
-    public static partial class Env
-    {
-        const int MAX_PATH = 260;
-        const int ERROR_ENVVAR_NOT_FOUND = 0xCB;
-
-        public static string NewLine
-        {
-            get
-            {
-                if (Utilities.IsWindows)
-                {
-                    return "\r\n";
-                }
-                else
-                {
-                    return "\n";
-                }
-            }
-        }
-
-        public static string FileSeperator
-        {
-            get
-            {
-                if (Utilities.IsWindows)
-                {
-                    return "\\";
-                }
-                else
-                {
-                    return "/";
-                }
-            }
-        }
-
-        public static string VolumeSeperator
-        {
-            get
-            {
-                if (Utilities.IsWindows)
-                {
-                    return ":";
-                }
-                else
-                {
-                    return "/";
-                }
-            }
-        }
-
-        public static string AltFileSeperator
-        {
-            get
-            {
-                if (Utilities.IsWindows)
-                {
-                    return "/";
-                }
-                else
-                {
-                    return "\\";
-                }
-            }
-        }
-
-        public static string PathDelimiter
-        {
-            get
-            {
-                if (Utilities.IsWindows)
-                {
-                    return ";";
-                }
-                else
-                {
-                    return ":";
-                }
-            }
-        }
-
-        public static int MaxPath
-        {
-            get
-            {
-                return 248;
-            }
-        }
-
-        public static int MaxFileName
-        {
-            get
-            {
-                return 260;
-            }
-        }
-
-        public static String CurrentDirectory
-        {
-            get { return ""; }
-        }
-    }
-}
index ff094a3..7208009 100644 (file)
@@ -29,11 +29,11 @@ namespace TestLibrary
 #else
             Random rand = new Random();
 
-            if (Env.GetEnvVariable("CORECLR_SEED") != null)
+            if (Environment.GetEnvironmentVariable("CORECLR_SEED") != null)
             {
                 try
                 {
-                    seed = int.Parse(Env.GetEnvVariable("CORECLR_SEED"));
+                    seed = int.Parse(Environment.GetEnvironmentVariable("CORECLR_SEED"));
                 }
                 catch (FormatException) { seed = rand.Next(); }
             }
index 88e37e8..ce5632d 100644 (file)
@@ -37,7 +37,7 @@ public class ArgumentOutOfRangeExceptionCtor2
                 TestLibrary.TestFramework.LogError("001", "The result is not the value as expected");
                 retVal = false;
             }
-            if ((argumentOutOfRangeException.Message != "Specified argument was out of the range of valid values."+TestLibrary.Env.NewLine+"Parameter name: " + randValue) &
+            if ((argumentOutOfRangeException.Message != "Specified argument was out of the range of valid values."+Environment.NewLine+"Parameter name: " + randValue) &
                 (!argumentOutOfRangeException.Message.Contains("[Arg_ArgumentOutOfRangeException]")))
             {
                 TestLibrary.TestFramework.LogError("002", "The result is not the value as expected" + argumentOutOfRangeException.Message);
index 2045699..9d0e755 100644 (file)
@@ -34,7 +34,7 @@ public class ArgumentOutOfRangeExceptionMessage
         {
             string randValue = TestLibrary.Generator.GetString(-55, false, c_MIN_STRING_LENGTH, c_MAX_STRING_LENGTH);
             ArgumentOutOfRangeException argumentOutOfRangeException = new ArgumentOutOfRangeException(randValue);
-            if ((argumentOutOfRangeException.Message != "Specified argument was out of the range of valid values." + TestLibrary.Env.NewLine + "Parameter name: " + randValue) &
+            if ((argumentOutOfRangeException.Message != "Specified argument was out of the range of valid values." + Environment.NewLine + "Parameter name: " + randValue) &
                 (!argumentOutOfRangeException.Message.Contains("[Arg_ArgumentOutOfRangeException]")))
             {
                 TestLibrary.TestFramework.LogError("001", "The result is not the value as expected");
@@ -61,7 +61,7 @@ public class ArgumentOutOfRangeExceptionMessage
             string randValue = TestLibrary.Generator.GetString(-55, false, c_MIN_STRING_LENGTH, c_MAX_STRING_LENGTH);
             string paramName = TestLibrary.Generator.GetString(-55, false, c_MIN_STRING_LENGTH, c_MAX_STRING_LENGTH);
             ArgumentOutOfRangeException argumentOutOfRangeException = new ArgumentOutOfRangeException(paramName, randValue);
-            if ((argumentOutOfRangeException.Message != randValue + "" + TestLibrary.Env.NewLine + "Parameter name: " + paramName) &
+            if ((argumentOutOfRangeException.Message != randValue + "" + Environment.NewLine + "Parameter name: " + paramName) &
                 (argumentOutOfRangeException.Message != randValue))
             {
                 TestLibrary.TestFramework.LogError("003", "The result is not the value as expected");
@@ -88,7 +88,7 @@ public class ArgumentOutOfRangeExceptionMessage
             string paramName = TestLibrary.Generator.GetString(-55, false, c_MIN_STRING_LENGTH, c_MAX_STRING_LENGTH);
             string Value = null;
             ArgumentOutOfRangeException argumentOutOfRangeException = new ArgumentOutOfRangeException(paramName, Value);
-            if ((argumentOutOfRangeException.Message != "Exception of type 'System.ArgumentOutOfRangeException' was thrown." + TestLibrary.Env.NewLine + "Parameter name: " + paramName) &
+            if ((argumentOutOfRangeException.Message != "Exception of type 'System.ArgumentOutOfRangeException' was thrown." + Environment.NewLine + "Parameter name: " + paramName) &
                 (argumentOutOfRangeException.Message != "Exception of type 'System.ArgumentOutOfRangeException' was thrown."))
             {
                 TestLibrary.TestFramework.LogError("005", "The result is not the value as expected");
index 8db8ac5..e75d80f 100644 (file)
@@ -45,7 +45,7 @@ public class PathAltDirectorySeparatorChar
         const string c_TEST_DESC = "PosTest1: Verify the Path.AltDirectorySeparatorChar value is '/' ";
         const string c_TEST_ID = "P001";
 
-        char correctChar = Env.AltFileSeperator[0];
+        char correctChar = Utilities.IsWindows ? '/' : '/';
 
         TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
 
index 2bcc905..d5afdad 100644 (file)
@@ -10,6 +10,7 @@ using TestLibrary;
 /// </summary>
 public class PathCombine
 {
+    char fileSeperator = Utilities.IsWindows ? '\\' : '/';
 
     public static int Main()
     {
@@ -59,9 +60,9 @@ public class PathCombine
         const string c_TEST_DESC = "PosTest1: Verify Combine  two paths . ";
         const string c_TEST_ID = "P001";
 
-        string path1 = @"mydir" + Env.FileSeperator + "myfolder" + Env.FileSeperator + "";
-        string path2 = @"youfolder" + Env.FileSeperator + "youfile";
-        string resPath = @"mydir" + Env.FileSeperator + "myfolder" + Env.FileSeperator + "youfolder" + Env.FileSeperator + "youfile";
+        string path1 = @"mydir" + fileSeperator + "myfolder" + fileSeperator + "";
+        string path2 = @"youfolder" + fileSeperator + "youfile";
+        string resPath = @"mydir" + fileSeperator + "myfolder" + fileSeperator + "youfolder" + fileSeperator + "youfile";
         string newPath ;
 
         TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
@@ -93,9 +94,9 @@ public class PathCombine
         const string c_TEST_DESC = "PosTest2: path1 does not end with a valid separator character. ";
         const string c_TEST_ID = "P002";
 
-        string path1 = @"mydir" + Env.FileSeperator + "myfolder";
-        string path2 = @"youfolder" + Env.FileSeperator + "youfile";
-        string resPath = @"mydir" + Env.FileSeperator + "myfolder" + Env.FileSeperator + "youfolder" + Env.FileSeperator + "youfile";
+        string path1 = @"mydir" + fileSeperator + "myfolder";
+        string path2 = @"youfolder" + fileSeperator + "youfile";
+        string resPath = @"mydir" + fileSeperator + "myfolder" + fileSeperator + "youfolder" + fileSeperator + "youfile";
         string newPath;
 
         TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
@@ -128,8 +129,8 @@ public class PathCombine
         const string c_TEST_ID = "P003";
 
         string path1 = "";
-        string path2 = @"yourfolder" + Env.FileSeperator + "" + Env.FileSeperator + "youfile";
-        string resPath = @"yourfolder" + Env.FileSeperator + "" + Env.FileSeperator + "youfile";
+        string path2 = @"yourfolder" + fileSeperator + "" + fileSeperator + "youfile";
+        string resPath = @"yourfolder" + fileSeperator + "" + fileSeperator + "youfile";
         string newPath;
 
         TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
@@ -229,9 +230,9 @@ public class PathCombine
         const string c_TEST_DESC = "PosTest6: path2 have a willcard";
         const string c_TEST_ID = "P006";
 
-        string path1 = "mydir" + Env.FileSeperator + "my folder";
+        string path1 = "mydir" + fileSeperator + "my folder";
         string path2 = "*.txt";
-        string resPath = "mydir" + Env.FileSeperator + "my folder" + Env.FileSeperator + "*.txt";
+        string resPath = "mydir" + fileSeperator + "my folder" + fileSeperator + "*.txt";
         string newPath;
 
         TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
index f1b92b2..2c94db7 100644 (file)
@@ -45,7 +45,7 @@ public class PathDirectorySeparatorChar
         const string c_TEST_DESC = "PosTest1: Verify the Path.DirectorySeparatorChar value is backslash... ";
         const string c_TEST_ID = "P001";
 
-        char correctChar = Env.FileSeperator[0];
+        char correctChar = Utilities.IsWindows ? '\\' : '/';
 
         TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
 
index 9ad31c2..5ce9d9b 100644 (file)
@@ -9,6 +9,7 @@ using TestLibrary;
 public class PathGetDirectoryName
 {
     private const int c_MAX_PATH_LEN = 256;
+    char fileSeperator = Utilities.IsWindows ? '\\' : '/';
 
     public static int Main()
     {
@@ -54,8 +55,8 @@ public class PathGetDirectoryName
         const string c_TEST_DESC = "PosTest1:the source path is a file name.";
         const string c_TEST_ID = "P001";
 
-        string sourcePath = @"C:" + Env.FileSeperator + "mydir" + Env.FileSeperator + "myfolder" + Env.FileSeperator + "test.txt";
-        string directoryName = @"C:" + Env.FileSeperator + "mydir" + Env.FileSeperator + "myfolder";
+        string sourcePath = @"C:" + fileSeperator + "mydir" + fileSeperator + "myfolder" + fileSeperator + "test.txt";
+        string directoryName = @"C:" + fileSeperator + "mydir" + fileSeperator + "myfolder";
 
         TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
 
index 3772d67..94bf9e0 100644 (file)
@@ -45,7 +45,7 @@ public class PathPathSeparator
         const string c_TEST_DESC = "PosTest1: Verify the Path.PathSeparator value is semicolon ... ";
         const string c_TEST_ID = "P001";
 
-        char correctChar = Env.PathDelimiter[0];
+        char correctChar = Utilities.IsWindows ? ';' : ':';
 
         TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
 
index dd348a7..a2be825 100644 (file)
@@ -45,7 +45,7 @@ public class PathVolumeSeparatorChar
         const string c_TEST_DESC = "PosTest1: Verify the Path.VolumeSeparatorChar value is colon ... ";
         const string c_TEST_ID = "P001";
 
-        char correctChar = Env.VolumeSeperator[0];
+        char correctChar = Utilities.IsWindows ? ':' : '/';
 
         TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
 
index 948e96e..bb0d126 100644 (file)
@@ -43,9 +43,9 @@ public class ObjectDisposedExceptionMessage
                 if (index == -1)
                 {
                     string errorDesc = "Message shoule contains the object name";
-                    errorDesc += TestLibrary.Env.NewLine + "objectName is " + name;
-                    errorDesc += TestLibrary.Env.NewLine + "message is " + message;
-                    errorDesc += TestLibrary.Env.NewLine + "exception's message is " + exception.Message;
+                    errorDesc += Environment.NewLine + "objectName is " + name;
+                    errorDesc += Environment.NewLine + "message is " + message;
+                    errorDesc += Environment.NewLine + "exception's message is " + exception.Message;
                     TestLibrary.TestFramework.LogError("001 " + "TestID_" + c_TEST_ID, errorDesc);
                     retVal = false;
                 }
@@ -53,9 +53,9 @@ public class ObjectDisposedExceptionMessage
                 if (index == -1)
                 {
                     string errorDesc = "Message shoule contains the message";
-                    errorDesc += TestLibrary.Env.NewLine + "objectName is " + name;
-                    errorDesc += TestLibrary.Env.NewLine + "message is " + message;
-                    errorDesc += TestLibrary.Env.NewLine + "exception's message is " + exception.Message;
+                    errorDesc += Environment.NewLine + "objectName is " + name;
+                    errorDesc += Environment.NewLine + "message is " + message;
+                    errorDesc += Environment.NewLine + "exception's message is " + exception.Message;
                     TestLibrary.TestFramework.LogError("001 " + "TestID_" + c_TEST_ID, errorDesc);
                     retVal = false;
                 }
@@ -92,9 +92,9 @@ public class ObjectDisposedExceptionMessage
                 if (index == -1)
                 {
                     string errorDesc = "Message shoule contains the message";
-                    errorDesc += TestLibrary.Env.NewLine + "objectName is empty";
-                    errorDesc += TestLibrary.Env.NewLine + "message parameter" + message;
-                    errorDesc += TestLibrary.Env.NewLine + "exception's message is " + exception.Message;
+                    errorDesc += Environment.NewLine + "objectName is empty";
+                    errorDesc += Environment.NewLine + "message parameter" + message;
+                    errorDesc += Environment.NewLine + "exception's message is " + exception.Message;
                     TestLibrary.TestFramework.LogError("003 " + "TestID_" + c_TEST_ID, errorDesc);
                     retVal = false;
                 }
index c7d253f..49cb5bc 100644 (file)
@@ -151,7 +151,7 @@ public class InternalsVisibleToAttributeAssemblyName
 
         string assemblyName;
         string actualFriendAssemblyName;
-        assemblyName = "::B:" + TestLibrary.Env.FileSeperator + "\n\v\r\t\0myTestCase.dll";
+        assemblyName = "::B:" + System.IO.Path.DirectorySeparatorChar + "\n\v\r\t\0myTestCase.dll";
         TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
         try
         {
index ef7cfd4..faf4bcf 100644 (file)
@@ -18,11 +18,7 @@ internal class pow1
 
         string processorArchEnvVar = null;
 
-#if CORECLR 
-        processorArchEnvVar = TestLibrary.Env.GetEnvVariable("PROCESSOR_ARCHITECTURE");
-#else
         processorArchEnvVar = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
-#endif
 
         if ((processorArchEnvVar != null) && processorArchEnvVar.Equals("ARM", StringComparison.CurrentCultureIgnoreCase))
         {
index 43ca62a..d001f76 100644 (file)
@@ -24,7 +24,7 @@ public class Trace
   public void WriteLine(string str)
   {
     _actual += str;
-    _actual += Env.NewLine;
+    _actual += Environment.NewLine;
 
     // Console.WriteLine(str);
   }