public void ReadWriteRequest()
 {
     Task.Run(async () =>
     {
         var request = new BuildRequest(
             BuildProtocolConstants.ProtocolVersion,
             BuildProtocolConstants.RequestLanguage.VisualBasicCompile,
             ImmutableArray.Create(
                 new BuildRequest.Argument(BuildProtocolConstants.ArgumentId.CurrentDirectory, argumentIndex: 0, value: "directory"),
                 new BuildRequest.Argument(BuildProtocolConstants.ArgumentId.CommandLineArgument, argumentIndex: 1, value: "file")));
         var memoryStream = new MemoryStream();
         await request.WriteAsync(memoryStream, default(CancellationToken)).ConfigureAwait(false);
         Assert.True(memoryStream.Position > 0);
         memoryStream.Position = 0;
         var read = await BuildRequest.ReadAsync(memoryStream, default(CancellationToken)).ConfigureAwait(false);
         Assert.Equal(BuildProtocolConstants.ProtocolVersion, read.ProtocolVersion);
         Assert.Equal(BuildProtocolConstants.RequestLanguage.VisualBasicCompile, read.Language);
         Assert.Equal(2, read.Arguments.Length);
         Assert.Equal(BuildProtocolConstants.ArgumentId.CurrentDirectory, read.Arguments[0].ArgumentId);
         Assert.Equal(0, read.Arguments[0].ArgumentIndex);
         Assert.Equal("directory", read.Arguments[0].Value);
         Assert.Equal(BuildProtocolConstants.ArgumentId.CommandLineArgument, read.Arguments[1].ArgumentId);
         Assert.Equal(1, read.Arguments[1].ArgumentIndex);
         Assert.Equal("file", read.Arguments[1].Value);
     }).Wait();
 }
Beispiel #2
0
        internal static string[] GetCommandLineArguments(BuildRequest req, out string currentDirectory, out string tempDirectory, out string libDirectory)
        {
            currentDirectory = null;
            libDirectory = null;
            tempDirectory = null;
            List<string> commandLineArguments = new List<string>();

            foreach (BuildRequest.Argument arg in req.Arguments)
            {
                if (arg.ArgumentId == BuildProtocolConstants.ArgumentId.CurrentDirectory)
                {
                    currentDirectory = arg.Value;
                }
                else if (arg.ArgumentId == BuildProtocolConstants.ArgumentId.TempDirectory)
                {
                    tempDirectory = arg.Value;
                }
                else if (arg.ArgumentId == BuildProtocolConstants.ArgumentId.LibEnvVariable)
                {
                    libDirectory = arg.Value;
                }
                else if (arg.ArgumentId == BuildProtocolConstants.ArgumentId.CommandLineArgument)
                {
                    int argIndex = arg.ArgumentIndex;
                    while (argIndex >= commandLineArguments.Count)
                        commandLineArguments.Add("");
                    commandLineArguments[argIndex] = arg.Value;
                }
            }

            return commandLineArguments.ToArray();
        }
		public object Get(BuildRequest request)
		{
			if(request != null && !string.IsNullOrEmpty(request.Id))
			{
				return _buildManager.GetBuild(request.Id);
			}
			else 
			{
				return _buildManager.GetBuildList(request.BuildListOptions(), request.ProjectId, request.ProjectBranchId, request.ProjectComponentId);
			}
		}
		public object Post(BuildRequest request)
		{
			if(string.IsNullOrEmpty(request.Id))
			{
				return this._buildManager.CreateBuild(request.ProjectId, request.ProjectComponentId, request.ProjectBranchId, request.FileId, request.Version);
			}
			else 
			{
				return this._buildManager.UpdateBuild(request.Id, request.ProjectId, request.ProjectComponentId, request.ProjectBranchId, request.FileId, request.Version);
			}
		}
Beispiel #5
0
        internal static RunRequest GetRunRequest(BuildRequest req)
        {
            string currentDirectory;
            string libDirectory;
            string[] arguments = GetCommandLineArguments(req, out currentDirectory, out libDirectory);
            string language = "";
            switch (req.Language)
            {
                case RequestLanguage.CSharpCompile:
                    language = LanguageNames.CSharp;
                    break;
                case RequestLanguage.VisualBasicCompile:
                    language = LanguageNames.VisualBasic;
                    break;
            }

            return new RunRequest(language, currentDirectory, libDirectory, arguments);
        }
        /// <summary>
        /// An incoming request as occurred. This is called on a new thread to handle
        /// the request.
        /// </summary>
        public BuildResponse HandleRequest(BuildRequest request, CancellationToken cancellationToken)
        {
            var req = BuildProtocolUtil.GetRunRequest(request);
            switch (req.Language)
            {
                case LanguageNames.CSharp:
                    _compilerServerHost.Log("Request to compile C#");
                    return RunCompile(req, CreateCSharpCompiler, cancellationToken);

                case LanguageNames.VisualBasic:
                    _compilerServerHost.Log("Request to compile VB");
                    return RunCompile(req, CreateBasicCompiler, cancellationToken);

                default:
                    // We can't do anything with a request we don't know about. 
                    _compilerServerHost.Log($"Got request with id '{req.Language}'");
                    return new CompletedBuildResponse(-1, false, "", "");
            }
        }
        /// <summary>
        /// Logs the project started/finished pair for projects which are skipped entirely because all
        /// of their results are available in the cache.
        /// </summary>
        internal void LogRequestHandledFromCache(BuildRequest request, BuildRequestConfiguration configuration, BuildResult result)
        {
            ProjectLoggingContext projectLoggingContext = LogProjectStarted(request, configuration);

            // When pulling a request from the cache, we want to make sure we log a task skipped message for any targets which
            // were used to build the request including default and inital targets.
            foreach (string target in configuration.GetTargetsUsedToBuildRequest(request))
            {
                projectLoggingContext.LogComment
                (
                    MessageImportance.Low,
                    result[target].ResultCode == TargetResultCode.Failure ? "TargetAlreadyCompleteFailure" : "TargetAlreadyCompleteSuccess",
                    target
                );

                if (result[target].ResultCode == TargetResultCode.Failure)
                {
                    break;
                }
            }

            projectLoggingContext.LogProjectFinished(result.OverallResult == BuildResultCode.Success);
        }
Beispiel #8
0
        public void Clone()
        {
            BuildRequest request = CreateNewBuildRequest(1, new string[0]);
            BuildResult  result1 = new BuildResult(request);

            result1.ResultsByTarget.Add("FOO", BuildResultUtilities.GetEmptySucceedingTargetResult());
            Assert.True(result1.ResultsByTarget.ContainsKey("foo")); // test comparer

            BuildResult result2 = result1.Clone();

            result1.ResultsByTarget.Add("BAR", BuildResultUtilities.GetEmptySucceedingTargetResult());
            Assert.True(result1.ResultsByTarget.ContainsKey("foo")); // test comparer
            Assert.True(result1.ResultsByTarget.ContainsKey("bar"));

            Assert.Equal(result1.SubmissionId, result2.SubmissionId);
            Assert.Equal(result1.ConfigurationId, result2.ConfigurationId);
            Assert.Equal(result1.GlobalRequestId, result2.GlobalRequestId);
            Assert.Equal(result1.ParentGlobalRequestId, result2.ParentGlobalRequestId);
            Assert.Equal(result1.NodeRequestId, result2.NodeRequestId);
            Assert.Equal(result1.CircularDependency, result2.CircularDependency);
            Assert.Equal(result1.ResultsByTarget["foo"], result2.ResultsByTarget["foo"]);
            Assert.Equal(result1.OverallResult, result2.OverallResult);
        }
Beispiel #9
0
        public void TestOverallResult()
        {
            BuildRequest request = CreateNewBuildRequest(1, Array.Empty <string>());
            BuildResult  result  = new BuildResult(request);

            Assert.Equal(BuildResultCode.Success, result.OverallResult);

            result.AddResultsForTarget("foo", BuildResultUtilities.GetEmptySucceedingTargetResult());
            Assert.Equal(BuildResultCode.Success, result.OverallResult);

            result.AddResultsForTarget("bar", new TargetResult(Array.Empty <TaskItem>(), new WorkUnitResult(WorkUnitResultCode.Success, WorkUnitActionCode.Continue, new Exception())));
            Assert.Equal(BuildResultCode.Success, result.OverallResult);

            result.AddResultsForTarget("baz", new TargetResult(Array.Empty <TaskItem>(), BuildResultUtilities.GetStopWithErrorResult(new Exception())));
            Assert.Equal(BuildResultCode.Failure, result.OverallResult);

            BuildRequest request2 = CreateNewBuildRequest(2, Array.Empty <string>());
            BuildResult  result2  = new BuildResult(request2);

            result2.AddResultsForTarget("foo", BuildResultUtilities.GetEmptySucceedingTargetResult());
            result2.AddResultsForTarget("bar", BuildResultUtilities.GetEmptyFailingTargetResult());
            Assert.Equal(BuildResultCode.Failure, result2.OverallResult);
        }
Beispiel #10
0
        public void TestTranslation()
        {
            BuildRequest request = CreateNewBuildRequest(1, new string[] { "alpha", "omega" });

            Assert.Equal(NodePacketType.BuildRequest, request.Type);

            ((INodePacketTranslatable)request).Translate(TranslationHelpers.GetWriteTranslator());
            INodePacket packet = BuildRequest.FactoryForDeserialization(TranslationHelpers.GetReadTranslator());

            BuildRequest deserializedRequest = packet as BuildRequest;

            Assert.Equal(request.BuildEventContext, deserializedRequest.BuildEventContext);
            Assert.Equal(request.ConfigurationId, deserializedRequest.ConfigurationId);
            Assert.Equal(request.GlobalRequestId, deserializedRequest.GlobalRequestId);
            Assert.Equal(request.IsConfigurationResolved, deserializedRequest.IsConfigurationResolved);
            Assert.Equal(request.NodeRequestId, deserializedRequest.NodeRequestId);
            Assert.Equal(request.ParentBuildEventContext, deserializedRequest.ParentBuildEventContext);
            Assert.Equal(request.Targets.Count, deserializedRequest.Targets.Count);
            for (int i = 0; i < request.Targets.Count; i++)
            {
                Assert.Equal(request.Targets[i], deserializedRequest.Targets[i]);
            }
        }
Beispiel #11
0
        public void TestMaxNodeCountNotExceededWithRequestsOfAffinityAny()
        {
            _host.BuildParameters.MaxNodeCount = 3;

            CreateConfiguration(1, "foo.proj");
            CreateConfiguration(2, "bar.proj");
            CreateConfiguration(3, "baz.proj");
            CreateConfiguration(4, "quz.proj");
            BuildRequest request1 = CreateBuildRequest(1, 1, new string[] { "foo" });
            BuildRequest request2 = CreateBuildRequest(2, 2, new string[] { "bar" });
            BuildRequest request3 = CreateBuildRequest(3, 3, new string[] { "baz" });
            BuildRequest request4 = CreateBuildRequest(4, 4, new string[] { "qux" });

            BuildRequestBlocker     blocker  = new BuildRequestBlocker(request1.ParentGlobalRequestId, new string[] { }, new BuildRequest[] { request1, request2, request3, request4 });
            List <ScheduleResponse> response = new List <ScheduleResponse>(_scheduler.ReportRequestBlocked(1, blocker));

            Assert.Equal(2, response.Count);
            Assert.Equal(ScheduleActionType.ScheduleWithConfiguration, response[0].Action);
            Assert.Equal(request1, response[0].BuildRequest);
            Assert.Equal(ScheduleActionType.CreateNode, response[1].Action);
            Assert.Equal(NodeAffinity.OutOfProc, response[1].RequiredNodeType);
            Assert.Equal(2, response[1].NumberOfNodesToCreate);
        }
Beispiel #12
0
        public void TestMaxNodeCountOOPNodesCreatedForOOPAffinitizedRequests()
        {
            _host.BuildParameters.MaxNodeCount = 3;

            CreateConfiguration(1, "foo.proj");
            CreateConfiguration(2, "bar.proj");
            CreateConfiguration(3, "baz.proj");
            CreateConfiguration(4, "quz.proj");
            BuildRequest request1 = CreateBuildRequest(1, 1, new string[] { "foo" }, NodeAffinity.OutOfProc, _defaultParentRequest);
            BuildRequest request2 = CreateBuildRequest(2, 2, new string[] { "bar" }, NodeAffinity.OutOfProc, _defaultParentRequest);
            BuildRequest request3 = CreateBuildRequest(3, 3, new string[] { "baz" }, NodeAffinity.OutOfProc, _defaultParentRequest);
            BuildRequest request4 = CreateBuildRequest(4, 4, new string[] { "qux" }, NodeAffinity.OutOfProc, _defaultParentRequest);

            BuildRequestBlocker     blocker  = new BuildRequestBlocker(request1.ParentGlobalRequestId, new string[] { }, new BuildRequest[] { request1, request2, request3, request4 });
            List <ScheduleResponse> response = new List <ScheduleResponse>(_scheduler.ReportRequestBlocked(1, blocker));

            // Parent request is blocked by the fact that both child requests require the out-of-proc node that doesn't
            // exist yet.
            Assert.Single(response);
            Assert.Equal(ScheduleActionType.CreateNode, response[0].Action);
            Assert.Equal(NodeAffinity.OutOfProc, response[0].RequiredNodeType);
            Assert.Equal(3, response[0].NumberOfNodesToCreate);
        }
Beispiel #13
0
        internal EngineProxy CreateEngineProxyWithDummyTaskEngine(Engine e, Project p)
        {
            // UNDONE need a real handle Id and a real TEM pointer
            XmlElement taskNode = new XmlDocument().CreateElement("MockTask");

            BuildRequest      request = new BuildRequest(EngineCallback.invalidEngineHandle, "mockproject", null, (BuildPropertyGroup)null, null, -1, false, false);
            ProjectBuildState context = new ProjectBuildState(request, new ArrayList(), new BuildEventContext(0, 0, 0, 0));
            int        handleId       = e.EngineCallback.CreateTaskContext(p, null, context, taskNode, 0, new BuildEventContext(0, 0, 0, 0));
            TaskEngine taskEngine     = new TaskEngine
                                        (
                taskNode,
                null,                     /* host object */
                p.FullFileName,
                p.FullFileName,
                e.LoggingServices,
                handleId,
                e.NodeManager.TaskExecutionModule,
                new BuildEventContext(0, 0, 0, 0)
                                        );

            e.Scheduler.Initialize(new INodeDescription[] { null });
            return(new EngineProxy(e.NodeManager.TaskExecutionModule, handleId, p.FullFileName, p.FullFileName, e.LoggingServices, new BuildEventContext(0, 0, 0, 0)));
        }
Beispiel #14
0
        public void TestAddAndRetrieveResultsByConfiguration()
        {
            ResultsCache cache   = new ResultsCache();
            BuildRequest request = new BuildRequest(1 /* submissionId */, 0, 1, new string[1] {
                "testTarget"
            }, null, BuildEventContext.Invalid, null);
            BuildResult result = new BuildResult(request);

            result.AddResultsForTarget("testTarget", TestUtilities.GetEmptyFailingTargetResult());
            cache.AddResult(result);

            request = new BuildRequest(1 /* submissionId */, 0, 1, new string[1] {
                "otherTarget"
            }, null, BuildEventContext.Invalid, null);
            result = new BuildResult(request);
            result.AddResultsForTarget("otherTarget", TestUtilities.GetEmptySucceedingTargetResult());
            cache.AddResult(result);

            BuildResult retrievedResult = cache.GetResultsForConfiguration(1);

            Assert.IsTrue(retrievedResult.HasResultsForTarget("testTarget"));
            Assert.IsTrue(retrievedResult.HasResultsForTarget("otherTarget"));
        }
        /// <summary>
        /// Logs the project started/finished pair for projects which are skipped entirely because all
        /// of their results are available in the cache.
        /// </summary>
        internal void LogRequestHandledFromCache(BuildRequest request, BuildRequestConfiguration configuration, BuildResult result)
        {
            ProjectLoggingContext projectLoggingContext = LogProjectStarted(request, configuration);

            // When pulling a request from the cache, we want to make sure we log a task skipped message for any targets which 
            // were used to build the request including default and inital targets.
            foreach (string target in configuration.GetTargetsUsedToBuildRequest(request))
            {
                projectLoggingContext.LogComment
                    (
                        MessageImportance.Low,
                        result[target].ResultCode == TargetResultCode.Failure ? "TargetAlreadyCompleteFailure" : "TargetAlreadyCompleteSuccess",
                        target
                    );

                if (result[target].ResultCode == TargetResultCode.Failure)
                {
                    break;
                }
            }

            projectLoggingContext.LogProjectFinished(result.OverallResult == BuildResultCode.Success);
        }
Beispiel #16
0
        public BuildRequestsList DeleteRequest(BuildRequest param)
        {
            try
            {
                var queue = BuildRequestsQueue.Queue;
                var elem  = (from c in queue.QueueList
                             where c.Name.Equals(param.Name) && c.RequestTime == param.RequestTime
                             select c).FirstOrDefault();

                if (elem != null)
                {
                    queue.QueueList.Remove(elem);
                }

                WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.OK;
            }
            catch (Exception e)
            {
                WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotAcceptable;
            }

            return(BuildRequestsList.GetList());
        }
        public ResultsCacheResponse SatisfyRequest(
            BuildRequest request,
            List <string> configInitialTargets,
            List <string> configDefaultTargets,
            List <string> additionalTargetsToCheckForOverallResult,
            bool skippedResultsAreOK)
        {
            var overrideRequest = _override.SatisfyRequest(
                request,
                configInitialTargets,
                configDefaultTargets,
                additionalTargetsToCheckForOverallResult,
                skippedResultsAreOK);

            if (overrideRequest.Type == ResultsCacheResponseType.Satisfied)
            {
#if DEBUG
                ErrorUtilities.VerifyThrow(
                    CurrentCache.SatisfyRequest(
                        request,
                        configInitialTargets,
                        configDefaultTargets,
                        additionalTargetsToCheckForOverallResult,
                        skippedResultsAreOK)
                    .Type == ResultsCacheResponseType.NotSatisfied,
                    "caches should not overlap");
#endif
                return(overrideRequest);
            }

            return(CurrentCache.SatisfyRequest(
                       request,
                       configInitialTargets,
                       configDefaultTargets,
                       additionalTargetsToCheckForOverallResult,
                       skippedResultsAreOK));
        }
Beispiel #18
0
 //<----------------------------------used for generating the test request------------------------------------>
 public void generatetestrequest(List<string> outputfilelist, CommMessage msg)
 {
   BuildRequest newRequest = buildRequestContent.FromXml<BuildRequest>();
   TestRequest testRequest = new TestRequest();
   testRequest.author = "Ramteja Repaka";
   List<string> testDriverList = new List<string>();
   foreach (BuildItem item in newRequest.Builds)
   {
     TestElement element = new TestElement();
     element.testName = item.builddesc;
     string testdrivername = null;
     foreach (file f in item.driver)
     {
       String s = f.name;
       s = s.Replace(".cs", ".dll");
       element.addDriver(s);
       testdrivername = s;
     }
     foreach (file f in item.sourcefiles)
     {
       String s = f.name;
       s = s.Replace(".cs", ".dll");
       element.addCode(s);
     }
     if (outputfilelist.Contains(testdrivername))
     {
       testRequest.tests.Add(element);
       testDriverList.Add(testdrivername);
     }
   }
   string testxml = testRequest.ToXml();
   string filename = msg.filename;
   filename = filename.Replace("BuildRequest", "TestRequest");
   File.WriteAllText(ServiceEnvironment.fileStorage + "/" + builderId + "/" + filename, testxml);
   Console.WriteLine("TestRequest saved to BuilderStorage\n");
   sendfilestoharness(testDriverList, filename);
 }
Beispiel #19
0
        public void CancelBuilding(uint unitType)
        {
            foreach (Agent agent in Bot.Main.UnitManager.Agents.Values)
            {
                if (agent.Unit.UnitType == unitType &&
                    agent.Unit.BuildProgress < 0.99)
                {
                    agent.Order(Abilities.CANCEL);
                }
            }
            for (int i = ConstructionTask.Task.BuildRequests.Count - 1; i >= 0; i--)
            {
                BuildRequest request = ConstructionTask.Task.BuildRequests[i];
                if (request.Type != unitType)
                {
                    continue;
                }

                ConstructionTask.Task.BuildRequests.RemoveAt(i);
                if (ConstructionTask.Task.NaturalProbe != request.worker)
                {
                    IdleTask.Task.Add(request.worker);
                    ConstructionTask.Task.Units.Remove(request.worker);
                }
            }
            for (int i = ConstructionTask.Task.UnassignedRequests.Count - 1; i >= 0; i--)
            {
                BuildRequest request = ConstructionTask.Task.UnassignedRequests[i];
                if (request.Type != unitType)
                {
                    continue;
                }

                ConstructionTask.Task.UnassignedRequests.RemoveAt(i);
            }
        }
Beispiel #20
0
        public async Task <BuildResponse> GetResponseAsync(BuildRequest req,
                                                           CancellationToken cancellationToken)
        {
            NamedPipeClientStream pipeStream;

            if (TryAutoConnectToServer(cancellationToken, out pipeStream))
            {
                // We have a good connection
                BuildResponse response = await DoCompilationAsync(pipeStream, req, cancellationToken).ConfigureAwait(false);

                if (response != null)
                {
                    return(response);
                }
                else
                {
                    CompilerServerLogger.Log("Compilation failed, constructing new compiler server");
                    // The compilation failed. There are a couple possible reasons for this,
                    // including that we are using a 32-bit compiler server and we are out of
                    // memory. This is the last attempt -- we will create a new server manually
                    // and try to compile. There is no mutex because anyone else using
                    // this server is accidental only.
                    int newProcessId = CreateNewServerProcess();
                    if (newProcessId != 0 &&
                        TryConnectToProcess(newProcessId,
                                            TimeOutMsNewProcess,
                                            cancellationToken,
                                            out pipeStream))
                    {
                        return(await DoCompilationAsync(pipeStream, req, cancellationToken).ConfigureAwait(false));
                    }
                }
            }

            return(null);
        }
Beispiel #21
0
        /// <summary>
        /// Set up
        /// </summary>
        public Scheduler_Tests()
        {
            // Since we're creating our own BuildManager, we need to make sure that the default
            // one has properly relinquished the inproc node
            NodeProviderInProc nodeProviderInProc = ((IBuildComponentHost)BuildManager.DefaultBuildManager).GetComponent(BuildComponentType.InProcNodeProvider) as NodeProviderInProc;

            nodeProviderInProc?.Dispose();

            _host      = new MockHost();
            _scheduler = new Scheduler();
            _scheduler.InitializeComponent(_host);
            CreateConfiguration(99, "parent.proj");
            _defaultParentRequest = CreateBuildRequest(99, 99, new string[] { }, null);

            // Set up the scheduler with one node to start with.
            _scheduler.ReportNodesCreated(new NodeInfo[] { new NodeInfo(1, NodeProviderType.InProc) });
            _scheduler.ReportRequestBlocked(1, new BuildRequestBlocker(-1, new string[] { }, new BuildRequest[] { _defaultParentRequest }));

            _logger             = new MockLogger();
            _parameters         = new BuildParameters();
            _parameters.Loggers = new ILogger[] { _logger };
            _parameters.ShutdownInProcNodeOnBuildFinish = true;
            _buildManager = new BuildManager();
        }
        public async Task <ActionResult> Test(BuildRequestModel model)
        {
            if (ModelState.IsValid)
            {
                var jobId = Guid.NewGuid();

                var blobName  = "test_" + DateTime.Now.Ticks + ".txt";
                var blockBlob = requestBlob.GetBlockBlobReference(blobName);

                await blockBlob.UploadTextAsync(model.Source);

                Uri          url     = new Uri(Url.Action("StatusNotification", null, null, Request.Url.Scheme));
                BuildRequest request = new BuildRequest()
                {
                    BlobUri = blockBlob.Uri, JobId = jobId, Url = url
                };
                var queueMessage = new CloudQueueMessage(JsonConvert.SerializeObject(request));
                await requestsQueue.AddMessageAsync(queueMessage);

                Trace.TraceInformation("Created test queue message");
                return(Json(new { jobId }, JsonRequestBehavior.AllowGet));
            }
            return(new HttpStatusCodeResult(HttpStatusCode.NotAcceptable));
        }
Beispiel #23
0
        public void TestSimpleBuildScenario()
        {
            BuildRequestData          data   = new BuildRequestData("TestFile", new Dictionary <string, string>(), "TestToolsVersion", new string[0], null);
            BuildRequestConfiguration config = new BuildRequestConfiguration(1, data, "2.0");

            _cache.AddConfiguration(config);

            string[] targets = new string[3] {
                "target1", "target2", "target3"
            };
            BuildRequest request = CreateNewBuildRequest(1, targets);

            VerifyEngineStatus(BuildRequestEngineStatus.Uninitialized);
            _engine.InitializeForBuild(new NodeLoggingContext(_host.LoggingService, 0, false));
            _engine.SubmitBuildRequest(request);
            Thread.Sleep(250);
            VerifyEngineStatus(BuildRequestEngineStatus.Active);

            WaitForEvent(_requestCompleteEvent, "RequestComplete");
            Assert.Equal(request, _requestComplete_Request);
            Assert.Equal(BuildResultCode.Success, _requestComplete_Result.OverallResult);

            VerifyEngineStatus(BuildRequestEngineStatus.Idle);
        }
        //<------------------ Contains core logic to process build request----------------------------------->
        public Dictionary <string, string> processbuildrequest(string path, RepoMock mockobj)
        {
            Console.WriteLine("---------------------------------Build Server processing build request-----------------------------------");
            Console.WriteLine("\n");
            string xmlstring = File.ReadAllText(path);

            BuildRequest newRequest = xmlstring.FromXml <BuildRequest>();

            repomock = mockobj;

            foreach (BuildItem item in newRequest.Builds)
            {
                string        child  = "";
                List <string> parent = new List <string>();
                foreach (file f in item.driver)
                {
                    parent.Add(f.name);
                    Console.WriteLine("requesting  " + f.name); Console.WriteLine("\n");
                    repomock.processfilerequest(f.name);
                }

                foreach (file f in item.sourcefiles)
                {
                    child = child + f.name + "  ";
                    Console.WriteLine("requesting  " + f.name); Console.WriteLine("\n");
                    repomock.processfilerequest(f.name);
                }

                foreach (string str in parent)
                {
                    dict.Add(str, child);
                }
            }

            return(dict);
        }
			public BuildCondition WaitForRequest()
			{
				if (! HasPendingRequests())
				{
					latch.WaitOne();
				}

				lock (this)
				{
					BuildCondition result = request.Condition;
					request = NoBuildRequested;
					latch.Reset();

					Debug.Assert(result != BuildCondition.NoBuild);
					return result;					
				}
			}
		public void Delete(BuildRequest build)  
		{
			this._buildManager.DeleteBuild(build.Id);
		}
			public void RequestBuild(BuildCondition condition)
			{
				lock (this)
				{
					if (request.IsHigherPriority(condition))
					{
						request = new BuildRequest(condition);
						latch.Set();
					}
				}
			}
Beispiel #28
0
        public void TestRequestCaching()
        {
            CacheManager cacheManager = new CacheManager("3.5");

            ArrayList actuallyBuiltTargets;

            // Test the case where we pass in null targets
            Dictionary <string, string> dictionary = new Dictionary <string, string>();
            BuildRequest emptyRequest = new BuildRequest(1, "test.proj", null, dictionary, null, 1, true, false);

            Assert.IsNull(cacheManager.GetCachedBuildResult(emptyRequest, out actuallyBuiltTargets), "Expect a null return value if T=null");

            // Test the case where we pass in length 0 targets
            BuildRequest length0Request = new BuildRequest(1, "test.proj", new string[0], dictionary, null, 1, true, false);

            Assert.IsNull(cacheManager.GetCachedBuildResult(length0Request, out actuallyBuiltTargets), "Expect a null return value if T.Length=0");

            // Test the case when the scope doesn't exist
            string[]     targets        = new string[1]; targets[0] = "Target1";
            BuildRequest length1Request = new BuildRequest(1, "test.proj", targets, new BuildPropertyGroup(), null, 1, true, false);

            Assert.IsNull(cacheManager.GetCachedBuildResult(length1Request, out actuallyBuiltTargets), "Expect a null return value if no scope");

            // Test the case when the scope exists but is empty
            CacheScope cacheScope = cacheManager.GetCacheScope("test.proj", new BuildPropertyGroup(), "3.5", CacheContentType.BuildResults);

            Assert.IsNull(cacheManager.GetCachedBuildResult(length1Request, out actuallyBuiltTargets), "Expect a null return value if scope is empty");

            // Test the case when the scope exists but contains wrong data
            CacheEntry cacheEntry = new BuildResultCacheEntry("Target2", null, true);

            cacheManager.SetCacheEntries(new CacheEntry[] { cacheEntry }, "test.proj", new BuildPropertyGroup(), "3.5", CacheContentType.BuildResults);
            Assert.IsNull(cacheManager.GetCachedBuildResult(length1Request, out actuallyBuiltTargets), "Expect a null return value if scope contains wrong data");

            // Test the case when everything is correct
            cacheScope.AddCacheEntry(new PropertyCacheEntry(Constants.defaultTargetCacheName, string.Empty));
            cacheScope.AddCacheEntry(new PropertyCacheEntry(Constants.initialTargetCacheName, string.Empty));
            cacheScope.AddCacheEntry(new PropertyCacheEntry(Constants.projectIdCacheName, "1"));

            cacheEntry = new BuildResultCacheEntry("Target1", null, true);
            cacheManager.SetCacheEntries(new CacheEntry[] { cacheEntry }, "test.proj", new BuildPropertyGroup(), "3.5", CacheContentType.BuildResults);
            BuildResult buildResult = cacheManager.GetCachedBuildResult(length1Request, out actuallyBuiltTargets);

            Assert.IsNotNull(buildResult, "Expect a cached value if scope contains data");
            Assert.AreEqual(1, actuallyBuiltTargets.Count);
            Assert.AreEqual("Target1", actuallyBuiltTargets[0]);
            Assert.AreEqual(1, buildResult.ResultByTarget.Count);
            Assert.AreEqual(Target.BuildState.CompletedSuccessfully, buildResult.ResultByTarget["Target1"]);

            // Test the case when the scope contains partially correct data
            targets = new string[2]; targets[0] = "Target2"; targets[1] = "Target3";
            BuildRequest length2Request = new BuildRequest(1, "test.proj", targets, new BuildPropertyGroup(), null, 1, true, false);

            Assert.IsNull(cacheManager.GetCachedBuildResult(length2Request, out actuallyBuiltTargets), "Expect a null return value if partial data in the scope");

            // Test the correctness case for multiple targets
            cacheEntry = new BuildResultCacheEntry("Target3", null, true);
            cacheManager.SetCacheEntries(new CacheEntry[] { cacheEntry }, "test.proj", new BuildPropertyGroup(), "3.5", CacheContentType.BuildResults);
            buildResult = cacheManager.GetCachedBuildResult(length2Request, out actuallyBuiltTargets);
            Assert.IsNotNull(buildResult, "Expect a cached value if scope contains data");

            Assert.AreEqual(2, actuallyBuiltTargets.Count);
            Assert.AreEqual("Target2", actuallyBuiltTargets[0]);
            Assert.AreEqual("Target3", actuallyBuiltTargets[1]);
            Assert.AreEqual(2, buildResult.ResultByTarget.Count);
            Assert.AreEqual(Target.BuildState.CompletedSuccessfully, buildResult.ResultByTarget["Target2"]);
            Assert.AreEqual(Target.BuildState.CompletedSuccessfully, buildResult.ResultByTarget["Target3"]);
            Assert.AreEqual(1, buildResult.ProjectId);
        }
Beispiel #29
0
 /// <summary>
 /// Constructs a new build result with existing results, but associated with the specified request.
 /// </summary>
 /// <param name="request">The build request with which these results should be associated.</param>
 /// <param name="existingResults">The existing results, if any.</param>
 /// <param name="exception">The exception, if any</param>
 internal BuildResult(BuildRequest request, BuildResult existingResults, Exception exception)
     : this(request, existingResults, null, null, exception)
 {
 }
Beispiel #30
0
 protected override void ValidateBuildRequest(BuildRequest request)
 {
     ValidateBuildRequestFunc?.Invoke(request);
 }
Beispiel #31
0
 /// <summary>
 /// Constructs a build result with an exception
 /// </summary>
 /// <param name="request">The build request to which these results should be associated.</param>
 /// <param name="exception">The exception, if any.</param>
 internal BuildResult(BuildRequest request, Exception exception)
     : this(request, null, exception)
 {
 }
Beispiel #32
0
        protected virtual void ValidateBuildRequest(BuildRequest request)
        {

        }
Beispiel #33
0
 private bool IsShutdownRequest(BuildRequest request)
 {
     return request.Arguments.Length == 1 && request.Arguments[0].ArgumentId == BuildProtocolConstants.ArgumentId.Shutdown;
 }
Beispiel #34
0
        private async Task<ConnectionData> HandleCompilationRequest(BuildRequest request, CancellationToken cancellationToken)
        {
            var keepAlive = CheckForNewKeepAlive(request);

            // Kick off both the compilation and a task to monitor the pipe for closing.  
            var buildCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
            var compilationTask = ServeBuildRequest(request, buildCts.Token);
            var monitorTask = CreateMonitorDisconnectTask(buildCts.Token);
            await Task.WhenAny(compilationTask, monitorTask).ConfigureAwait(false);

            // Do an 'await' on the completed task, preference being compilation, to force
            // any exceptions to be realized in this method for logging.  
            CompletionReason reason;
            if (compilationTask.IsCompleted)
            {
                var response = await compilationTask.ConfigureAwait(false);

                try
                {
                    Log("Begin writing response.");
                    await response.WriteAsync(_stream, cancellationToken).ConfigureAwait(false);
                    reason = CompletionReason.CompilationCompleted;
                    Log("End writing response.");
                }
                catch
                {
                    reason = CompletionReason.ClientDisconnect;
                }
            }
            else
            {
                await monitorTask.ConfigureAwait(false);
                reason = CompletionReason.ClientDisconnect;
            }

            // Begin the tear down of the Task which didn't complete. 
            buildCts.Cancel();
            return new ConnectionData(reason, keepAlive);
        }
Beispiel #35
0
 /// <summary>
 /// Callback for event raised when a build request is completed
 /// </summary>
 /// <param name="request">The request which completed</param>
 /// <param name="result">The result for the request</param>
 private void Engine_RequestComplete(BuildRequest request, BuildResult result)
 {
     _requestComplete_Request = request;
     _requestComplete_Result  = result;
     _requestCompleteEvent.Set();
 }
Beispiel #36
0
        public AppCommandProcessor(IMongoCollection <AppData> apps, GridFSBucket files, RepositoryApi repository, DataTransferManager dataTransfer,
                                   IMongoCollection <ToDeleteRevision> toDelete, WorkDistributor <BuildRequest, BuildCompled> workDistributor, IActorRef changeTracker)
        {
            _apps = apps;

            CommandPhase1 <CreateAppCommand>("CreateApp", repository,
                                             (command, reporter) =>
            {
                reporter.Send(DeploymentMessages.RegisterRepository);
                return(new RegisterRepository(command.TargetRepo)
                {
                    IgnoreDuplicate = true
                });
            },
                                             (command, reporter, op) => new ContinueCreateApp(op, command, reporter));

            CommandPhase2 <ContinueCreateApp, CreateAppCommand, AppInfo>("CreateApp2", (command, result, reporter, data) =>
            {
                if (!result.Ok)
                {
                    if (reporter.IsCompled)
                    {
                        return(null);
                    }
                    reporter.Compled(OperationResult.Failure(result.Error ?? BuildErrorCodes.CommandErrorRegisterRepository));
                    return(null);
                }

                if (data != null)
                {
                    reporter.Compled(OperationResult.Failure(BuildErrorCodes.CommandDuplicateApp));
                    return(null);
                }

                var newData = new AppData(command.AppName, -1, DateTime.UtcNow, DateTime.MinValue, command.TargetRepo, command.ProjectName, ImmutableList <AppFileInfo> .Empty);

                apps.InsertOne(newData);
                var info = newData.ToInfo();

                changeTracker.Tell(info);
                return(info);
            });

            CommandPhase1 <PushVersionCommand>("PushVersion",
                                               (command, reporter) =>
            {
                var data = apps.AsQueryable().FirstOrDefault(ad => ad.Name == command.AppName);
                if (data == null)
                {
                    reporter.Compled(OperationResult.Failure(BuildErrorCodes.CommandAppNotFound));
                }
                else
                {
                    BuildRequest.SendWork(workDistributor, reporter, data, repository, BuildEnv.TempFiles.CreateFile())
                    .PipeTo(Self,
                            success: c => new ContinuePushNewVersion(OperationResult.Success(c), command, reporter),
                            failure: e => new ContinuePushNewVersion(OperationResult.Failure(e.Unwrap()?.Message ?? "Cancel"), command, reporter));
                }
            });

            CommandPhase2 <ContinuePushNewVersion, PushVersionCommand, AppBinary>("PushVersion2", (command, result, reporter, data) =>
            {
                if (data == null)
                {
                    if (!reporter.IsCompled)
                    {
                        reporter.Compled(OperationResult.Failure(BuildErrorCodes.CommandAppNotFound));
                    }
                    return(null);
                }

                if (!result.Ok)
                {
                    return(null);
                }

                using var transaction = apps.Database.Client.StartSession(new ClientSessionOptions { DefaultTransactionOptions = new TransactionOptions(writeConcern: WriteConcern.Acknowledged) });
                var dataFilter        = Builders <AppData> .Filter.Eq(ad => ad.Name, data.Name);

                var(commit, fileName) = ((string, ITempFile))result.Outcome !;

                using var targetStream = fileName;

                var newId = files.UploadFromStream(data.Name + ".zip", targetStream.Stream);

                var newBinary  = new AppFileInfo(newId, data.Last + 1, DateTime.UtcNow, false, commit);
                var newBinarys = data.Versions.Add(newBinary);

                var definition = Builders <AppData> .Update;
                var updates    = new List <UpdateDefinition <AppData> >
                {
                    definition.Set(ad => ad.Last, newBinary.Version),
                    definition.Set(ad => ad.Versions, newBinarys)
                };

                var deleteUpdates = new List <ToDeleteRevision>();

                if (data.Versions.Count(s => !s.Deleted) > 5)
                {
                    foreach (var info in newBinarys.OrderByDescending(i => i.CreationTime).Skip(5))
                    {
                        if (info.Deleted)
                        {
                            continue;
                        }
                        info.Deleted = true;
                        deleteUpdates.Add(new ToDeleteRevision(info.File.ToString()));
                    }
                }

                transaction.StartTransaction();

                if (deleteUpdates.Count != 0)
                {
                    toDelete.InsertMany(transaction, deleteUpdates);
                }
                if (!apps.UpdateOne(transaction, dataFilter, definition.Combine(updates)).IsAcknowledged)
                {
                    transaction.AbortTransaction();
                    reporter.Compled(OperationResult.Failure(BuildErrorCodes.DatabaseError));
                    return(null);
                }

                transaction.CommitTransaction();

                changeTracker.Tell(_apps.AsQueryable().FirstOrDefault(ad => ad.Name == command.AppName));
                return(new AppBinary(command.AppName, newBinary.Version, newBinary.CreationTime, false, newBinary.Commit, data.Repository));
            });
Beispiel #37
0
 /// <summary>
 /// Callback for event raised when a request is resumed
 /// </summary>
 /// <param name="request">The request being resumed</param>
 private void Engine_RequestResumed(BuildRequest request)
 {
     _requestResumed_Request = request;
     _requestResumedEvent.Set();
 }
Beispiel #38
0
        public void QueueBuild(string agentUri, string buildUri)
        {
            BuildServiceSoapClient soapClient = new BuildServiceSoapClient(GetBinding(Protocol, "BuildServiceSoap"), GetBuildEndpointAddress());

            BuildRequest request = new BuildRequest
            {
                BuildAgentUri = agentUri,
                BuildDefinitionUri = buildUri
            };

            soapClient.QueueBuild(request, QueueOptions.None);
        }
Beispiel #39
0
        /// <summary>
        /// Check the request arguments for a new keep alive time. If one is present,
        /// set the server timer to the new time.
        /// </summary>
        private TimeSpan? CheckForNewKeepAlive(BuildRequest request)
        {
            TimeSpan? timeout = null;
            foreach (var arg in request.Arguments)
            {
                if (arg.ArgumentId == BuildProtocolConstants.ArgumentId.KeepAlive)
                {
                    int result;
                    // If the value is not a valid integer for any reason,
                    // ignore it and continue with the current timeout. The client
                    // is responsible for validating the argument.
                    if (int.TryParse(arg.Value, out result))
                    {
                        // Keep alive times are specified in seconds
                        timeout = TimeSpan.FromSeconds(result);
                    }
                }
            }

            return timeout;
        }
 protected override void ValidateBuildRequest(BuildRequest request)
 {
     // Now that we've read data from the stream we can validate the identity.
     if (!ClientAndOurIdentitiesMatch(_pipeStream))
     {
         throw new Exception("Client identity does not match server identity.");
     }
 }
Beispiel #41
0
        protected virtual Task<BuildResponse> ServeBuildRequest(BuildRequest buildRequest, CancellationToken cancellationToken)
        {
            Func<BuildResponse> func = () =>
            {
                // Do the compilation
                Log("Begin compilation");

                var request = BuildProtocolUtil.GetRunRequest(buildRequest);
                var response = _compilerServerHost.RunCompilation(request, cancellationToken);

                Log("End compilation");
                return response;
            };

            var task = new Task<BuildResponse>(func, cancellationToken, TaskCreationOptions.LongRunning);
            task.Start();
            return task;
        }
 protected virtual Task<BuildResponse> ServeBuildRequest(BuildRequest request, CancellationToken cancellationToken)
 {
     return Task.Run(() =>
     {
         try
         {
             // Do the compilation
             Log("Begin compilation");
             BuildResponse response = ServeBuildRequestCore(request, cancellationToken);
             Log("End compilation");
             return response;
         }
         catch (Exception e) when (FatalError.Report(e))
         {
             throw ExceptionUtilities.Unreachable;
         }
     });
 }
Beispiel #43
0
 /// <summary>
 /// A new build request for this definition is submitted. This call is in the ProcessorThread of the TestDataProvider
 /// </summary>
 public void RaiseOnNewBuildRequest(BuildRequest request)
 {
     this.Build(request);
 }
        private BuildResponse ServeBuildRequestCore(BuildRequest buildRequest, CancellationToken cancellationToken)
        {
            var request = BuildProtocolUtil.GetRunRequest(buildRequest);
            CommonCompiler compiler;
            if (!_compilerServerHost.TryCreateCompiler(request, out compiler))
            {
                // TODO: is this the right option?  Right now it will cause the fall back in the command line 
                // to fail because it's a valid response.  Probably should add a "server failed" response
                // for command line to deal with.

                // We can't do anything with a request we don't know about. 
                Log($"Got request with id '{request.Language}'");
                return new CompletedBuildResponse(-1, false, "", "");
            }

            Log($"CurrentDirectory = '{request.CurrentDirectory}'");
            Log($"LIB = '{request.LibDirectory}'");
            for (int i = 0; i < request.Arguments.Length; ++i)
            {
                Log($"Argument[{i}] = '{request.Arguments[i]}'");
            }

            bool utf8output = compiler.Arguments.Utf8Output;
            if (!_compilerServerHost.CheckAnalyzers(request.CurrentDirectory, compiler.Arguments.AnalyzerReferences))
            {
                return new AnalyzerInconsistencyBuildResponse();
            }

            Log($"****Running {request.Language} compiler...");
            TextWriter output = new StringWriter(CultureInfo.InvariantCulture);
            int returnCode = compiler.Run(output, cancellationToken);
            Log($"****{request.Language} Compilation complete.\r\n****Return code: {returnCode}\r\n****Output:\r\n{output.ToString()}\r\n");
            return new CompletedBuildResponse(returnCode, utf8output, output.ToString(), "");
        }
Beispiel #45
0
 /// <summary>
 /// Constructor creates an empty build result
 /// </summary>
 /// <param name="request">The build request to which these results should be associated.</param>
 internal BuildResult(BuildRequest request)
     : this(request, null)
 {
 }
		void build(BuildRequest request, CancellationToken cancellation, Action<BuildStatus> onCompleted)
		{
			var status = BuildStatus.Failed;

			try
			{
				lock (_coreSyncRoot)
				{
					_coreRunning = true;
					Monitor.PulseAll(_coreSyncRoot);
				}

				// cancelAndWait() may cancel _and_ return before _coreRunning was set to true, we
				// want to be sure to not start another build then.
				cancellation.ThrowIfCancellationRequested();

				coreToIDE(() =>
				{
					_pane.Clear();
					_pane.Activate();
				});

				status = buildCore(request, cancellation);
			}
			catch (Exception e)
			{
				Log.E(e, "build crashed");
				coreToIDE(() => {
					_pane.reportException(e);
				});
			}
			finally
			{
				lock (_coreSyncRoot)
				{
					_coreRunning = false;
					Monitor.PulseAll(_coreSyncRoot);
				}

				_mainThread.Post(_ => onCompleted(status), null);
			}
		}
Beispiel #47
0
 /// <summary>
 /// Constructor creates a build result indicating a circular dependency was created.
 /// </summary>
 /// <param name="request">The build request to which these results should be associated.</param>
 /// <param name="circularDependency">Set to true if a circular dependency was detected.</param>
 internal BuildResult(BuildRequest request, bool circularDependency)
     : this(request, null)
 {
     _circularDependency = circularDependency;
 }
		BuildStatus buildCore(BuildRequest request, CancellationToken cancellation)
		{
#if DEBUG
			var verbosity = LoggerVerbosity.Minimal;
#else
			var verbosity = LoggerVerbosity.Quiet;
#endif
			var consoleLogger = new ConsoleLogger(verbosity,
				str =>
					coreToIDE(() => _pane.OutputString(str)),
				color => { },
				() => { })
			{
				SkipProjectStartedText = true,
				ShowSummary = false
			};

			var summaryLogger = new SummaryLogger();

			var parameters = new BuildParameters()
			{
				Loggers = new ILogger[] {consoleLogger, summaryLogger},
				EnableNodeReuse = true,
				ShutdownInProcNodeOnBuildFinish = false,
				DetailedSummary = false,
			};
			
			printIntro(request);
			var status = buildCore(request, cancellation, parameters);
			printSummary(summaryLogger, request.AllProjectsToBuildOrdered);
			return status;
		}
Beispiel #49
0
        /// <summary>
        /// Constructs a new build result with existing results, but associated with the specified request.
        /// </summary>
        /// <param name="request">The build request with which these results should be associated.</param>
        /// <param name="existingResults">The existing results, if any.</param>
        /// <param name="targetNames">The list of target names that are the subset of results that should be returned.</param>
        /// <param name="additionalTargetsToCheck">The additional targets that need to be taken into account when computing the overall result, if any.</param>
        /// <param name="exception">The exception, if any</param>
        internal BuildResult(BuildRequest request, BuildResult existingResults, string[] targetNames, List <string> additionalTargetsToCheck, Exception exception)
        {
            ErrorUtilities.VerifyThrow(request != null, "Must specify a request.");
            _submissionId          = request.SubmissionId;
            _configurationId       = request.ConfigurationId;
            _globalRequestId       = request.GlobalRequestId;
            _parentGlobalRequestId = request.ParentGlobalRequestId;
            _nodeRequestId         = request.NodeRequestId;
            _circularDependency    = false;

            if (existingResults == null)
            {
                _requestException  = exception;
                _resultsByTarget   = CreateTargetResultDictionary(0);
                _baseOverallResult = true;
            }
            else
            {
                _requestException = exception ?? existingResults._requestException;

                _resultsByTarget = targetNames == null ? existingResults._resultsByTarget : CreateTargetResultDictionaryWithContents(existingResults, targetNames);

                if (existingResults.OverallResult == BuildResultCode.Success || (additionalTargetsToCheck == null || additionalTargetsToCheck.Count == 0))
                {
                    // If we know for a fact that all of the existing results succeeded, then by definition we'll have
                    // succeeded too.  Alternately, if we don't have any additional targets to check, then we want the
                    // overall result to reflect only the targets included in this result, which the OverallResult
                    // property already does -- so just default to true in that case as well.
                    _baseOverallResult = true;
                }
                else
                {
                    // If the existing result is a failure, then we need to determine whether the targets we are
                    // specifically interested in contributed to that failure or not.  If they did not, then this
                    // result should be sucessful even though the result it is based on failed.
                    //
                    // For the most part, this is taken care of for us because any dependent targets that fail also
                    // mark their parent targets (up to and including the entrypoint target) as failed.  However,
                    // there is one case in which this is not true: if the entrypoint target has AfterTargets that
                    // fail, then as far as the entrypoint target knows when it is executing, it has succeeded.  The
                    // failure doesn't come until after.  On the other hand, we don't want to actually include the
                    // AfterTarget results in the build result itself if the user hasn't asked for them.
                    //
                    // So in the case where there are AfterTargets, we will check them for failure so that we can
                    // make sure the overall success/failure result is correct, but not actually add their contents
                    // to the new result.
                    _baseOverallResult = true;

                    foreach (string additionalTarget in additionalTargetsToCheck)
                    {
                        if (existingResults.ResultsByTarget.TryGetValue(additionalTarget, out TargetResult targetResult))
                        {
                            if (targetResult.ResultCode == TargetResultCode.Failure && !targetResult.TargetFailureDoesntCauseBuildFailure)
                            {
                                _baseOverallResult = false;
                                break;
                            }
                        }
                    }
                }
            }
        }
		BuildStatus buildCore(BuildRequest request, CancellationToken cancellation, BuildParameters parameters)
		{
			using (measureBlock("build time"))
			using (beginBuild(BuildManager, parameters))
			using (cancellation.Register(() =>
			{
				Log.I("cancelling background build");
				BuildManager.CancelAllSubmissions();
			}))
			{
				var projects = request.AllProjectsToBuildOrdered;
				
				foreach (var project in projects)
				{
					if (cancellation.IsCancellationRequested)
						return BuildStatus.Indeterminate;

					if (request.mustBeSkipped(project))
					{
						notifyProjectSkipped(project);
						continue;
					}

					var buildData = request.createBuildRequestData(project);
					var result = BuildManager.BuildRequest(buildData);
					switch (result.OverallResult)
					{
						case BuildResultCode.Success:
							continue;
						case BuildResultCode.Failure:
							return BuildStatus.Failed;
						default:
							throw new ArgumentOutOfRangeException();
					}
				}

				return BuildStatus.Ok;
			}
		}
Beispiel #51
0
        public void TestPacketType()
        {
            BuildRequest request = CreateNewBuildRequest(0, Array.Empty <string>());

            Assert.Equal(NodePacketType.BuildRequest, request.Type);
        }
		void printIntro(BuildRequest request)
		{
			var isSolution = request.WholeSolutionBuild;
			var projectInfo = isSolution ?
				"Solution: " + getSolutionNameFromFilename(request.SolutionPath)
				: (request.PrimaryProjects.Length == 1
					? ("Project: " + nameOfProject(request.PrimaryProjects[0]))
					: ("Projects: " + request.PrimaryProjects.Select(nameOfProject).Aggregate((a, b) => a + ";" + b)));
			var configurationInfo = "Configuration: " + request.Configuration + " " + request.Platform;

			coreToIDE(() => _pane.OutputString($"---------- BuildOnSave: {projectInfo}, {configurationInfo} ----------\n"));
		}
Beispiel #53
0
        public static bool CheckPlacement(Point2D location, Point2D size, uint type, BuildRequest skipRequest, bool buildingsOnly)
        {
            // Check if the building can be placed on this position of the map.
            for (float x = -size.X / 2f; x < size.X / 2f + 0.1f; x++)
            {
                for (float y = -size.Y / 2f; y < size.Y / 2f + 0.1f; y++)
                {
                    if (!SC2Util.GetTilePlacable((int)Math.Round(location.X + x), (int)Math.Round(location.Y + y)))
                    {
                        return(false);
                    }
                }
            }

            if (CanHaveAddOn(type))
            {
                if (!SC2Util.GetTilePlacable((int)Math.Round(location.X + 2f), (int)Math.Round(location.Y - 1)))
                {
                    return(false);
                }
                if (!SC2Util.GetTilePlacable((int)Math.Round(location.X + 2f), (int)Math.Round(location.Y)))
                {
                    return(false);
                }
                if (!SC2Util.GetTilePlacable((int)Math.Round(location.X + 3f), (int)Math.Round(location.Y - 1)))
                {
                    return(false);
                }
                if (!SC2Util.GetTilePlacable((int)Math.Round(location.X + 3f), (int)Math.Round(location.Y)))
                {
                    return(false);
                }
            }

            foreach (Unit unit in Tyr.Bot.Observation.Observation.RawData.Units)
            {
                if (!unit.IsFlying && (unit.Owner != Tyr.Bot.PlayerId || unit.UnitType == UnitTypes.SIEGE_TANK_SIEGED || UnitTypes.BuildingTypes.Contains(unit.UnitType)) && !CheckDistance(location, type, SC2Util.To2D(unit.Pos), unit.UnitType, buildingsOnly))
                {
                    return(false);
                }
            }

            foreach (BuildRequest request in ConstructionTask.Task.UnassignedRequests)
            {
                if (request != skipRequest && !CheckDistance(location, type, request.Pos, request.Type, buildingsOnly))
                {
                    return(false);
                }
            }

            foreach (BuildRequest request in ConstructionTask.Task.BuildRequests)
            {
                if (request != skipRequest && !CheckDistance(location, type, request.Pos, request.Type, buildingsOnly))
                {
                    return(false);
                }
            }

            if (Tyr.Bot.MyRace == Race.Zerg && type != UnitTypes.HATCHERY && type != UnitTypes.EXTRACTOR)
            {
                BoolGrid creep = new ImageBoolGrid(Tyr.Bot.Observation.Observation.RawData.MapState.Creep, 1);
                for (float dx = -size.X / 2f; dx <= size.X / 2f + 0.01f; dx++)
                {
                    for (float dy = -size.Y / 2f; dy <= size.Y / 2f + 0.01f; dy++)
                    {
                        if (!creep[(int)(location.X + dx), (int)(location.Y + dy)])
                        {
                            return(false);
                        }
                    }
                }
            }
            if (Tyr.Bot.MyRace != Race.Zerg)
            {
                BoolGrid creep = new ImageBoolGrid(Tyr.Bot.Observation.Observation.RawData.MapState.Creep, 1);
                for (float dx = -size.X / 2f; dx <= size.X / 2f + 0.01f; dx++)
                {
                    for (float dy = -size.Y / 2f; dy <= size.Y / 2f + 0.01f; dy++)
                    {
                        if (creep[(int)(location.X + dx), (int)(location.Y + dy)])
                        {
                            return(false);
                        }
                    }
                }
            }

            if (type != UnitTypes.PYLON && Tyr.Bot.MyRace == Race.Protoss)
            {
                foreach (Unit unit in Tyr.Bot.Observation.Observation.RawData.Units)
                {
                    if (unit.UnitType != UnitTypes.PYLON || unit.BuildProgress < 1)
                    {
                        continue;
                    }

                    if (Tyr.Bot.MapAnalyzer.MapHeight((int)unit.Pos.X, (int)unit.Pos.Y) < Tyr.Bot.MapAnalyzer.MapHeight((int)location.X, (int)location.Y))
                    {
                        continue;
                    }

                    if (location.X - size.X / 2f >= unit.Pos.X - 6 && location.X + size.X / 2f <= unit.Pos.X + 6 &&
                        location.Y - size.Y / 2f >= unit.Pos.Y - 7 && location.Y + size.Y / 2f <= unit.Pos.Y + 7)
                    {
                        if (SC2Util.DistanceGrid(unit.Pos, location) <= 10 - size.X / 2f - size.Y / 2f)
                        {
                            return(true);
                        }
                    }
                }
                return(false);
            }

            return(true);
        }
 /// <summary>
 /// Log that a project has started if it is serviced from the cache
 /// </summary>
 /// <param name="request">The build request.</param>
 /// <param name="configuration">The configuration used to build the request.</param>
 /// <returns>The BuildEventContext to use for this project.</returns>
 internal ProjectLoggingContext LogProjectStarted(BuildRequest request, BuildRequestConfiguration configuration)
 {
     ErrorUtilities.VerifyThrow(this.IsValid, "Build not started.");
     return new ProjectLoggingContext(this, request, configuration.ProjectFullPath, configuration.ToolsVersion, request.ParentBuildEventContext);
 }