6
6
using System . Diagnostics ;
7
7
using System . IO ;
8
8
using System . Linq ;
9
- using System . Runtime . InteropServices ;
10
9
using System . Text ;
11
10
using System . Threading ;
12
11
using Xunit ;
12
+ using static Microsoft . JavaScript . NodeApi . Test . TestUtils ;
13
13
14
14
namespace Microsoft . JavaScript . NodeApi . Test ;
15
15
@@ -30,39 +30,14 @@ internal static class TestBuilder
30
30
"Release" ;
31
31
#endif
32
32
33
- public static string RepoRootDirectory { get ; } = GetRootDirectory ( ) ;
33
+ public static string RepoRootDirectory { get ; } = GetRepoRootDirectory ( ) ;
34
34
35
35
public static string TestCasesDirectory { get ; } = GetTestCasesDirectory ( ) ;
36
36
37
- private static string GetRootDirectory ( )
38
- {
39
- string ? solutionDir = Path . GetDirectoryName (
40
- #if NETFRAMEWORK
41
- new Uri ( typeof ( TestBuilder ) . Assembly . CodeBase ) . LocalPath ) ! ;
42
- #else
43
- #pragma warning disable IL3000 // Assembly.Location returns an empty string for assemblies embedded in a single-file app
44
- typeof ( TestBuilder ) . Assembly . Location ) ! ;
45
- #pragma warning restore IL3000
46
- #endif
47
-
48
- // This assumes there is only a .SLN file at the root of the repo.
49
- while ( Directory . GetFiles ( solutionDir , "*.sln" ) . Length == 0 )
50
- {
51
- solutionDir = Path . GetDirectoryName ( solutionDir ) ;
52
-
53
- if ( string . IsNullOrEmpty ( solutionDir ) )
54
- {
55
- throw new DirectoryNotFoundException ( "Solution directory not found." ) ;
56
- }
57
- }
58
-
59
- return solutionDir ;
60
- }
61
-
62
37
private static string GetTestCasesDirectory ( )
63
38
{
64
39
// This assumes tests are organized in this test/TestCases directory structure.
65
- string testCasesDir = Path . Combine ( GetRootDirectory ( ) , "test" , "TestCases" ) ;
40
+ string testCasesDir = Path . Combine ( GetRepoRootDirectory ( ) , "test" , "TestCases" ) ;
66
41
67
42
if ( ! Directory . Exists ( testCasesDir ) )
68
43
{
@@ -141,33 +116,6 @@ public static string GetRunLogFilePath(string prefix, string moduleName, string
141
116
return Path . Combine ( logDir , $ "{ prefix } -{ Path . GetFileName ( testCasePath ) } .log") ;
142
117
}
143
118
144
- public static string GetCurrentPlatformRuntimeIdentifier ( )
145
- {
146
- string os = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ? "win" :
147
- RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) ? "osx" :
148
- RuntimeInformation . IsOSPlatform ( OSPlatform . Linux ) ? "linux" :
149
- throw new PlatformNotSupportedException (
150
- "Platform not supported: " + Environment . OSVersion . Platform ) ;
151
-
152
- string arch = RuntimeInformation . ProcessArchitecture switch
153
- {
154
- Architecture . X86 => "x86" ,
155
- Architecture . X64 => "x64" ,
156
- Architecture . Arm64 => "arm64" ,
157
- _ => throw new PlatformNotSupportedException (
158
- "CPU architecture not supported: " + RuntimeInformation . ProcessArchitecture ) ,
159
- } ;
160
-
161
- return $ "{ os } -{ arch } ";
162
- }
163
-
164
- public static string GetCurrentFrameworkTarget ( )
165
- {
166
- Version frameworkVersion = Environment . Version ;
167
- return frameworkVersion . Major == 4 ? "net472" :
168
- $ "net{ frameworkVersion . Major } .{ frameworkVersion . Minor } ";
169
- }
170
-
171
119
public static string CreateProjectFile ( string moduleName )
172
120
{
173
121
string projectFilePath = Path . Combine (
0 commit comments