/// <summary> /// Creates a build request. /// </summary> private BuildRequest CreateBuildRequest(int nodeRequestId, int configId, string[] targets, NodeAffinity nodeAffinity, BuildRequest parentRequest) { HostServices hostServices = null; if (nodeAffinity != NodeAffinity.Any) { hostServices = new HostServices(); hostServices.SetNodeAffinity(String.Empty, nodeAffinity); } BuildRequest request = new BuildRequest(1 /* submissionId */, nodeRequestId, configId, targets, hostServices, BuildEventContext.Invalid, parentRequest); return request; }
public void TestUnregisteringNonConflictingHostObjectRestoresOriginalAffinity() { HostServices hostServices = new HostServices(); TestHostObject hostObject = new TestHostObject(); hostServices.SetNodeAffinity(String.Empty, NodeAffinity.OutOfProc); hostServices.SetNodeAffinity("project", NodeAffinity.Any); Assert.AreEqual(NodeAffinity.OutOfProc, hostServices.GetNodeAffinity("project2")); Assert.AreEqual(NodeAffinity.Any, hostServices.GetNodeAffinity("project")); hostServices.RegisterHostObject("project", "target", "task", hostObject); Assert.AreEqual(NodeAffinity.InProc, hostServices.GetNodeAffinity("project")); hostServices.RegisterHostObject("project", "target", "task", null); Assert.AreEqual(NodeAffinity.Any, hostServices.GetNodeAffinity("project")); Assert.AreEqual(NodeAffinity.OutOfProc, hostServices.GetNodeAffinity("project2")); }
public void TestProjectInstanceWithNonConflictingHostServices() { HostServices hostServices = new HostServices(); ProjectInstance project = CreateDummyProject("foo.proj"); BuildRequestData data = new BuildRequestData(project, new string[] { }, hostServices); hostServices.SetNodeAffinity(project.FullPath, NodeAffinity.InProc); BuildRequestData data2 = new BuildRequestData(project, new string[] { }, hostServices); }
public void TestNonContraditcoryHostObjectAllowed_InProc() { HostServices hostServices = new HostServices(); TestHostObject hostObject = new TestHostObject(); hostServices.SetNodeAffinity("project", NodeAffinity.InProc); hostServices.RegisterHostObject("project", "target", "task", hostObject); }
public void TestAffinityChangeAfterClearingHostObject() { HostServices hostServices = new HostServices(); TestHostObject hostObject = new TestHostObject(); hostServices.RegisterHostObject("project", "target", "task", hostObject); Assert.AreEqual(NodeAffinity.InProc, hostServices.GetNodeAffinity("project")); hostServices.RegisterHostObject("project", "target", "task", null); Assert.AreEqual(NodeAffinity.Any, hostServices.GetNodeAffinity("project")); hostServices.SetNodeAffinity("project", NodeAffinity.OutOfProc); Assert.AreEqual(NodeAffinity.OutOfProc, hostServices.GetNodeAffinity("project")); }
public void TestContraditcoryHostObjectCausesException_OutOfProc() { HostServices hostServices = new HostServices(); TestHostObject hostObject = new TestHostObject(); hostServices.SetNodeAffinity("project", NodeAffinity.OutOfProc); hostServices.RegisterHostObject("project", "target", "task", hostObject); }
public void TestNonContraditcoryHostObjectAllowed_Any() { HostServices hostServices = new HostServices(); TestHostObject hostObject = new TestHostObject(); hostServices.SetNodeAffinity("project", NodeAffinity.Any); hostServices.RegisterHostObject("project", "target", "task", hostObject); Assert.AreEqual(NodeAffinity.InProc, hostServices.GetNodeAffinity("project")); }
public void TestClearingAffinities() { HostServices hostServices = new HostServices(); hostServices.SetNodeAffinity("project", NodeAffinity.OutOfProc); Assert.AreEqual(NodeAffinity.OutOfProc, hostServices.GetNodeAffinity("project")); hostServices.SetNodeAffinity(null, NodeAffinity.OutOfProc); Assert.AreEqual(NodeAffinity.Any, hostServices.GetNodeAffinity("project")); hostServices.SetNodeAffinity(String.Empty, NodeAffinity.OutOfProc); Assert.AreEqual(NodeAffinity.OutOfProc, hostServices.GetNodeAffinity("project")); hostServices.SetNodeAffinity(null, NodeAffinity.OutOfProc); Assert.AreEqual(NodeAffinity.Any, hostServices.GetNodeAffinity("project")); }
public void TestContradictoryAffinityCausesException_Any() { HostServices hostServices = new HostServices(); TestHostObject hostObject = new TestHostObject(); hostServices.RegisterHostObject("project", "target", "task", hostObject); Assert.AreEqual(NodeAffinity.InProc, hostServices.GetNodeAffinity("project")); hostServices.SetNodeAffinity("project", NodeAffinity.Any); }
public void TestOverrideGeneralAffinityRegistration() { HostServices hostServices = new HostServices(); hostServices.SetNodeAffinity(String.Empty, NodeAffinity.InProc); hostServices.SetNodeAffinity("project", NodeAffinity.OutOfProc); Assert.AreEqual(NodeAffinity.OutOfProc, hostServices.GetNodeAffinity("project")); Assert.AreEqual(NodeAffinity.InProc, hostServices.GetNodeAffinity("project2")); }
public void TestDefaultAffinityWhenProjectNotRegistered() { HostServices hostServices = new HostServices(); hostServices.SetNodeAffinity("project1", NodeAffinity.InProc); Assert.AreEqual(NodeAffinity.Any, hostServices.GetNodeAffinity("project2")); }
public void TestSpecificAffinityRegistration() { HostServices hostServices = new HostServices(); hostServices.SetNodeAffinity("project", NodeAffinity.InProc); Assert.AreEqual(NodeAffinity.InProc, hostServices.GetNodeAffinity("project")); hostServices.SetNodeAffinity("project", NodeAffinity.OutOfProc); Assert.AreEqual(NodeAffinity.OutOfProc, hostServices.GetNodeAffinity("project")); hostServices.SetNodeAffinity("project", NodeAffinity.Any); Assert.AreEqual(NodeAffinity.Any, hostServices.GetNodeAffinity("project")); }
public void Regress265010() { string contents = ObjectModelHelpers.CleanupFileContents(@" <Project xmlns='msbuildnamespace' ToolsVersion='msbuilddefaulttoolsversion'> <PropertyGroup> <Prop>BaseValue</Prop> </PropertyGroup> <ItemGroup> <Item Include='BaseItem'/> </ItemGroup> <Target Name='BaseTest'> <Message Text='[$(Prop)]'/> <Message Text='[@(Item)]'/> <PropertyGroup> <Prop>NewValue</Prop> </PropertyGroup> <ItemGroup> <Item Include='NewItem'/> </ItemGroup> </Target> <Target Name='MovedTest'> <Message Text='[$(Prop)]'/> <Message Text='[@(Item)]'/> </Target> </Project> "); string fileName = Path.GetTempFileName(); File.WriteAllText(fileName, contents); _buildManager.BeginBuild(_parameters); try { HostServices services = new HostServices(); services.SetNodeAffinity(fileName, NodeAffinity.OutOfProc); BuildRequestData data = new BuildRequestData(fileName, new Dictionary<string, string>(), ObjectModelHelpers.MSBuildDefaultToolsVersion, new[] { "BaseTest" }, services); _buildManager.PendBuildRequest(data).Execute(); _logger.AssertLogContains("[BaseValue]"); _logger.AssertLogContains("[BaseItem]"); _logger.ClearLog(); _parameters.ResetCaches = false; services.SetNodeAffinity(fileName, NodeAffinity.InProc); data = new BuildRequestData(fileName, new Dictionary<string, string>(), ObjectModelHelpers.MSBuildDefaultToolsVersion, new[] { "MovedTest" }, services); _buildManager.PendBuildRequest(data).Execute(); _logger.AssertLogContains("[NewValue]"); _logger.AssertLogContains("[BaseItem;NewItem]"); _logger.AssertLogDoesntContain("[BaseValue]"); } finally { if (File.Exists(fileName)) { File.Delete(fileName); } _buildManager.EndBuild(); } }
public void TestContraditcoryHostObjectCausesException_OutOfProc() { Assert.Throws<InvalidOperationException>(() => { HostServices hostServices = new HostServices(); TestHostObject hostObject = new TestHostObject(); hostServices.SetNodeAffinity("project", NodeAffinity.OutOfProc); hostServices.RegisterHostObject("project", "target", "task", hostObject); } ); }