Exemple #1
0
        internal override void InternalExecute()
        {
            if (String.IsNullOrEmpty(pathToConsoleRunner))
            {
                throw new FileNotFoundException("Could not automatically find mstest.exe. Please specify it manually using PathToConsoleRunner");
            }

            BuildArgs();
            IExecutable executable = _executable.ExecutablePath(pathToConsoleRunner).UseArgumentBuilder(_argumentBuilder);

            if (!String.IsNullOrEmpty(workingDirectory))
            {
                executable = executable.InWorkingDirectory(workingDirectory);
            }

            //don't throw any errors
            //.WithMessageProcessor()
            int returnCode = executable.Execute();

            //if it returned non-zero then just exit (as a test failed)
            if (returnCode != 0 && base.OnError == OnError.Fail)
            {
                BuildFile.SetErrorState();
                Defaults.Logger.WriteError("ERROR", "MSTest returned non-zero error code");
            }
        }
Exemple #2
0
 private void SetRebuild(BuildFile bf)
 {
     if (checkForceRebuild.Checked)
     {
         bf.ForceRebuildAll();
     }
 }
 static bool BuildFileMatchesAssembly(BuildFile file, string assemblyName)
 {
     return(file.path.ToNPath().FileNameWithoutExtension == assemblyName &&
            (file.role == "ManagedLibrary" ||
             file.role == "DependentManagedLibrary" ||
             file.role == "ManagedEngineAPI"));
 }
        public void VerifyMissingBuildPropertiesWithCondition()
        {
            BuildFile   file   = new BuildFile(@"BuildFiles\DefaultConsoleApplication.csproj");
            ruleElement config = new ruleElement();
            ruleElementBuildProperty buildProperty;

            // Add missing build properties.
            buildProperty           = new ruleElementBuildProperty();
            buildProperty.name      = "dummy";
            buildProperty.value     = "dummy";
            buildProperty.condition = "Debug";
            config.buildProperties.Add(buildProperty);
            config.name        = "BuildProperty";
            config.RuleChecker = new BuildPropertiesRule(config);

            ruleElementBuildProperty rule = new ruleElementBuildProperty();

            rule.name = "BuildProperty";
            IList <LogEntry> entries = config.RuleChecker.Check(file);

            Assert.IsNotNull(entries);
            Assert.AreEqual <int>(config.buildProperties.Count, entries.Count);
            foreach (LogEntry entry in entries)
            {
                Assert.AreEqual <string>("BuildProperty", entry.Rule);
                Assert.AreEqual <string>("PropertyShouldExist", entry.Code);
            }
        }
Exemple #5
0
 private void SetProperties(BuildFile bf)
 {
     foreach (DataGridViewRow row in dtProperties.Rows)
     {
         bf.SetPropertyValue(row.Cells["dtColName"].Value.ToString(), row.Cells["dtColValue"].Value.ToString());
     }
 }
Exemple #6
0
        public override void Execute(IEnumerable <string> args)
        {
            string targetName    = null;
            string outputDir     = null;
            var    configuration = BuildConfiguration.Debug;
            var    nativeArgs    = new List <string>();
            var    runArgs       = new List <string>();
            var    build         = false;
            var    run           = false;
            var    input         = new OptionSet
            {
                { "t=|target=", value => targetName = value },
                { "c=|configuration=", value => configuration = value.ParseEnum <BuildConfiguration>("configuration") },
                { "o=|out-dir|output-dir=", value => outputDir = value },
                { "n=|native-args=", nativeArgs.Add },
                { "a=|run-args=", runArgs.Add },
                { "b|build", value => build = true },
                { "d|debug", value => runArgs.Add("debug") },
                { "r|run", value => run = true },
            }
            .Parse(args);

            var target  = BuildTargets.Get(targetName, input);
            var project = Project.Load(input.Path(".").GetProjectFile());

            if (string.IsNullOrEmpty(outputDir))
            {
                outputDir = project.GetOutputDirectory(configuration, target);
            }

            var file = new BuildFile(outputDir);

            if (!file.Exists)
            {
                throw new InvalidOperationException("Target was not built -- run 'uno build' first");
            }

            if (build || nativeArgs.Count > 0)
            {
                if (!target.CanBuild(file))
                {
                    // If the build script is missing it's probably not needed
                    Log.Warning("A build script was not found in " + outputDir.Quote());
                }
                else if (!target.Build(Shell, file, string.Join(" ", nativeArgs)))
                {
                    ExitCode = 1;
                    return;
                }
            }

            if (run || runArgs.Count > 0)
            {
                if (!target.CanRun(file) ||
                    !target.Run(Shell, file, string.Join(" ", runArgs)).Result)
                {
                    ExitCode = 1;
                }
            }
        }
        public void VerifyCompareEqualToIncorrectCaseSensitive()
        {
            BuildFile   file   = new BuildFile(@"BuildFiles\DefaultConsoleApplication.csproj");
            ruleElement config = new ruleElement();

            ruleElementBuildProperty buildProperty = new ruleElementBuildProperty();

            buildProperty.name                = "Configuration";
            buildProperty.value               = "debug";
            buildProperty.compareOption       = CompareOption.EqualTo.ToString();
            buildProperty.stringCompareOption = StringComparison.Ordinal.ToString();
            config.buildProperties.Add(buildProperty);
            config.name        = "BuildProperty";
            config.RuleChecker = new BuildPropertiesRule(config);

            ruleElementBuildProperty rule = new ruleElementBuildProperty();

            rule.name = "BuildProperty";
            IList <LogEntry> entries = config.RuleChecker.Check(file);

            Assert.IsNotNull(entries);
            Assert.AreEqual <int>(1, entries.Count);
            Assert.AreEqual <string>("BuildProperty", entries[0].Rule);
            Assert.AreEqual <string>("IncorrectValue", entries[0].Code);
        }
        /// <summary>
        /// Checks the current rule on the given build file.
        /// </summary>
        /// <param name="project">The build file to verify.</param>
        /// <returns>The log entries for the specified build file.</returns>
        public override IList <LogEntry> Check(BuildFile project)
        {
            List <LogEntry> entries = new List <LogEntry>();

            bool projectFound = false;

            string[] solutionFiles = Directory.GetFiles(config.solutions.searchPath, "*.sln", SearchOption.AllDirectories);
            foreach (string solutionFile in solutionFiles)
            {
                string solutionFileContents = File.ReadAllText(solutionFile);
                foreach (Match solutionProjectMatch in SolutionProjectExpression.Matches(solutionFileContents))
                {
                    string solutionProjectFileName = solutionProjectMatch.Groups["ProjectFileName"].Value;
                    if (!Path.IsPathRooted(solutionProjectFileName))
                    {
                        // The project file name is a relative path, resolve it against the solution path.
                        solutionProjectFileName = Path.Combine(Path.GetDirectoryName(solutionFile), solutionProjectFileName);
                        solutionProjectFileName = Path.GetFullPath(solutionProjectFileName);
                    }
                    if (string.Equals(solutionProjectFileName, project.Path, StringComparison.OrdinalIgnoreCase))
                    {
                        projectFound = true;
                    }
                }
            }

            if (!projectFound)
            {
                string message = string.Format(CultureInfo.CurrentCulture, "The project is not found in any solution.");
                string detail  = string.Format(CultureInfo.CurrentCulture, "The project is not part of any solution file in the search path {0}.", config.solutions.searchPath);
                entries.Add(new LogEntry(Name, "OrphanedProject", LogLevel.Error, message, detail));
            }

            return(entries);
        }
Exemple #9
0
        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);
        }
Exemple #10
0
        private bool RecursiveDependencyEval(JobManager jobManager, BuildFile bFile, string targetName)
        {
            var targetInst = bFile.Projects.Find(x => x.Name.Equals(targetName));

            if (targetInst == null)
            {
                DisplayUsage("Target [{0}] does not exist", targetName);
                return(false);
            }

            // check if we have already added an instance of the project to the worker list
            if (jobManager.ContainsWorkerData(targetInst))
            {
                return(true);
            }

            Log.InfoFormat("Adding {0} to worker list", targetInst.Name);
            jobManager.AddWorker(targetInst.Name, targetInst);

            if (_argParser.IsSwitchSet("nodeps"))
            {
                return(true);
            }

            foreach (var depName in targetInst.Dependencies)
            {
                var b = RecursiveDependencyEval(jobManager, bFile, depName);
                if (!b)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #11
0
        protected void LoadProjectFile(BuildFile projectsFile)
        {
            _isPopulating = true;

            foreach (var p in projectsFile.Projects)
            {
                var pa = new ProjectAdapter(p)
                {
                    BuildFile = this
                };
                Projects.Add(pa);

                UpdateHashes(pa);
            }
            _isPopulating = false;

            foreach (var p in Projects)
            {
                foreach (var depName in p.Dependencies)
                {
                    var dep = GetProjectByName(depName);
                    if (dep == null)
                    {
                        continue;
                    }

                    dep.ActualDependants.GetInternalList().Add(p);
                    p.ActualDependencies.GetInternalList().Add(dep);
                }
            }
        }
Exemple #12
0
        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 void ConvertFile()
        {
            var texturesToAtlasConverter = new TexturesToAtlasConverter(TexturesFile, ScmlFile);

            atlasFile = texturesToAtlasConverter.GetAtlasFile();
            buildFile = texturesToAtlasConverter.GetBuildFile();
        }
        public void VerifyIncorrectBuildPropertiesForMultipleConditions()
        {
            BuildFile   file   = new BuildFile(@"BuildFiles\DefaultConsoleApplication.csproj");
            ruleElement config = new ruleElement();
            ruleElementBuildProperty buildProperty;

            // Add incorrect build properties.
            buildProperty           = new ruleElementBuildProperty();
            buildProperty.name      = "Optimize";
            buildProperty.value     = "dummy";
            buildProperty.condition = ""; // No condition means it should be true for all configurations (two in this case).
            config.buildProperties.Add(buildProperty);

            buildProperty           = new ruleElementBuildProperty();
            buildProperty.name      = "Optimize";
            buildProperty.value     = "dummy";
            buildProperty.condition = null; // Also try with null.
            config.buildProperties.Add(buildProperty);
            config.name        = "BuildProperty";
            config.RuleChecker = new BuildPropertiesRule(config);

            ruleElementBuildProperty rule = new ruleElementBuildProperty();

            rule.name = "BuildProperty";
            IList <LogEntry> entries = config.RuleChecker.Check(file);

            Assert.IsNotNull(entries);
            Assert.AreEqual <int>(config.buildProperties.Count * 2, entries.Count);
            foreach (LogEntry entry in entries)
            {
                Assert.AreEqual <string>("BuildProperty", entry.Rule);
                Assert.AreEqual <string>("IncorrectValue", entry.Code);
            }
        }
Exemple #15
0
        public void ProjectNamePropertyTest()
        {
            BuildFile bf = new BuildFile();

            bf.LoadXmlDocument(TestData.XmlDocument);

            Assert.AreEqual("Test Project", bf.ProjectName);
        }
Exemple #16
0
 void UpdateValues(Repository values, BuildFile newValues)
 {
     values.BuildFilePath        = newValues.FilePath;
     values.BuildFileUrl         = newValues.Url;
     values.BuildFileSize        = newValues.Size;
     values.BuildFileContent     = newValues.Content;
     values.LastBuildFileUpdated = DateTime.Now;
 }
 public KAnimToScmlConverter(AtlasFile atlasFile, BuildFile buildFile, AnimFile animationFile, string outDir,
                             string outFile)
 {
     AtlasFile     = atlasFile;
     BuildFile     = buildFile;
     AnimationFile = animationFile;
     OutDir        = outDir;
     OutPath       = Path.Join(outDir, outFile);
 }
Exemple #18
0
        public void GetBuildComponentWithRootActionsTest()
        {
            BuildFile bf = TestData.BuildFile;

            List <IBuildFileElement> elements = (List <IBuildFileElement>)bf.GetBuildComponentWithRootActions("Core");

            Assert.AreEqual(2, elements.Count);
            Assert.AreEqual(((BuildComponent)elements[1]).Name, "Core");
        }
Exemple #19
0
        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]);
            }
        }
        public void VerifyCorrectBuildProperties()
        {
            BuildFile   file   = new BuildFile(@"BuildFiles\DefaultConsoleApplication.csproj");
            ruleElement config = new ruleElement();
            ruleElementBuildProperty buildProperty;

            // Add correct build properties.
            buildProperty       = new ruleElementBuildProperty();
            buildProperty.name  = "Configuration";
            buildProperty.value = "Debug";
            config.buildProperties.Add(buildProperty);

            buildProperty       = new ruleElementBuildProperty();
            buildProperty.name  = "Platform";
            buildProperty.value = "AnyCPU";
            config.buildProperties.Add(buildProperty);

            buildProperty       = new ruleElementBuildProperty();
            buildProperty.name  = "ProductVersion";
            buildProperty.value = "8.0.50727";
            config.buildProperties.Add(buildProperty);

            buildProperty           = new ruleElementBuildProperty();
            buildProperty.name      = "DebugSymbols";
            buildProperty.value     = "true";
            buildProperty.condition = "debug";
            config.buildProperties.Add(buildProperty);

            buildProperty           = new ruleElementBuildProperty();
            buildProperty.name      = "DebugType";
            buildProperty.value     = "full";
            buildProperty.condition = "debug";
            config.buildProperties.Add(buildProperty);

            buildProperty           = new ruleElementBuildProperty();
            buildProperty.name      = "DebugType";
            buildProperty.value     = "pdbonly";
            buildProperty.condition = "release";
            config.buildProperties.Add(buildProperty);

            buildProperty           = new ruleElementBuildProperty();
            buildProperty.name      = "ErrorReport";
            buildProperty.value     = "prompt";
            buildProperty.condition = ""; // No condition means it should be true for all configurations (two in this case).
            config.buildProperties.Add(buildProperty);
            config.name        = "BuildProperty";
            config.RuleChecker = new BuildPropertiesRule(config);

            ruleElementBuildProperty rule = new ruleElementBuildProperty();

            rule.name = "BuildProperty";
            IList <LogEntry> entries = config.RuleChecker.Check(file);

            Assert.IsNotNull(entries);
            Assert.AreEqual <int>(0, entries.Count);
        }
Exemple #21
0
        public void GetBuildComponentsTest()
        {
            BuildFile bf = TestData.BuildFile;

            List <BuildComponent> components = (List <BuildComponent>)bf.GetBuildComponents(new List <string>(new string[] { "Core", "TestComponent" }));

            Assert.AreEqual(2, components.Count);
            Assert.AreEqual(components[0].Name, "Core");
            Assert.AreEqual(components[1].Name, "TestComponent");
        }
Exemple #22
0
        public void SetPropertyValueTest()
        {
            BuildFile bf = TestData.BuildFile;

            bf.SetPropertyValue("OutputDir", "TestSetOutputDir");

            Assert.AreEqual(@"TestSetOutputDir", bf.GetPropertyValue("OutputDir"));

            Assert.AreEqual(false, bf.SetPropertyValue("nonexistantproperty", "TestSetOutputDir"));
        }
Exemple #23
0
        public void GetBuildComponentsWithRootActionsTest()
        {
            BuildFile bf = TestData.BuildFile;

            List <IBuildFileElement> elements = (List <IBuildFileElement>)bf.GetBuildComponentsWithRootActions(new List <string>(new string[] { "Core", "TestComponent" }));

            Assert.AreEqual(3, elements.Count);
            Assert.AreEqual(((BuildComponent)elements[1]).Name, "Core");
            Assert.AreEqual(((BuildComponent)elements[2]).Name, "TestComponent");
        }
Exemple #24
0
        public string ToProjectComponent(object obj)
        {
            BuildFile file = (BuildFile)obj;
            string    path = file.Name;

            path = path.Replace(Project.OutputPath, string.Empty);
            path = path.Substring(file.Component.Length + 1);

            return(path);
        }
Exemple #25
0
        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 ExeSample()
        {
            Task.Run.ILMerge(x => x.ExecutableLocatedAt("").AddSource("").AddSource("").OutputTo(""));
            var response = Task.Run.Executable(exe => exe.ExecutablePath(@"c:\temp\myapp.exe").SucceedOnNonZeroErrorCodes());

            if (response == 3 || response == 7)
            {
                BuildFile.SetErrorState();
                Defaults.Logger.WriteError("MYAPP", "myapp.exe returned an error code of " + response);
            }
        }
Exemple #27
0
        private BuildFile PrepBuildFile()
        {
            var bFile = new BuildFile();

            foreach (var projectAdapter in Projects)
            {
                bFile.Projects.Add(projectAdapter.Target);
            }

            return(bFile);
        }
Exemple #28
0
        public override Task <bool> Run(Shell shell, BuildFile file, string args, CancellationToken ct)
        {
            var prefix    = string.Format("http://localhost:{0}/", GetRandomUnusedPort());
            var webServer = new WebServer(prefix, file.RootDirectory);

            shell.Open(Path.Combine(prefix, "index.html"), args);

            Thread.Sleep(TimeSpan.FromSeconds(30)); // TODO: make configurable

            return(Task.FromResult(true));
        }
Exemple #29
0
        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]);
        }
Exemple #30
0
        private void HandleTimeout(IProcessWrapper process)
        {
            Defaults.Logger.WriteDebugMessage("TIMEOUT!");
            process.Kill();
            Thread.Sleep(1000); //wait one second so that the process has time to exit

            if (OnError == OnError.Fail)
            {
                //exit code should only be set if we want the application to fail on error
                BuildFile.SetErrorState(); //set our ExitCode to non-zero so consumers know we errored
            }
        }
Exemple #31
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            BuildFile bf = new BuildFile();

            bf.Name = "Standert Build File";
            bf.Description = "This is the build file used to compile the templates";

            bf.Steps.Add(new BuildStep()
            {
                Description = "Asm - Compile all asm files",
                Name = "Assembly",
                OPT = "",
                Args = new List<string>() { "-f elf", "-o {build}{buildedname}", "{filepath}" },
                Exe = "{nasm}",
                FileType = ".asm",
                Path = ".",
                OutPutRegex = "Compiled {name}:"
            });
            bf.Steps.Add(new BuildStep() {
                Description = "Gcc - Compile all C files" ,
                Name = "GCC", OPT = "-w -m32 -Wall -O -fstrength-reduce  -finline-functions -fomit-frame-pointer -nostdinc -fno-builtin -I {include} -c -fno-strict-aliasing -fno-common -fno-stack-protector",
                Args = new List<string>() {"{opt}", "-o {build}{buildedname}", "{filepath}" } ,
                Exe = "{gcc}" ,
                FileType = ".c" ,
                Path = ".",
                OutPutRegex = "Compiled {name}:"
            });
            bf.Steps.Add(new BuildStep()
            {
                Description = "G++ - Compile all C++ files",
                Name = "G++",
                OPT = "-ffreestanding -O2 -Wall -Wextra -fno-exceptions -fno-rtti -I {include}",
                Args = new List<string>() { "{opt}", "-o {build}{buildedname}", "{filepath}" },
                Exe = "{g++}",
                FileType = ".cpp|.c\\+\\+",
                Path = ".",
                OutPutRegex = "Compiled {name}:"
            });
            bf.Steps.Add(new BuildStep()
            {
                Description = "Freebasic - Compile all bas files",
                Name = "FreeBasic",
                OPT = "",
                Args = new List<string>() { "-c {filepath}", "-o {build}{buildedname}" },
                Exe = "{fbc}",
                FileType = ".bas",
                Path = ".",
                OutPutRegex = "Compiled {name}:"
            });
            bf.Steps.Add(new BuildStep()
            {
                Description = "Linker - Link all files",
                Name = "Linker",
                OnceOfExecute = true,
                OPT = "",
                Args = new List<string>() { "-melf_i386", "-T {dls}", "{build}*.o" },
                Exe = "{ld}",
                FileType = ".o",
                Path = ".",
                OutPutRegex = "Linker every thing:"
            });
            bf.Steps.Add(new BuildStep()
            {
                Description = "Build Image File - Builds Image File",
                Name = "BuildImageFile",
                OnceOfExecute = true,
                OPT = "",
                Args = new List<string>() { "-i Factory\\CD" , "-o {img}" },
                Exe = "{git}",
                FileType = ".*+",
                Path = ".",
                OutPutRegex = "Builded boot image:"
            });
            bf.Steps.Add(new BuildStep()
            {
                Description = "Qemu - Start the emulator",
                Name = "Qemu",
                OnceOfExecute = true,
                Waitfor = false,
                OPT = "",
                Args = new List<string>() { "-L ." , "-fda {img}", "-serial tcp:127.0.0.1:8080,server,nowait" },
                Exe = "{qemu}",
                FileType = ".*+",
                Path = ".",
                OutPutRegex = "Starteded Qemu"
            });
            Global.CurrentBuildFile = bf;
            Global.Save();
            this.Close();
        }