public void TestTranslation()
        {
            BuildRequestConfigurationResponse response = new BuildRequestConfigurationResponse(1, 2, 3);

            Assert.Equal(response.Type, NodePacketType.BuildRequestConfigurationResponse);

            ((INodePacketTranslatable)response).Translate(TranslationHelpers.GetWriteTranslator());

            INodePacket deserializedPacket = BuildRequestConfigurationResponse.FactoryForDeserialization(TranslationHelpers.GetReadTranslator());
            BuildRequestConfigurationResponse deserializedResponse = deserializedPacket as BuildRequestConfigurationResponse;

            Assert.Equal(response.NodeConfigurationId, deserializedResponse.NodeConfigurationId);
            Assert.Equal(response.GlobalConfigurationId, deserializedResponse.GlobalConfigurationId);
            Assert.Equal(response.ResultsNodeId, deserializedResponse.ResultsNodeId);
        }
 public void TestConstructor()
 {
     BuildRequestConfigurationResponse response   = new BuildRequestConfigurationResponse(0, 0, 0);
     BuildRequestConfigurationResponse response2  = new BuildRequestConfigurationResponse(0, 1, 0);
     BuildRequestConfigurationResponse response3  = new BuildRequestConfigurationResponse(0, -1, 0);
     BuildRequestConfigurationResponse response4  = new BuildRequestConfigurationResponse(1, 0, 0);
     BuildRequestConfigurationResponse response5  = new BuildRequestConfigurationResponse(1, 1, 0);
     BuildRequestConfigurationResponse response6  = new BuildRequestConfigurationResponse(1, -1, 0);
     BuildRequestConfigurationResponse response7  = new BuildRequestConfigurationResponse(-1, 0, 0);
     BuildRequestConfigurationResponse response8  = new BuildRequestConfigurationResponse(-1, 1, 0);
     BuildRequestConfigurationResponse response9  = new BuildRequestConfigurationResponse(-1, -1, 0);
     BuildRequestConfigurationResponse response10 = new BuildRequestConfigurationResponse(0, 0, 1);
     BuildRequestConfigurationResponse response11 = new BuildRequestConfigurationResponse(0, 1, 0);
     BuildRequestConfigurationResponse response12 = new BuildRequestConfigurationResponse(0, -1, -1);
     BuildRequestConfigurationResponse response13 = new BuildRequestConfigurationResponse(1, 0, 1);
     BuildRequestConfigurationResponse response14 = new BuildRequestConfigurationResponse(1, 1, 0);
     BuildRequestConfigurationResponse response15 = new BuildRequestConfigurationResponse(1, -1, -1);
     BuildRequestConfigurationResponse response16 = new BuildRequestConfigurationResponse(-1, 0, 1);
     BuildRequestConfigurationResponse response17 = new BuildRequestConfigurationResponse(-1, 1, 0);
     BuildRequestConfigurationResponse response18 = new BuildRequestConfigurationResponse(-1, -1, -1);
 }
Example #3
0
        public void TestBuildWithNewConfiguration()
        {
            BuildRequestData          data   = new BuildRequestData(Path.GetFullPath("TestFile"), new Dictionary <string, string>(), "TestToolsVersion", new string[0], null);
            BuildRequestConfiguration config = new BuildRequestConfiguration(1, data, "2.0");

            _cache.AddConfiguration(config);

            // Configure the builder to spawn build requests
            MockRequestBuilder        builder          = (MockRequestBuilder)_host.GetComponent(BuildComponentType.RequestBuilder);
            BuildRequestData          data2            = new BuildRequestData(Path.GetFullPath("OtherFile"), new Dictionary <string, string>(), "TestToolsVersion", new string[0], null);
            BuildRequestConfiguration unresolvedConfig = new BuildRequestConfiguration(data2, "2.0");

            builder.NewRequests.Add(new FullyQualifiedBuildRequest[1] {
                new FullyQualifiedBuildRequest(unresolvedConfig, new string[1] {
                    "requiredTarget1"
                }, true)
            });

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

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

            // Wait for the request to generate the child request with the unresolved configuration
            WaitForEvent(_newConfigurationEvent, "NewConfigurationEvent");
            Assert.Equal(Path.GetFullPath("OtherFile"), _newConfiguration_Config.ProjectFullPath);
            Assert.Equal("TestToolsVersion", _newConfiguration_Config.ToolsVersion);
            Assert.True(_newConfiguration_Config.WasGeneratedByNode);
            Thread.Sleep(250);
            VerifyEngineStatus(BuildRequestEngineStatus.Waiting);

            // Resolve the configuration
            BuildRequestConfigurationResponse response = new BuildRequestConfigurationResponse(_newConfiguration_Config.ConfigurationId, 2, 0);

            _engine.ReportConfigurationResponse(response);

            // Now wait for the actual requests to be issued.
            WaitForEvent(_newRequestEvent, "NewRequestEvent");
            Assert.Equal(2, _newRequest_Request.BuildRequests[0].ConfigurationId);
            Assert.Equal(2, _newRequest_Request.BuildRequests[0].ConfigurationId);
            Assert.Single(_newRequest_Request.BuildRequests[0].Targets);
            Assert.Equal("requiredTarget1", _newRequest_Request.BuildRequests[0].Targets[0]);

            // Report a result to satisfy the build request
            BuildResult result = new BuildResult(_newRequest_Request.BuildRequests[0]);

            result.AddResultsForTarget("requiredTarget1", BuildResultUtilities.GetEmptySucceedingTargetResult());
            _engine.UnblockBuildRequest(new BuildRequestUnblocker(result));

            // Continue the request
            _engine.UnblockBuildRequest(new BuildRequestUnblocker(request.GlobalRequestId));

            // Wait for the original request to complete
            WaitForEvent(_requestCompleteEvent, "RequestComplete");
            Assert.Equal(request, _requestComplete_Request);
            Assert.Equal(BuildResultCode.Success, _requestComplete_Result.OverallResult);
            Thread.Sleep(250);
            VerifyEngineStatus(BuildRequestEngineStatus.Idle);
        }
Example #4
0
 private void HandleBuildRequestConfigurationResponse(BuildRequestConfigurationResponse response)
 {
     _buildRequestEngine.ReportConfigurationResponse(response);
 }
        public void TestResultsNodeId()
        {
            BuildRequestConfigurationResponse response = new BuildRequestConfigurationResponse(0, 1, 2);

            Assert.Equal(2, response.ResultsNodeId);
        }
        public void TestGlobalConfigurationId()
        {
            BuildRequestConfigurationResponse response = new BuildRequestConfigurationResponse(0, 1, 0);

            Assert.Equal(1, response.GlobalConfigurationId);
        }
        public void TestNodeConfigurationId()
        {
            BuildRequestConfigurationResponse response = new BuildRequestConfigurationResponse(1, 0, 0);

            Assert.Equal(1, response.NodeConfigurationId);
        }