2016-06-30 18:20:11 +03:00
using System ;
2017-09-29 02:25:32 +03:00
using System.Reflection ;
using System.Threading.Tasks ;
2016-06-30 18:20:11 +03:00
using MonoDevelop.Core.Execution ;
2017-09-29 02:25:32 +03:00
using RollbarDotNet ;
2016-06-30 18:20:11 +03:00
namespace XUnitRunner
{
class MainClass
{
public static void Main ( string [ ] args )
{
2017-06-16 21:41:22 +03:00
if ( args . Length = = 1 )
{
XUnitRunner . PreloadAssemblies ( ) ;
var runner = new XUnitRunner ( ) ;
var info = runner . GetTestInfo ( args [ 0 ] , null ) ;
return ;
}
2017-09-29 02:25:32 +03:00
RegisterRollbar ( ) ;
2016-06-30 18:20:11 +03:00
XUnitRunner . PreloadAssemblies ( ) ;
RemoteProcessServer server = new RemoteProcessServer ( ) ;
2017-06-16 21:41:22 +03:00
server . Connect ( args , new RemoteXUnitRunner ( server ) ) ;
2016-06-30 18:20:11 +03:00
}
2017-09-29 02:25:32 +03:00
private static void RegisterRollbar ( )
{
2017-09-29 04:30:59 +03:00
// IMPORTANT: if no .runsettings file is found, use the extension setting from environment variable.
var enabledString = Environment . GetEnvironmentVariable ( "MONODEVELOP_XUNIT_ROLLBAR_ENABLED" ) ? . ToUpperInvariant ( ) ;
if ( enabledString = = null ) {
// IMPORTANT: by default enable rollbar.
2017-11-14 05:12:09 +03:00
enabledString = "FALSE" ;
2017-09-29 04:30:59 +03:00
}
bool enabled ;
if ( ! bool . TryParse ( enabledString , out enabled ) ) {
enabled = true ;
}
if ( ! enabled ) {
return ;
}
2017-11-14 05:12:09 +03:00
Console . WriteLine ( $"This extension uses Rollbar to log information. To enable logging, set environment variable MONODEVELOP_XUNIT_ROLLBAR_ENABLED to TRUE" ) ;
2017-09-29 04:30:59 +03:00
2017-09-29 02:25:32 +03:00
Rollbar . Init ( new RollbarConfig {
2017-11-14 05:12:09 +03:00
AccessToken = "375079eb85e54e388ef1a336a6bdc353" ,
2017-09-29 02:25:32 +03:00
Environment = "production"
} ) ;
var version = Assembly . GetExecutingAssembly ( ) . GetName ( ) . Version . ToString ( ) ;
var userName = $"{version}" ;
Rollbar . PersonData ( ( ) = > new Person ( version ) {
UserName = userName
} ) ;
AppDomain . CurrentDomain . UnhandledException + = ( sender , args ) = > {
Rollbar . Report ( args . ExceptionObject as System . Exception ) ;
} ;
TaskScheduler . UnobservedTaskException + = ( sender , args ) = > {
Rollbar . Report ( args . Exception ) ;
} ;
}
2016-06-30 18:20:11 +03:00
}
}