/// <summary> /// This method creates a BuildResult using the information contained in a completed build request and /// then routes it to the right node. On a child process, this means either consume the result localy, /// or send it to the parent node. On a parent node, this means either consume the result locally or /// send it to a child node /// </summary> internal void PostDoneNotice(BuildRequest buildRequest) { // Create a container with the results of the evaluation BuildResult buildResult = buildRequest.GetBuildResult(); // If we're supposed to use caching and this request wasn't restored from cache, cache it if (buildRequest.UseResultsCache && !buildRequest.RestoredFromCache) { CacheScope cacheScope = parentEngine.CacheManager.GetCacheScope(buildRequest.ProjectFileName, buildRequest.GlobalProperties, buildRequest.ToolsetVersion, CacheContentType.BuildResults); cacheScope.AddCacheEntryForBuildResults(buildResult); } // an external request is any request that came from the parent engine, all requests to a child are external // unless the project was alredy loaded on the node itself if (buildRequest.IsExternalRequest) { // If the build request was send from outside the current process, // send the results to the parent engine parentNode.PostBuildResultToHost(buildResult); } else { // In the case of a child process, getting to this point means the request will be satisfied locally, the node index should be 0 // on the parent engine however, the node index can be, 0 for the local node, or can be >0 which represents a child node PostDoneNotice(buildRequest.NodeIndex, buildResult); } }
public void AddRemoveBuildResults() { BuildPropertyGroup default_scope = new BuildPropertyGroup(); CacheScope testScope = new CacheScope("Test.proj", new BuildPropertyGroup(), "2.0"); // First add a single empty result (expect no crash) testScope.AddCacheEntryForBuildResults(resultWith0Outputs); // Add a single result - expect to find target in the cache testScope.AddCacheEntryForBuildResults(resultWith1Outputs); Assert.IsTrue(testScope.ContainsCacheEntry("Target1"), "Expected entry in the cache"); Assert.IsNotNull(testScope.GetCacheEntry("Target1"), "Cache should have an entry"); // Add a double result expect both target in the entry testScope.AddCacheEntryForBuildResults(resultWith2Outputs); Assert.IsTrue(testScope.ContainsCacheEntry("Target2"), "Expected entry in the cache"); Assert.IsNotNull(testScope.GetCacheEntry("Target2"), "Cache should have an entry"); Assert.IsTrue(testScope.ContainsCacheEntry("Target3"), "Expected entry in the cache"); Assert.IsNotNull(testScope.GetCacheEntry("Target3"), "Cache should have an entry"); // Double add a result ( expect no crash since it is identical ) testScope.AddCacheEntryForBuildResults(resultWith1Outputs); // Add an uncacheable result and verify that it is not in the cache testScope.AddCacheEntryForBuildResults(uncacheableResult); Assert.IsFalse(testScope.ContainsCacheEntry("Target4"), "Didn't expect entry in the cache"); Assert.IsNull(testScope.GetCacheEntry("Target4"), "Cache should not have an entry"); }