コード例 #1
0
        /// <summary>
        /// Attempts to match the line with each regex specified by the current state
        /// </summary>
        /// <param name="state">Current state</param>
        /// <param name="logData">Input line</param>
        /// <returns>true if a match occurs</returns>
        private bool AttemptMatch(ITestResultParserState state, LogData logData)
        {
            foreach (var regexActionPair in state.RegexesToMatch)
            {
                try
                {
                    var match = regexActionPair.Regex.Match(logData.Line);
                    if (match.Success)
                    {
                        // Reset this value on a match
                        _stateContext.LinesWithinWhichMatchIsExpected = -1;

                        _currentState = (JestParserStates)regexActionPair.MatchAction(match, _stateContext);
                        return(true);
                    }
                }
                catch (RegexMatchTimeoutException)
                {
                    Logger.Warning($"JestTestResultParser : AttemptMatch : failed due to timeout while trying to match" +
                                   $" { regexActionPair.Regex.ToString() } at line {logData.LineNumber}");
                    Telemetry.AddAndAggregate("RegexTimeout",
                                              new List <string> {
                        regexActionPair.Regex.ToString()
                    }, JestTelemetryConstants.EventArea);
                }
            }

            state.PeformNoPatternMatchedAction(logData.Line, _stateContext);

            return(false);
        }
コード例 #2
0
        /// <summary>
        /// Attempts to match the line with each regex specified by the current state
        /// </summary>
        /// <param name="state">Current state</param>
        /// <param name="testResultsLine">Input line</param>
        /// <returns>True if a match occurs</returns>
        private bool AttemptMatch(ITestResultParserState state, LogData testResultsLine)
        {
            foreach (var regexActionPair in state.RegexsToMatch)
            {
                var match = regexActionPair.Regex.Match(testResultsLine.Message);
                if (match.Success)
                {
                    this.currentState = (MochaParserStates)regexActionPair.MatchAction(match, this.stateContext);
                    return(true);
                }
            }

            return(false);
        }
コード例 #3
0
        /// <summary>
        /// Detailed constructor where specified logger and telemetry data collector are initialized along with test run manager
        /// </summary>
        /// <param name="testRunPublisher"></param>
        /// <param name="diagnosticDataCollector"></param>
        /// <param name="telemetryDataCollector"></param>
        public MochaTestResultParser(ITestRunManager testRunManager, ITraceLogger logger, ITelemetryDataCollector telemetryDataCollector) : base(testRunManager, logger, telemetryDataCollector)
        {
            logger.Info("MochaTestResultParser : Starting mocha test result parser.");
            telemetryDataCollector.AddToCumulativeTelemetry(MochaTelemetryConstants.EventArea, MochaTelemetryConstants.Initialize, true);

            // Initialize the starting state of the parser
            var testRun = new TestRun($"{Name}/{Version}", 1);

            this.stateContext = new MochaParserStateContext(testRun);
            this.currentState = MochaParserStates.ExpectingTestResults;

            this.expectingTestResults    = new MochaExpectingTestResults(AttemptPublishAndResetParser, logger, telemetryDataCollector);
            this.expectingTestRunSummary = new MochaExpectingTestRunSummary(AttemptPublishAndResetParser, logger, telemetryDataCollector);
            this.expectingStackTraces    = new MochaExpectingStackTraces(AttemptPublishAndResetParser, logger, telemetryDataCollector);
        }