Esempio n. 1
0
        /// <summary>
        /// Publish test run to pipeline
        /// </summary>
        public async Task PublishAsync(TestRun testRun)
        {
            _telemetry.AddAndAggregate(TelemetryConstants.TotalRunsDetected, 1);

            var validatedTestRun = ValidateAndPrepareForPublish(testRun);

            if (validatedTestRun != null)
            {
                _telemetry.AddAndAggregate(TelemetryConstants.ValidRunsDetected, 1);
                var task = _publisher.PublishAsync(validatedTestRun);
                _runningTasks.Add(task);
                await task;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Default implemenation that checks for the constraint for the next expected match
        /// If the number of lines within which the next match expected falls to 0 this resets the parser
        /// </summary>
        /// <param name="line">Current line</param>
        /// <param name="stateContext">State context object containing information of the parser's state</param>
        /// <returns>True if the parser was reset</returns>>
        public virtual bool PeformNoPatternMatchedAction(string line, AbstractParserStateContext stateContext)
        {
            // This is a mechanism to enforce matches that have to occur within
            // a specific number of lines after encountering the previous match
            // one obvious usage is for successive summary lines containing passed,
            // pending and failed test summary
            if (stateContext.LinesWithinWhichMatchIsExpected == 1)
            {
                Logger.Info($"{ParserName} : {StateName} : NoPatternMatched : Was expecting {stateContext.NextExpectedMatch} before line {stateContext.CurrentLineNumber}, but no matches occurred.");
                Telemetry.AddAndAggregate("UnexpectedParserResetCount", 1, ParserName);
                AttemptPublishAndResetParser();
                return(true);
            }

            // If no match occurred and a match was expected in a positive number of lines, decrement the counter
            // A value of zero or lesser indicates not expecting a match
            if (stateContext.LinesWithinWhichMatchIsExpected > 1)
            {
                stateContext.LinesWithinWhichMatchIsExpected--;
            }

            return(false);
        }