Esempio n. 1
0
        public void RejectCachesWithMoreConfigEntriesThanResultEntries()
        {
            var configCache = new ConfigCache();

            configCache.AddConfiguration(new BuildRequestConfiguration(configId: 1, new BuildRequestData("path", new Dictionary <string, string>()
            {
                ["p"] = "v"
            }, "13", new [] { "a", "b" }, null), "13"));
            configCache.AddConfiguration(new BuildRequestConfiguration(configId: 2, new BuildRequestData("path2", new Dictionary <string, string>()
            {
                ["p"] = "v"
            }, "13", new [] { "c", "d" }, null), "13"));

            var resultsCache = new ResultsCache();
            var buildResult  = new BuildResult(new BuildRequest(1, 2, configurationId: 1, new List <string>()
            {
                "a", "b"
            }, null, BuildEventContext.Invalid, null));

            buildResult.AddResultsForTarget("a", GetNonEmptySucceedingTargetResult());
            resultsCache.AddResult(buildResult);

            aggregator.Add(configCache, resultsCache);

            using (var env = TestEnvironment.Create())
            {
                env.SetEnvironmentVariable("MSBUILDDONOTLAUNCHDEBUGGER", "1");
                var e = Should.Throw <InternalErrorException>(() => aggregator.Aggregate());
                e.Message.ShouldContain("Assuming 1-to-1 mapping between configs and results. Otherwise it means the caches are either not minimal or incomplete");
            }
        }
Esempio n. 2
0
        public void RejectCachesWithMismatchedIds()
        {
            // one entry in each cache but different config ids

            var configCache = new ConfigCache();

            configCache.AddConfiguration(new BuildRequestConfiguration(configId: 1, new BuildRequestData("path", new Dictionary <string, string>()
            {
                ["p"] = "v"
            }, "13", new [] { "a", "b" }, null), "13"));

            var resultsCache = new ResultsCache();
            var buildResult  = new BuildResult(new BuildRequest(1, 2, configurationId: 2, new List <string>()
            {
                "a", "b"
            }, null, BuildEventContext.Invalid, null));

            buildResult.AddResultsForTarget("a", GetNonEmptySucceedingTargetResult());
            resultsCache.AddResult(buildResult);

            aggregator.Add(configCache, resultsCache);

            using (var env = TestEnvironment.Create())
            {
                env.SetEnvironmentVariable("MSBUILDDONOTLAUNCHDEBUGGER", "1");
                var e = Should.Throw <InternalErrorException>(() => aggregator.Aggregate());
                e.Message.ShouldContain("Each result should have a corresponding configuration. Otherwise the caches are not consistent");
            }
        }
Esempio n. 3
0
        public void RejectCollidingConfigurationsFromSeparateCaches()
        {
            // collides with the config id from configCache2
            var configCache1 = new ConfigCache();

            configCache1.AddConfiguration(new BuildRequestConfiguration(configId: 1, new BuildRequestData("path", new Dictionary <string, string>()
            {
                ["p"] = "v"
            }, "13", new [] { "a", "b" }, null), "13"));

            var resultsCache1 = new ResultsCache();
            var buildResult11 = new BuildResult(new BuildRequest(1, 2, configurationId: 1, new List <string>()
            {
                "a", "b"
            }, null, BuildEventContext.Invalid, null));

            buildResult11.AddResultsForTarget("a", GetNonEmptySucceedingTargetResult());
            resultsCache1.AddResult(buildResult11);

            var configCache2 = new ConfigCache();

            configCache2.AddConfiguration(new BuildRequestConfiguration(configId: 1, new BuildRequestData("path", new Dictionary <string, string>()
            {
                ["p"] = "v"
            }, "13", new [] { "a", "b" }, null), "13"));

            var resultsCache2 = new ResultsCache();
            var buildResult21 = new BuildResult(new BuildRequest(1, 2, configurationId: 1, new List <string>()
            {
                "e", "f"
            }, null, BuildEventContext.Invalid, null));

            buildResult21.AddResultsForTarget("a", GetNonEmptySucceedingTargetResult());
            resultsCache2.AddResult(buildResult21);

            aggregator.Add(configCache1, resultsCache1);
            aggregator.Add(configCache2, resultsCache2);

            using (var env = TestEnvironment.Create())
            {
                env.SetEnvironmentVariable("MSBUILDDONOTLAUNCHDEBUGGER", "1");
                var e = Should.Throw <InternalErrorException>(() => aggregator.Aggregate());
                e.Message.ShouldContain("Input caches should not contain entries for the same configuration");
            }
        }