File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
LibGit2Sharp.Tests/TestHelpers Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 4
4
using System . Globalization ;
5
5
using System . IO ;
6
6
using System . Linq ;
7
+ using System . Reflection ;
7
8
using System . Text ;
8
9
using System . Text . RegularExpressions ;
9
10
using LibGit2Sharp . Core ;
@@ -172,6 +173,42 @@ protected static void InconclusiveIf(Func<bool> predicate, string message)
172
173
throw new SkipException ( message ) ;
173
174
}
174
175
176
+ protected void RequiresDotNetOrMonoGreaterThanOrEqualTo ( Version minimumVersion )
177
+ {
178
+ Type type = Type . GetType ( "Mono.Runtime" ) ;
179
+
180
+ if ( type == null )
181
+ {
182
+ // We're running on top of .Net
183
+ return ;
184
+ }
185
+
186
+ MethodInfo displayName = type . GetMethod ( "GetDisplayName" , BindingFlags . NonPublic | BindingFlags . Static ) ;
187
+
188
+ if ( displayName == null )
189
+ {
190
+ throw new InvalidOperationException ( "Cannot access Mono.RunTime.GetDisplayName() method." ) ;
191
+ }
192
+
193
+ var version = ( string ) displayName . Invoke ( null , null ) ;
194
+
195
+ Version current ;
196
+
197
+ try
198
+ {
199
+ current = new Version ( version . Split ( ' ' ) [ 0 ] ) ;
200
+ }
201
+ catch ( Exception e )
202
+ {
203
+ throw new Exception ( string . Format ( "Cannot parse Mono version '{0}'." , version ) , e ) ;
204
+ }
205
+
206
+ InconclusiveIf ( ( ) => current < minimumVersion ,
207
+ string . Format (
208
+ "Current Mono version is {0}. Minimum required version to run this test is {1}." ,
209
+ current , minimumVersion ) ) ;
210
+ }
211
+
175
212
protected static void AssertValueInConfigFile ( string configFilePath , string regex )
176
213
{
177
214
var text = File . ReadAllText ( configFilePath ) ;
You can’t perform that action at this time.
0 commit comments