Пример #1
0
        private bool IsDetectedPlatform(
            DetectorContext ctx,
            IPlatformDetector platformDetector,
            out Tuple <PlatformName, string> platformResult)
        {
            platformResult = null;
            PlatformName           platformName    = platformDetector.DetectorPlatformName;
            PlatformDetectorResult detectionResult = platformDetector.Detect(ctx);

            if (detectionResult == null)
            {
                _logger.LogInformation($"Platform '{platformName}' was not detected in the given repository.");
                return(false);
            }

            if (string.IsNullOrEmpty(detectionResult.PlatformVersion))
            {
                _logger.LogInformation($"Platform '{platformName}' was detected in the given repository, but " +
                                       $"no versions were detected.");
                platformResult = Tuple.Create(platformName, "Not Detected");
                return(true);
            }

            string detectedVersion = detectionResult.PlatformVersion;

            platformResult = Tuple.Create(platformName, detectedVersion);
            _logger.LogInformation($"platform '{platformName}' was detected with version '{detectedVersion}'.");
            return(true);
        }
        public static IPathFactory CreatePathFactory(this IPlatformDetector platformDetector)
        {
            if (platformDetector.IsLinux)
            {
                return(new LinuxPathFactory());
            }

            Console.WriteLine("WARNING: Running on Windows.");

            return(new WindowsPathFactory());
        }
Пример #3
0
 public AgentUpdateService(
     IDockerClient dockerClient,
     AgentDockerContainerFactory dockerContainerFactory,
     IPlatformDetector platformDetecter,
     DeviceApiClient deviceApiClient,
     ILogger logger) : base(logger, dockerClient)
 {
     _dockerClient           = dockerClient ?? throw new ArgumentNullException(nameof(dockerClient));
     _dockerContainerFactory = dockerContainerFactory ?? throw new ArgumentNullException(nameof(dockerContainerFactory));
     _platformDetecter       = platformDetecter;
     _deviceApiClient        = deviceApiClient ?? throw new ArgumentNullException(nameof(deviceApiClient));
 }
Пример #4
0
 public TestProgrammingPlatform(
     string platformName,
     string[] platformVersions,
     bool?canGenerateScript     = null,
     string scriptContent       = null,
     IPlatformDetector detector = null,
     bool enabled = true,
     bool platformIsEnabledForMultiPlatformBuild = true)
 {
     Name = platformName;
     SupportedVersions  = platformVersions;
     _canGenerateScript = canGenerateScript;
     _scriptContent     = scriptContent;
     _detector          = detector;
     _enabled           = enabled;
     _platformIsEnabledForMultiPlatformBuild = platformIsEnabledForMultiPlatformBuild;
 }
Пример #5
0
        public void Detect_ReturnsResult_MultiplePlatform_DotNetCoreReactApp()
        {
            Mock <IPlatformDetector>        mockNodePlatformDetector       = new Mock <IPlatformDetector>();
            Mock <IPlatformDetector>        mockDotnetcorePlatformDetector = new Mock <IPlatformDetector>();
            IEnumerable <IPlatformDetector> platformDetectors = new List <IPlatformDetector>()
            {
                mockNodePlatformDetector.Object, mockDotnetcorePlatformDetector.Object
            };

            var options    = new Mock <IOptions <DetectorOptions> >();
            var sourceRepo = new MemorySourceRepo();
            var detector   = new DefaultPlatformDetector(
                platformDetectors,
                NullLogger <DefaultPlatformDetector> .Instance,
                options.Object);
            var context = CreateContext(sourceRepo);

            var detectionResult1 = new PlatformDetectorResult();

            detectionResult1.Platform        = "node";
            detectionResult1.PlatformVersion = "12.16.1";

            var detectionResult2 = new PlatformDetectorResult();

            detectionResult2.Platform        = "dotnetcore";
            detectionResult2.PlatformVersion = "3.1";

            mockNodePlatformDetector.Setup(x => x.DetectorPlatformName).Returns(PlatformName.Node);
            mockDotnetcorePlatformDetector.Setup(x => x.DetectorPlatformName).Returns(PlatformName.DotNetCore);
            mockNodePlatformDetector.Setup(x => x.Detect(context)).Returns(detectionResult1);
            mockDotnetcorePlatformDetector.Setup(x => x.Detect(context)).Returns(detectionResult2);

            IPlatformDetector nodePlatformDetector       = mockNodePlatformDetector.Object;
            IPlatformDetector dotnetcorePlatformDetector = mockDotnetcorePlatformDetector.Object;

            // Act
            var detectionResults = detector.GetAllDetectedPlatforms(context);

            // Assert
            Assert.NotNull(detectionResults);
            Assert.Equal(2, detectionResults.Count);
        }
Пример #6
0
        private bool IsDetectedPlatform(
            DetectorContext context,
            IPlatformDetector platformDetector,
            out PlatformDetectorResult platformResult)
        {
            platformResult = platformDetector.Detect(context);

            if (platformResult == null)
            {
                _logger.LogInformation("Could not detect any platform in the given repository.");
                return(false);
            }

            if (string.IsNullOrEmpty(platformResult.PlatformVersion))
            {
                _logger.LogInformation(
                    $"Platform '{platformResult.Platform}' was detected in the given repository, " +
                    $"but no versions were detected.");
            }

            _logger.LogInformation(
                $"Platform '{platformResult.Platform}' was detected with version '{platformResult.PlatformVersion}'.");
            return(true);
        }
 public CodecovRunnerFixture(IPlatformDetector platformDetector, string expectedExecutable)
     : base(expectedExecutable)
 {
     this.platformDetector = platformDetector;
 }
Пример #8
0
 internal CodecovRunner(IPlatformDetector platformDetector, IFileSystem fileSystem, ICakeEnvironment environment, IProcessRunner processRunner, IToolLocator tools)
     : base(fileSystem, environment, processRunner, tools)
 {
     this.platformDetector = platformDetector ?? throw new ArgumentNullException(nameof(platformDetector));
 }