Beispiel #1
0
        private static List <Message> GetResponse(DummyProcessRunner dummyProcessRunner, Request request, ILogger logger, CancellationToken cancellationToken)
        {
            var messages = new List <Message>();

            CFamilyHelper.CallClangAnalyzer(messages.Add, request, dummyProcessRunner, logger, cancellationToken);

            return(messages);
        }
Beispiel #2
0
        public void CallAnalyzer_BadResponse_Fails()
        {
            // Arrange
            var    dummyProcessRunner = new DummyProcessRunner(MockBadEndResponse(), true);
            Action act = () => CFamilyHelper.CallClangAnalyzer(new Request(), dummyProcessRunner, new TestLogger());

            // Act and Assert
            act.Should().ThrowExactly <InvalidDataException>();

            dummyProcessRunner.ExecuteCalled.Should().BeTrue();
            File.Exists(dummyProcessRunner.ExchangeFileName).Should().BeFalse();
        }
Beispiel #3
0
        public void CallAnalyzer_BadResponse_ThrowsException()
        {
            // Arrange
            var logger             = new TestLogger();
            var dummyProcessRunner = new DummyProcessRunner(MockBadEndResponse());

            Action act = () => GetResponse(dummyProcessRunner, new Request(), logger);

            // Act and Assert
            act.Should().Throw <InvalidDataException>().And.Message.Should().Be("Communication issue with the C/C++ analyzer");
            dummyProcessRunner.ExecuteCalled.Should().BeTrue();
        }
        public void CallAnalyzer_BadResponse_FailsSilentlyAndReturnsNull()
        {
            // Arrange
            var logger             = new TestLogger();
            var dummyProcessRunner = new DummyProcessRunner(MockBadEndResponse(), true);
            var result             = CFamilyHelper.CallClangAnalyzer(new Request(), dummyProcessRunner, logger, CancellationToken.None);

            // Act and Assert
            result.Should().BeNull();
            logger.AssertPartialOutputStrings("Failed to execute analysis");
            dummyProcessRunner.ExecuteCalled.Should().BeTrue();
            File.Exists(dummyProcessRunner.ExchangeFileName).Should().BeFalse();
        }
Beispiel #5
0
        public void CallAnalyzer_RequestWithReproducer_ReturnsZeroMessages()
        {
            // Arrange
            var request = new Request {
                Flags = Request.CreateReproducer
            };
            var dummyProcessRunner = new DummyProcessRunner(MockBadEndResponse());
            var result             = GetResponse(dummyProcessRunner, request, new TestLogger());

            // Act and Assert
            result.Should().BeEmpty();
            dummyProcessRunner.ExecuteCalled.Should().BeTrue();
        }
Beispiel #6
0
        public void CallAnalyzer_Fails_ReturnsZeroMessages()
        {
            // Arrange
            var dummyProcessRunner = new DummyProcessRunner(MockEmptyResponse());

            // Act
            var response = GetResponse(dummyProcessRunner, new Request(), new TestLogger());

            // Assert
            dummyProcessRunner.ExecuteCalled.Should().BeTrue();

            response.Should().BeEmpty();
        }
Beispiel #7
0
        public void CallAnalyzer_Fails()
        {
            // Arrange
            var dummyProcessRunner = new DummyProcessRunner(MockEmptyResponse(), false);

            // Act
            var response = CFamilyHelper.CallClangAnalyzer(new Request(), dummyProcessRunner, new TestLogger());

            // Assert
            dummyProcessRunner.ExecuteCalled.Should().BeTrue();
            File.Exists(dummyProcessRunner.ExchangeFileName).Should().BeFalse();

            response.Should().BeNull();
        }
        public void CallAnalyzer_RequestWithReproducer_ReturnsNull()
        {
            // Arrange
            var request = new Request {
                Flags = Request.CreateReproducer
            };
            var dummyProcessRunner = new DummyProcessRunner(MockBadEndResponse(), true);
            var result             = CFamilyHelper.CallClangAnalyzer(request, dummyProcessRunner, new TestLogger(), CancellationToken.None);

            // Act and Assert
            result.Should().BeNull();
            dummyProcessRunner.ExecuteCalled.Should().BeTrue();
            File.Exists(dummyProcessRunner.ExchangeFileName).Should().BeFalse();
        }
Beispiel #9
0
        public void CallAnalyzer_Succeeds_ReturnsMessages()
        {
            // Arrange
            var dummyProcessRunner = new DummyProcessRunner(MockResponse());

            // Act
            var response = GetResponse(dummyProcessRunner, new Request(), new TestLogger());

            // Assert
            dummyProcessRunner.ExecuteCalled.Should().BeTrue();

            response.Count().Should().Be(1);
            response[0].Filename.Should().Be("file.cpp");
        }
Beispiel #10
0
        public void CallAnalyzer_Succeeds()
        {
            // Arrange
            var dummyProcessRunner = new DummyProcessRunner(MockResponse(), true);

            // Act
            var response = CFamilyHelper.CallClangAnalyzer(new Request(), dummyProcessRunner, new TestLogger());

            // Assert
            dummyProcessRunner.ExecuteCalled.Should().BeTrue();
            File.Exists(dummyProcessRunner.ExchangeFileName).Should().BeFalse();

            response.Should().NotBeNull();
            response.Messages.Count().Should().Be(1);
            response.Messages[0].Filename.Should().Be("file.cpp");
        }
Beispiel #11
0
 private static List <Message> GetResponse(DummyProcessRunner dummyProcessRunner, Request request, ILogger logger)
 {
     return(GetResponse(dummyProcessRunner, request, logger, CancellationToken.None));
 }