public StateController(ISignboardRepository signboardRepository, IDeviceRepository deviceRepository, ICompanyRepository companyRepository, ILoggingComponent loggingComponent) { SignboardRepository = signboardRepository; DeviceRepository = deviceRepository; CompanyRepository = companyRepository; LoggingComponent = loggingComponent; }
private Debuggee(ILoggingComponent logger, ICompilerSettings settings, string debuggeeName, int debuggeeMoniker, string outputName, CompilerOutputType outputType) { Parameter.ThrowIfNull(logger, nameof(logger)); Parameter.ThrowIfNullOrWhiteSpace(debuggeeName, nameof(debuggeeName)); Parameter.ThrowIfNegativeOrZero(debuggeeMoniker, nameof(debuggeeMoniker)); Parameter.ThrowIfNull(settings, nameof(settings)); this.OutputHelper = logger.OutputHelper; this.compilerDefineConstants = new Dictionary <string, string>(); this.debuggeeName = debuggeeName; this.debuggeeMoniker = debuggeeMoniker; this.CompilerOptions = CompilerOption.GenerateSymbols; this.libraries = new List <string>(); this.outputType = outputType; this.settings = settings; this.sourceFilePaths = new List <string>(); if (String.IsNullOrEmpty(outputName)) { // If the outputName was not provided, assume it is called "a.out" and update the extension outputName = Debuggee.UpdateOutputName("a.out", outputType); } else if (String.IsNullOrEmpty(Path.GetExtension(outputName))) { // If the outputName has no extension, add the appropriate extension outputName = Debuggee.UpdateOutputName(outputName, outputType); } this.outputName = outputName; }
/// <summary> /// Creates a new debuggee instance. This will copy the debuggee into a new folder based on the debuggeeMoniker. /// This should only be called once per debuggee. /// </summary> public static IDebuggee Create(ILoggingComponent logger, ICompilerSettings settings, string debuggeeName, int debuggeeMoniker, string outputName = null, CompilerOutputType outputType = CompilerOutputType.Executable) { Debuggee newDebuggee = new Debuggee(logger, settings, debuggeeName, debuggeeMoniker, outputName, outputType); newDebuggee.CopySource(); return(newDebuggee); }
public BusinessService(ILoggingComponent loggingComponent, IWebServiceProxy webServiceProxy, IDataAccessComponent dataAccessComponent) { _loggingComponent = loggingComponent; _webServiceProxy = webServiceProxy; _dataAccessComponent = dataAccessComponent; }
public BusinessService(IDataAccessComponent dataAccessComponent, IWebServiceProxy webServiceProxy, ILoggingComponent loggingComponent) { _loggingComponent = loggingComponent; _webServiceProxy = webServiceProxy; _dataAccessComponent = dataAccessComponent; }
/// <summary> /// Open existing debuggee /// </summary> private static IDebuggee OpenDebuggee(ILoggingComponent logger, ITestSettings settings, int debuggeeMoniker) { lock (syncObject) { IDebuggee debuggee = Debuggee.Open(logger, settings.CompilerSettings, debuggeeName, debuggeeMoniker, outAppName); Assert.True(File.Exists(debuggee.OutputPath), "The debuggee was not compiled. Missing " + debuggee.OutputPath); return(debuggee); } }
public CompilerBase(ILoggingComponent logger, ICompilerSettings settings, bool addDebuggerDirToPath) { Parameter.ThrowIfNull(logger, nameof(logger)); Parameter.ThrowIfNull(settings, nameof(settings)); this.addDebuggerDirToPath = addDebuggerDirToPath; this.OutputHelper = logger.OutputHelper; this.Settings = settings; }
public static IDebuggee Open(ILoggingComponent logger, ICompilerSettings settings, int moniker, string name, string outputname) { lock (s_lock) { IDebuggee debuggee = Debuggee.Open(logger, settings, name, moniker, outputname); Assert.True(File.Exists(debuggee.OutputPath), "The debuggee was not compiled. Missing " + debuggee.OutputPath); return(debuggee); } }
/// <summary> /// Log a message commenting on what the overall purpose of the test /// </summary> public static void TestPurpose(this ILoggingComponent component, string message) { string timestamp = GetTimestamp(); string commentLine = new string('#', message.Length + timestamp.Length + 4); component.WriteLine(commentLine); component.WriteLine("# {0}{1} #", message, timestamp); component.WriteLine(commentLine); }
/// <summary> /// Create the debuggee and compile the application /// </summary> private static IDebuggee CompileApp(ILoggingComponent logger, ITestSettings settings, int debuggeeMoniker) { lock (syncObject) { IDebuggee debuggee = Debuggee.Create(logger, settings.CompilerSettings, debuggeeName, debuggeeMoniker, outAppName); debuggee.AddSourceFiles(srcClassName, srcAppName); debuggee.Compile(); return(debuggee); } }
public static void WriteLines(this ILoggingComponent component, StreamReader reader) { Parameter.ThrowIfNull(reader, nameof(reader)); string line = null; while (null != (line = reader.ReadLine())) { component.WriteLine(line); } }
public static IDebuggee OpenAndCompile(ILoggingComponent logger, ICompilerSettings settings, int moniker, string name, string outputname, Action <IDebuggee> addSourceFiles) { Assert.NotNull(addSourceFiles); lock (s_lock) { IDebuggee debuggee = Debuggee.Create(logger, settings, name, moniker, outputname); addSourceFiles(debuggee); debuggee.Compile(); return(debuggee); } }
public StructuresController(IDeviceRepository deviceRepository, ISignboardRepository signboardRepository, ISlideshowRepository slideshowRepository, IWidgetDefinitionRepository widgetDefinitionRepository, IAnnouncementRepository announcementRepository, IDiagnosticsComponent diagnosticsComponent, ILoggingComponent loggingComponent) { DeviceRepository = deviceRepository; SignboardRepository = signboardRepository; SlideshowRepository = slideshowRepository; WidgetDefinitionRepository = widgetDefinitionRepository; AnnouncementRepository = announcementRepository; DiagnosticsComponent = diagnosticsComponent; LoggingComponent = loggingComponent; }
private static CompilerBase CreateCompiler(ILoggingComponent logger, ICompilerSettings settings) { switch (settings.CompilerType) { case SupportedCompiler.GPlusPlus: return(new GppCompiler(logger, settings)); case SupportedCompiler.ClangPlusPlus: return(new ClangCompiler(logger, settings)); case SupportedCompiler.VisualCPlusPlus: return(new VisualCPlusPlusCompiler(logger, settings)); default: throw new ArgumentOutOfRangeException(nameof(settings.CompilerType), "Unhandled compiler toolset: " + settings.CompilerType); } }
public static void WriteLine(this ILoggingComponent component, string message = "", params object[] args) { // Invalid XML characters cause xUnit not to write the whole results file // For now we only handle null characters since that's what's causing issues and // this is just a temporary workaround. // See https://github.com/xunit/xunit/issues/876#issuecomment-253337669 if (!string.IsNullOrEmpty(message)) { message = message.Replace("\0", "<null>"); } if (args.Length > 0) { component?.OutputHelper?.WriteLine(message, args); } else { component?.OutputHelper?.WriteLine(message); } }
private DebuggerRunner(ILoggingComponent logger, ITestSettings testSettings, IEnumerable <Tuple <string, CallbackRequestHandler> > callbackHandlers) { Parameter.ThrowIfNull(testSettings, nameof(testSettings)); this.OutputHelper = logger.OutputHelper; this.DebuggerSettings = testSettings.DebuggerSettings; #if DEBUG this.savedDebugFailUI = UDebug.DebugFailUI; UDebug.DebugFailUI = new XUnitDefaultDebugFailUI(this.OutputHelper); #endif this.WriteLine("Creating Debug Adapter Runner."); string adapterId = (this.DebuggerSettings.DebuggerType == SupportedDebugger.VsDbg) ? "cppvsdbg" : "cppdbg"; string debugAdapterRelativePath = this.DebuggerSettings.DebuggerAdapterPath ?? "OpenDebugAD7"; string debugAdapterFullPath = Path.Combine(PathSettings.DebugAdaptersPath, debugAdapterRelativePath); Assert.True(Directory.Exists(Path.GetDirectoryName(debugAdapterFullPath)), "Debug Adapter Path {0} does not exist.".FormatInvariantWithArgs(debugAdapterFullPath)); // Output engine log to temp folder if requested. this.engineLogPath = Path.Combine(PathSettings.TempPath, "EngineLog-{0}-{1}-{2}.log".FormatInvariantWithArgs(testSettings.Name, testSettings.DebuggerSettings.DebuggeeArchitecture.ToString(), testSettings.DebuggerSettings.DebuggerType.ToString())); this.WriteLine("Logging engine to: {0}", this.engineLogPath); this.DarRunner = new DarRunner( adapterPath: debugAdapterFullPath, traceDebugAdapterOutput: DiagnosticsSettings.LogDebugAdapter ? DebugAdapterRunner.TraceDebugAdapterMode.Memory : DebugAdapterRunner.TraceDebugAdapterMode.None, engineLogPath: this.engineLogPath, pauseForDebugger: false, isVsDbg: this.DebuggerSettings.DebuggerType == SupportedDebugger.VsDbg, isNative: true, responseTimeout: 5000); if (callbackHandlers != null) { foreach (Tuple <string, CallbackRequestHandler> handlerPair in callbackHandlers) { this.DarRunner.AddCallbackRequestHandler(handlerPair.Item1, handlerPair.Item2); } } this.WriteLine("Initializing debugger."); this.initializeResponse = this.RunCommand(new InitializeCommand(adapterId)); }
public CompaniesController(ICompanyRepository companyRepository, ILoggingComponent loggingComponent) { CompanyRepository = companyRepository; LoggingComponent = loggingComponent; }
public static IDebuggee OpenAndCompile(ILoggingComponent logger, ICompilerSettings settings, int moniker) { return(DebuggeeHelper.OpenAndCompile(logger, settings, moniker, SinkHelper.Name, SinkHelper.OutputName, SinkHelper.AddSourceFiles)); }
public ScreenshotsController(IDeviceRepository deviceRepository, IScreenshotComponent screensaverComponent, ILoggingComponent loggingComponent) { DeviceRepository = deviceRepository; ScreensaverComponent = screensaverComponent; LoggingComponent = loggingComponent; }
public VisualCPlusPlusCompiler(ILoggingComponent logger, ICompilerSettings settings) : base(logger, settings, addDebuggerDirToPath: false) { }
public ProcessCleanupHelper(ILoggingComponent logger, Process process) { this.logger = logger; this.process = process; }
/// <summary> /// Log a message commenting on what the test is currently trying to accomplish. /// </summary> public static void Comment(this ILoggingComponent component, string message, params object[] args) { component.WriteLine(); component.WriteLine("# " + message + GetTimestamp(), args); }
public SqlProvider(ILoggingComponent logger) { _logger = logger; }
public OracleProvider(ILoggingComponent logger) { _logger = logger; }
public ImagesController(IImageComponent imageComponent, ILoggingComponent loggingComponent) { ImageComponent = imageComponent; LoggingComponennt = loggingComponent; }
public DiBusinessLibrary(IDbProvider dbProvider, IProxy proxy, ILoggingComponent logger) { _dbProvider = dbProvider; _proxy = proxy; _logger = logger; }
/// <summary> /// Log a message with details on the tests current settings /// </summary> public static void WriteSettings(this ILoggingComponent component, ITestSettings testSettings) { component.WriteLine("Test: {0}", testSettings.Name); component.WriteLine(testSettings.CompilerSettings.ToString()); component.WriteLine(testSettings.DebuggerSettings.ToString()); }
/// <summary> /// Provides a way to assure a process will is closed or killed when dispose is called /// </summary> public static IDisposable ProcessCleanup(ILoggingComponent logger, Process p) { return new ProcessCleanupHelper(logger, p); }
/// <summary> /// Opens an existing debuggee instance. /// </summary> public static IDebuggee Open(ILoggingComponent logger, ICompilerSettings settings, string debuggeeName, int debuggeeMoniker, string outputName = null, CompilerOutputType outputType = CompilerOutputType.Executable) { return(new Debuggee(logger, settings, debuggeeName, debuggeeMoniker, outputName, outputType)); }
public static IDebuggerRunner Create(ILoggingComponent logger, ITestSettings testSettings, IEnumerable <Tuple <string, CallbackRequestHandler> > callbackHandlers) { return(new DebuggerRunner(logger, testSettings, callbackHandlers)); }
public TimetablesController(ITimetableComponent timetableComponent, ILoggingComponent loggingComponent) { TimetableComponent = timetableComponent; LoggingComponent = loggingComponent; }
public StaticDependencyBusinessLibrary() { _logger = new LoggingComponent(); _dbProvider = new SqlProvider(_logger); _proxy = new TestProxy(); }
public GlobalExceptionFilterAttribute(ILoggingComponent logging) { Logging = logging; }
/// <summary> /// Runs a command against the debugger. /// </summary> /// <param name="command">The command to run.</param> /// <param name="expectedEvents">[OPTIONAL] If the command causes an event to occur, pass the expected event(s)</param> private void Run(DarRunner darRunner, ILoggingComponent log, params IEvent[] expectedEvents) { Parameter.ThrowIfNull(darRunner, nameof(darRunner)); log?.WriteLine("Running command {0}", this.ToString()); log?.WriteLine("Command '{0}' expecting response: {1}", this.Name, this.ExpectedResponse.ToString()); DebugAdapterResponse darCommandResponse = GetDarResponse(this.ExpectedResponse); DebugAdapterCommand darCommand = new DebugAdapterCommand( this.Name, this.Args, new[] { darCommandResponse }); List <Tuple <DebugAdapterResponse, IEvent> > darEventMap = new List <Tuple <DebugAdapterResponse, IEvent> >(expectedEvents.Length); // Add additional expected events to match if requested if (expectedEvents != null && expectedEvents.Length > 0) { if (expectedEvents.Length > 1) { log?.WriteLine("Command '{0}' expecting {1} events:", this.Name, expectedEvents.Length); } foreach (var expectedEvent in expectedEvents) { DebugAdapterResponse darEventResponse = GetDarResponse(expectedEvent); darCommand.ExpectedResponses.Add(darEventResponse); darEventMap.Add(Tuple.Create(darEventResponse, expectedEvent)); // Debug info for expected response string eventMessage = expectedEvents.Length > 1 ? " - {1}" : "Command '{0}' expecting event: {1}"; log?.WriteLine(eventMessage, this.Name, expectedEvent.ToString()); } } // Allow the command to override the timeout int overrideTimeout = Convert.ToInt32(this.Timeout.TotalMilliseconds); int savedTimeout = darRunner.ResponseTimeout; try { if (overrideTimeout > 0) { darRunner.ResponseTimeout = overrideTimeout; log?.WriteLine("Command '{0}' timeout set to {1:n0} seconds.", this.Name, this.Timeout.TotalSeconds); } darCommand.Run(darRunner); // Allow the command to retrieve properties from the actual matched response. string responseJson = JsonConvert.SerializeObject(darCommandResponse.Match); if (!string.IsNullOrWhiteSpace(responseJson)) { this.ProcessActualResponse(new ActualResponse(responseJson)); } // Allow the events to retrieve properties from the actual event. foreach (var darEvent in darEventMap) { string eventJson = JsonConvert.SerializeObject(darEvent.Item1.Match); darEvent.Item2.ProcessActualResponse(new ActualResponse(eventJson)); } } catch (Exception ex) { // Add information to the log when the exception occurs log?.WriteLine("ERROR: Running command '{0}'. Exception thrown.", this.Name); log?.WriteLine(UDebug.ExceptionToString(ex)); // The DARException is not serializable, create a new exception if (ex is DARException) { throw new RunnerException(ex.Message); } else { throw; } } finally { if (overrideTimeout > 0) { darRunner.ResponseTimeout = savedTimeout; } } }
public static IDebuggee Open(ILoggingComponent logger, ICompilerSettings settings, int moniker) { return(DebuggeeHelper.Open(logger, settings, moniker, SourceMappingHelper.Name, SourceMappingHelper.OutputName)); }
public GppCompiler(ILoggingComponent logger, ICompilerSettings settings) : base(logger, settings) { }
public DbProvider(ILoggingComponent logger) { _logger = logger; }
public GppStyleCompiler(ILoggingComponent logger, ICompilerSettings settings) : base(logger, settings, PlatformUtilities.IsWindows) { }
public RequestsController(ISignboardRepository signboardRepository, IDeviceRepository deviceRepository, ILoggingComponent loggingComponent) { SignboardRepository = signboardRepository; DeviceRepository = deviceRepository; LoggingComponent = loggingComponent; }