Esempio n. 1
0
        public void CheckBasicOperation()
        {
            CacheManager cacheManager = new CacheManager("3.5");
            CacheScope   cacheScope   = cacheManager.GetCacheScope("Test.proj", new BuildPropertyGroup(), "3.5", CacheContentType.Items);

            Assert.IsNotNull(cacheScope, "Cache should not have an entry");
            CacheScope cacheScope1 = cacheManager.GetCacheScope("Test.proj", new BuildPropertyGroup(), "3.5", CacheContentType.Items);

            Assert.AreEqual(cacheScope, cacheScope1, "Expected to get the same scope");
            cacheScope1 = cacheManager.GetCacheScope("Test1.proj", new BuildPropertyGroup(), "3.5", CacheContentType.Items);
            Assert.IsNotNull(cacheScope1, "Cache should not have an entry");
            Assert.AreNotEqual(cacheScope, cacheScope1, "Expected to get different scopes");
            // Add an entry and verify that it ends up in the right scope
            CacheEntry cacheEntry  = new BuildResultCacheEntry("TestEntry", null, true);
            CacheEntry cacheEntry1 = new BuildResultCacheEntry("TestEntry1", null, true);

            cacheManager.SetCacheEntries(new CacheEntry[] { cacheEntry }, "Test.proj", new BuildPropertyGroup(), "3.5", CacheContentType.Items);
            Assert.IsNotNull(cacheScope.GetCacheEntry("TestEntry"), "Cache should have an entry");
            Assert.IsNotNull(cacheManager.GetCacheEntries(new string[] { "TestEntry" }, "Test.proj", new BuildPropertyGroup(), "3.5", CacheContentType.Items)[0],
                             "Cache should have an entry");
            cacheManager.SetCacheEntries(new CacheEntry[] { cacheEntry1 }, "Test1.proj", new BuildPropertyGroup(), "3.5", CacheContentType.Items);
            Assert.IsNotNull(cacheScope1.GetCacheEntry("TestEntry1"), "Cache should have an entry");
            Assert.IsNotNull(cacheManager.GetCacheEntries(new string[] { "TestEntry1" }, "Test1.proj", new BuildPropertyGroup(), "3.5", CacheContentType.Items)[0],
                             "Cache should have an entry");
            // Try clearing the whole cache
            cacheManager.ClearCache();
            Assert.AreNotEqual(cacheScope, cacheManager.GetCacheScope("Test.proj", new BuildPropertyGroup(), "3.5", CacheContentType.Items),
                               "Expected to get different scopes");
        }
Esempio n. 2
0
        public void BasicCacheOperation()
        {
            BuildPropertyGroup default_scope = new BuildPropertyGroup();
            CacheScope         testScope     = new CacheScope("Test.proj", new BuildPropertyGroup(), "2.0");
            // First add a single entry and verify that it is in the cache
            CacheEntry cacheEntry = new BuildResultCacheEntry("TestEntry", null, true);

            testScope.AddCacheEntry(cacheEntry);
            Assert.IsTrue(testScope.ContainsCacheEntry("TestEntry"), "Expect entry in the cache");
            CacheEntry inCacheEntry = testScope.GetCacheEntry("TestEntry");

            Assert.IsNotNull(inCacheEntry, "Cache should have an entry");
            Assert.IsTrue(inCacheEntry.IsEquivalent(cacheEntry), "Expect entry to be the same");
            // Add a second entry and then remove the first entry. Verify that the first entry
            // is not in the cache while the second entry is still there
            cacheEntry = new BuildResultCacheEntry("TestEntry2", null, true);
            testScope.AddCacheEntry(cacheEntry);
            testScope.ClearCacheEntry("TestEntry");
            Assert.IsFalse(testScope.ContainsCacheEntry("TestEntry"), "Didn't expect entry in the cache");
            Assert.IsTrue(testScope.ContainsCacheEntry("TestEntry2"), "Expected entry in the cache");
            Assert.IsNull(testScope.GetCacheEntry("TestEntry"), "Cache should  not have an entry");
            Assert.IsNotNull(testScope.GetCacheEntry("TestEntry2"), "Cache should have an entry");
        }
Esempio n. 3
0
        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");
        }
Esempio n. 4
0
        public void AddResultToCache()
        {
            Assert.IsNull(cacheScope.GetCacheEntry("TaskItems"), "Cache should not have an entry");
            NodeRequestMapping requestMapping = new NodeRequestMapping(1, 1, cacheScope);

            Assert.AreEqual(1, requestMapping.HandleId, "Expected NodeProxyId to be 1");
            Assert.AreEqual(1, requestMapping.RequestId, "Expected RequestId to be 1");
            requestMapping.AddResultToCache(resultWithOutputs);
            Assert.IsTrue(resultWithOutputs.EvaluationResult == ((BuildResultCacheEntry)cacheScope.GetCacheEntry("TaskItems")).BuildResult,
                          "Expected EvaluationResult to be the same after it was retrieved from the cache");
            Assert.IsTrue(((BuildItem[])resultWithOutputs.OutputsByTarget["TaskItems"])[0].Include == ((BuildResultCacheEntry)cacheScope.GetCacheEntry("TaskItems")).BuildItems[0].Include,
                          "Expected EvaluationResult to be the same after it was retrieved from the cache");
            // Remove the entry from the cache
            cacheScope.ClearCacheEntry("TaskItems");
        }