public BuildComponent(XmlElement xe, BuildFile bf) { this.Validate(xe); this.xe = xe; this.ParentBuildFile = bf; this.ParseActions(); }
public void TestNameProperty() { XmlDocument xd = TestData.XmlDocument; BuildFile bf = new BuildFile(); bf.LoadXmlDocument(xd); BuildComponent bc = new BuildComponent((XmlElement)xd.SelectSingleNode("//BuildComponent[@name='TestComponent']"), bf); Assert.AreEqual(bc.Name, "TestComponent"); }
private void FillListBc(BuildFile bf) { foreach (BuildComponent bc in bf.BuildComponents) { cListBC.Items.Add(bc.Name); if(bf.DefaultComponents != null) cListBC.SetItemChecked(cListBC.Items.Count - 1, bf.DefaultComponents.Contains(bc.Name)); } }
public void DefaultComponentsPropertyTest() { BuildFile bf = new BuildFile(); bf.LoadXmlDocument(TestData.XmlDocument); List<string> comps = (List<string>)bf.DefaultComponents; Assert.AreEqual("Core", comps[0]); Assert.AreEqual("TestComponent", comps[1]); }
private void FillListProperties(BuildFile bf) { // get "raw" property values from build file XmlDocument xd = new XmlDocument(); xd.Load(txtBuildFile.Text); foreach (XmlElement xe in xd.SelectNodes("/CamBuildProject/Property")) { string[] propRow = new string[] { xe.Attributes["name"].Value, xe.InnerText }; dtProperties.Rows.Add(propRow); } }
public void TestActionsProperty() { XmlDocument xd = TestData.XmlDocument; BuildFile bf = new BuildFile(); bf.LoadXmlDocument(xd); BuildComponent bc = new BuildComponent((XmlElement)xd.SelectSingleNode("//BuildComponent[@name='TestComponent']"), bf); List<IAction> actions = (List<IAction>)bc.Actions; Assert.IsTrue(actions.Count == 1); Assert.IsTrue(((IAction)actions[0]).GetType().Name == "WriteConsole"); }
public static ICollection<IBuildFileElement> Parse(XmlDocument xd, BuildFile parentBuildFile) { List<IBuildFileElement> elements = new List<IBuildFileElement>(); foreach (XmlElement xe in xd.DocumentElement.ChildNodes) { IBuildFileElement element = BuildFileElementFactory.Create(xe, parentBuildFile); if (element != null) elements.Add(element); } return elements; }
public void TestDependenciesProperty() { XmlDocument xd = TestData.XmlDocument; BuildFile bf = new BuildFile(); bf.LoadXmlDocument(xd); BuildComponent bc = new BuildComponent((XmlElement)xd.SelectSingleNode("//BuildComponent[@name='TestComponent']"), bf); Assert.AreEqual(1, bc.Dependencies.Count); Assert.AreEqual(((List<string>)bc.Dependencies)[0], "Core"); BuildComponent bc2 = new BuildComponent((XmlElement)xd.SelectSingleNode("//BuildComponent[@name='Core']"), bf); Assert.AreEqual(0, bc2.Dependencies.Count); }
public void TestConstructorXmlParsing() { XmlDocument xd = TestData.XmlDocument; BuildFile bf = new BuildFile(); bf.LoadXmlDocument(xd); try { new BuildComponent(xd.DocumentElement, bf); } catch (Exception ex) { Assert.IsTrue(ex is BuildFileParseException); } }
public static ICollection <IBuildFileElement> Parse(XmlDocument xd, BuildFile parentBuildFile) { List <IBuildFileElement> elements = new List <IBuildFileElement>(); foreach (XmlElement xe in xd.DocumentElement.ChildNodes) { IBuildFileElement element = BuildFileElementFactory.Create(xe, parentBuildFile); if (element != null) { elements.Add(element); } } return(elements); }
public void RunBuildScriptTestTool() { BuildFile bf = new BuildFile(); bf.LoadXmlFile(@"..\..\Scenario\TestTool.xml"); if (Directory.Exists(TestUtility.TempDir + @"TestTool")) Directory.Delete(TestUtility.TempDir + @"TestTool", true); List<IBuildFileElement> elements = (List<IBuildFileElement>)bf.RootElements; new BuildFileElementExecutor().ExecuteElements(elements); Assert.IsTrue(File.Exists(TestUtility.TempDir + @"TestTool\TestApplication.exe")); Assert.IsTrue(File.Exists(TestUtility.TempDir + @"TestTool\TestLibrary.dll")); Assert.IsTrue(File.Exists(TestUtility.TempDir + @"TestTool\Manual\Manual.doc")); Assert.IsTrue(File.Exists(TestUtility.TempDir + @"TestTool\JavaApp.class")); Directory.Delete(TestUtility.TempDir + @"TestTool", true); }
public void ParseTest() { XmlDocument xd = TestData.XmlDocument; BuildFile bf = new BuildFile(); bf.LoadXmlDocument(xd); List<IBuildFileElement> elements = (List<IBuildFileElement>)BuildFileElementParser.Parse(xd, bf); Assert.AreEqual(4, elements.Count); Assert.AreEqual(typeof(Property), elements[0].GetType()); Assert.AreEqual("WriteConsole", elements[1].GetType().Name); Assert.AreEqual(typeof(BuildComponent), elements[2].GetType()); Assert.AreEqual("Core", ((BuildComponent)elements[2]).Name); Assert.AreEqual(typeof(BuildComponent), elements[3].GetType()); Assert.AreEqual("TestComponent", ((BuildComponent)elements[3]).Name); }
public void Create() { XmlDocument xd = TestData.XmlDocument; BuildFile bf = new BuildFile(); bf.LoadXmlDocument(xd); IBuildFileElement elementAction = BuildFileElementFactory.Create((XmlElement)xd.SelectSingleNode("/CamBuildProject/WriteConsole"), bf); Assert.IsTrue(elementAction.GetType().Name == "WriteConsole"); Assert.AreEqual(elementAction.ParentBuildFile, bf); IBuildFileElement elementBuildComponent = BuildFileElementFactory.Create((XmlElement)xd.SelectSingleNode("/CamBuildProject/BuildComponent[@name='TestComponent']"), bf); Assert.IsTrue(elementBuildComponent is BuildComponent); Assert.AreEqual("TestComponent", ((BuildComponent)elementBuildComponent).Name); Assert.AreEqual(elementBuildComponent.ParentBuildFile, bf); IBuildFileElement elementProperty = BuildFileElementFactory.Create((XmlElement)xd.GetElementsByTagName("Property")[0], bf); Assert.AreEqual("Property", elementProperty.GetType().Name); Assert.AreEqual("OutputDir", elementProperty.GetType().GetProperty("Name").GetValue(elementProperty, null).ToString()); Assert.AreEqual(elementProperty.ParentBuildFile, bf); }
public void Test() { BuildFile bf = new BuildFile(); bf.LoadXmlFile(@"..\..\Scenario\Spitfire.xml"); if (Directory.Exists(TestUtility.TempDir + @"Spitfire")) Directory.Delete(TestUtility.TempDir + @"Spitfire", true); List<IBuildFileElement> elements = (List<IBuildFileElement>)bf.RootElements; new BuildFileElementExecutor().ExecuteElements(elements); Assert.IsTrue(File.Exists(TestUtility.TempDir + @"Spitfire\Storage.dll")); Assert.IsTrue(File.Exists(TestUtility.TempDir + @"Spitfire\CommandCore.dll")); Assert.IsTrue(File.Exists(TestUtility.TempDir + @"Spitfire\NetworkModel.dll")); Assert.IsTrue(File.Exists(TestUtility.TempDir + @"Spitfire\ClientCache.dll")); Assert.IsTrue(File.Exists(TestUtility.TempDir + @"Spitfire\MSSQLProvider.dll")); Assert.IsTrue(File.Exists(TestUtility.TempDir + @"Spitfire\Server.exe")); Assert.IsTrue(File.Exists(TestUtility.TempDir + @"Spitfire\ScmClient.exe")); Directory.Delete(TestUtility.TempDir + @"Spitfire", true); }
public static string Evaluate(string valueString, BuildFile parentBuildFile) { List<ValueToken> tokens = (List<ValueToken>)ValueStringTokenizer.TokenizeString(valueString); string eval = ""; foreach (ValueToken token in tokens) { if (token.Type == ValueTokenType.Text) { eval += token.Text; } else if (token.Type == ValueTokenType.Function) { FunctionString fs = new FunctionString(token.Text); IFunction bf = FunctionFactory.Create(fs.Name); List<string> newArgs = new List<string>(); foreach (string arg in fs.Args) { // TODO: This will cause a fatal error if function calls are nested newArgs.Add(ValueStringEvaluator.Evaluate(arg, parentBuildFile)); } eval += bf.GetResult(newArgs); } else if (token.Type == ValueTokenType.Property) { if (parentBuildFile == null) throw new ValueStringEvaluatorException("Value string contains a property, " + "but supplied BuildFile object is null", valueString); eval += parentBuildFile.GetPropertyValue(token.Text); } } return eval; }
public static IBuildFileElement Create(XmlElement xe, BuildFile bf) { if (xe == null) return null; IBuildFileElement element = null; if (xe.Name == "BuildComponent") { element = new BuildComponent(xe, bf); } else if (xe.Name == "Property") { element = new Property(xe.Attributes["name"].Value, xe.InnerText); element.ParentBuildFile = bf; } else // assume that element is a BaseAction { element = ActionFactory.Create(xe); element.ParentBuildFile = bf; } return element; }
public void RunBuildScriptTestToolSpecificComponent() { BuildFile bf = new BuildFile(); bf.LoadXmlFile(@"..\..\Scenario\TestTool.xml"); if (Directory.Exists(TestUtility.TempDir + @"TestTool")) Directory.Delete(TestUtility.TempDir + @"TestTool", true); List<IBuildFileElement> elements = (List<IBuildFileElement>)bf.GetBuildComponentWithRootActions("TestLibrary"); new BuildFileElementExecutor().ExecuteElements(elements); Assert.IsTrue(File.Exists(TestUtility.TempDir + @"TestTool\TestLibrary.dll")); Assert.IsTrue(!File.Exists(TestUtility.TempDir + @"TestTool\TestApplication.exe")); elements.Clear(); elements.Add(bf.GetBuildComponent("JavaApp")); new BuildFileElementExecutor().ExecuteElements(elements); Assert.IsTrue(File.Exists(TestUtility.TempDir + @"TestTool\JavaApp.class")); Directory.Delete(TestUtility.TempDir + @"TestTool", true); }
private BuildFile GetBuildFile() { BuildFile bf = new BuildFile(); try { bf.LoadXmlFile(txtBuildFile.Text); } catch (BuildFileParseException) { MessageBox.Show("Error parsing specified build file", "CamBuild"); return null; } return bf; }
public void ProjectNamePropertyTest() { BuildFile bf = new BuildFile(); bf.LoadXmlDocument(TestData.XmlDocument); Assert.AreEqual("Test Project", bf.ProjectName); }
private void SetRebuild(BuildFile bf) { if (checkForceRebuild.Checked) { bf.ForceRebuildAll(); } }
private void SetProperties(BuildFile bf) { foreach (DataGridViewRow row in dtProperties.Rows) { bf.SetPropertyValue(row.Cells["dtColName"].Value.ToString(), row.Cells["dtColValue"].Value.ToString()); } }
private bool IsValidBuildFile(string filePath) { if (!File.Exists(filePath)) return false; try { BuildFile bf = new BuildFile(); bf.LoadXmlFile(filePath); } catch (XmlException) { return false; } catch (BuildFileParseException) { return false; } return true; }
private void InitializeOptions() { cListBC.Items.Clear(); dtProperties.Rows.Clear(); cListLogging.Items.Clear(); BuildFile bf = new BuildFile(); bf.LoadXmlFile(txtBuildFile.Text); this.FillListBc(bf); this.FillListProperties(bf); this.FillLoggers(); }
private List<IBuildFileElement> GetElements(BuildFile bf) { List<IBuildFileElement> elements = new List<IBuildFileElement>(); if (radioBCAll.Checked) { elements = (List<IBuildFileElement>)bf.RootElements; } else if (radioBCSpec.Checked) { List<string> comps = new List<string>(); foreach (object item in cListBC.CheckedItems) { comps.Add(item.ToString()); } elements = (List<IBuildFileElement>)bf.GetBuildComponentsWithRootActions(comps); } return elements; }
private BuildFile GetBuildFile(string arg) { if (arg == null) throw new CamBuildConsoleException("Argument '-bf' is required."); if (arg.Length == 0) throw new CamBuildConsoleException("Argument '-bf' must be followed by a value (path to build file)."); if (!File.Exists(arg)) throw new CamBuildConsoleException("Argument '-bf' specifies an invalid path or non-existing file."); BuildFile bf = new BuildFile(); bf.LoadXmlFile(arg); return bf; }
private void SetRebuild(string arg, BuildFile bf) { if (arg != null) { // rebuild specified components if (arg != "true") // cla[string] returns "true" if argument is merely present { foreach (string comp in arg.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) { bf.ForceRebuild(comp.Trim()); } } else // rebuild all components { bf.ForceRebuildAll(); } } }
private void SetProperties(BuildFile bf) { string[] propSetters = cla["prop"].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string propSetter in propSetters) { bf.SetPropertyValue(propSetter.Split(new char[] { '=' })[0], propSetter.Split(new char[] { '=' })[1]); } }