예제 #1
0
        public Harness Execute(IEnumerable<Suite> suites)
        {
            if( _currentSuites == null )
                _currentSuites = suites;

            var harness = new Harness();
            var cases = new List<Case>();

            var timeBefore = DateTime.Now;
            Console.WriteLine("<--- Run Suite(s) --->");
            foreach (var suite in suites)
            {
                foreach (var description in suite.Descriptions)
                    cases.AddRange(description.Cases);

                harness.Cases = cases;

            }
            var page = _pageGenerator.GenerateFrom(harness);

            _scriptEngine.Execute(page);

            var delta = DateTime.Now.Subtract(timeBefore);

            Console.WriteLine("<--- Took {0} seconds --->\n", delta.TotalSeconds);
            return harness;
        }
        public void Apply(IFile file)
        {
			_appliedConfigFile = file;
			var fileContent = file.ReadAllText();

            YamlMapping root = null;
            var globalDependencies = new List<File>();

			var nodes = _yamlParser.Parse (fileContent);
            if (nodes.Count() > 0)
            {
                root = nodes.First() as YamlMapping;
                

                if (root != null && root.ContainsKey("Dependencies"))
                {
                    var globalDependenciesConfig = root["Dependencies"] as YamlSequence;
                    globalDependencies = globalDependenciesConfig
                                        .Select((node) => (File)((YamlScalar)node).Value)
                                        .ToList();

                }
            }
			
			if( root != null && root.ContainsKey("Harnesses") ) 
			{
				var harnesses = root["Harnesses"] as YamlSequence;
				if( harnesses != null )
				{
					foreach( YamlMapping harnessConfig in harnesses ) 
					{
						if( harnessConfig.ContainsKey("Harness") )
						{
							var values = harnessConfig["Harness"] as YamlMapping;
							
							var frameworkName = ((YamlScalar)values["Framework"]).Value;
							var framework = _frameworkManager.GetByName(frameworkName);
							
							var harness = new Harness(framework);
							harness.Name = ((YamlScalar)values["Name"]).Value;
							harness.SystemsSearchPath = ((YamlScalar)values["SystemsSearchPath"]).Value;
							harness.DescriptionsSearchPath = ((YamlScalar)values["DescriptionsSearchPath"]).Value;
                            if (values.ContainsKey("Dependencies"))
                            {
                                var harnessDependencies =
                                    ((YamlSequence) values["Dependencies"])
                                    .Select((node) => (File)((YamlScalar) node).Value)
                                    .ToList();

                                globalDependencies.AddRange(harnessDependencies);

                                globalDependencies.ForEach(harness.AddDependency);
                            }

						    _harnessManager.Add (harness);
						}
					}
				}
			}
        }
예제 #3
0
        public void Add(Harness harness)
        {
            // Subscribe to changes from the filesystem
            // When a change occurs - walk through existing suites in the harness and see if there was a change to one of them - if so, rerun it

            // If a change is to a non existing suite, filter through the configuration :
            //    - Does it match the regex of the SystemsSearchPath and does not match the DescriptionsSearchPath - add it as a system
            //    - Does it match the regex of the DescriptionSearchPath and not the SystemsSearchPath - look for the system in existing list, if exist add it, if not - try to find it in the filesystem based on configuration - add it if so

            // If the change is a delete - walk through existing suites in the harness and see some one is affected and just update the suite or remove the suite if the system was removed

            var allFiles = _fileSystem.GetAllFiles("*.js");
        }
예제 #4
0
        public Page GenerateFrom(Harness harness)
        {
            var page = new Page();

            var harnessView = (HarnessView)_engine.CreateInstance(_descriptor);
            harnessView.Harness = harness;
            harnessView.FrameworkScript = harness.Framework.ScriptName;
            harnessView.FrameworkExecutionScript = harness.Framework.ExecuteScriptName;
            harnessView.FrameworkReportingScript = harness.Framework.ReportScriptName;

            page.RootPath = Path.GetTempPath() + @"Forseti/";
            page.Filename = string.Format("{0}runner.html", page.RootPath);

            if (!Directory.Exists(page.RootPath))
                Directory.CreateDirectory(page.RootPath);

            if (harness.HasDependencies())
            {
                var actualDependencies = new List<string>();
                foreach (var dependency in harness.Dependencies)
                {
                    CopyScript(page.RootPath, dependency.RelativePath);
                    actualDependencies.Add(dependency.RelativePath);
                }
                harnessView.Dependencies = actualDependencies.ToArray();
            } else {
				harnessView.Dependencies = new string[0];
			}
							

            var writer = new StringWriter();
            harnessView.RenderView(writer);

            var result = writer.ToString();

            File.WriteAllText(page.RootPath + harness.Framework.ScriptName, harness.Framework.Script);
            File.WriteAllText(page.RootPath + harness.Framework.ExecuteScriptName, harness.Framework.ExecuteScript);
            File.WriteAllText(page.RootPath + harness.Framework.ReportScriptName, harness.Framework.ReportScript);

            foreach (var scriptFile in harnessView.SystemScripts)
                CopyScript(page.RootPath, scriptFile);
			
			
			
            foreach (var scriptFile in harnessView.CaseScripts)
                CopyScript(page.RootPath, scriptFile);

            File.WriteAllText(page.Filename, result);

            return page;
        }
예제 #5
0
        public void Apply(IFile file)
        {
            _appliedConfigFile = file;
            var fileContent = file.ReadAllText();
            var yamlDocument = _yamlParser.Parse (fileContent);
            foreach( var node in yamlDocument.First().AllNodes )
            {
                if( node.Tag == "Harnesses" )
                {
                    foreach( var childNode in node.AllNodes )
                    {
                        if( childNode.Tag == "Harness")
                        {
                            foreach( var parameter in childNode.AllNodes )
                            {
                                switch( parameter.Tag )
                                {
                                case "Name":
                                    {

                                        var i=0;
                                        i++;

                                    }break;
                                }

                            }

                        }
                    }
                }

            }

            var harness = new Harness();
            _harnessManager.Add (harness);
        }
예제 #6
0
        IEnumerable<Case> PrepareCasesForSuite(Harness harness, IEnumerable<Suite> suites)
        {
            var cases = new List<Case>();
            foreach (var suite in suites)
            {
                var descriptionsToRemove = new List<Description>();
                foreach (var description in suite.Descriptions)
                {
                    if (System.IO.File.Exists(description.File.FullPath))
                    {
                        cases.AddRange(description.Cases);
                    }
                    else
                    {
                        descriptionsToRemove.Add(description);
                    }
                }

                suite.RemoveDescriptions(descriptionsToRemove);
                harness.Cases = cases;
            }
            return cases;
        }
예제 #7
0
        public HarnessResult Execute(Harness harness, IEnumerable<Suite> suites)
        {
			Console.WriteLine("<--- Run Suite(s) for {0} on {1} framework --->", harness.Name, harness.Framework.Name);

            var result = new HarnessResult(harness);
            result.StartTime = DateTime.Now;
			if( suites.Count() == 0 ) 
			{
				Console.WriteLine ("No suites");
                _harnessChangeManager.NotifyChange(result, HarnessChangeType.RunComplete);
				return null;
			}
            suites.ForEach(s => 
                            {
                                s = PrepareSuiteForReporting(s);
                                result.AddAffectedSuite(s); 
                            });
			
            
            var timeBefore = DateTime.Now;
            var cases = PrepareCasesForSuite(harness, suites);
			
			if( harness.Cases.Count () == 0 )
			{
				Console.WriteLine("no cases");
			} else 
			{
	            var page = _pageGenerator.GenerateFrom(harness);

                // Todo: this is no good - just a temporary testing thing....
                HarnessCaseReporter.HarnessResult = result;
	            _scriptEngine.Execute(page);
			}

            result.EndTime = DateTime.Now;
            var delta = DateTime.Now.Subtract(timeBefore);

            
            _harnessChangeManager.NotifyChange(result, HarnessChangeType.RunComplete);

            Console.WriteLine("<--- Took {0} seconds --->\r\n", delta.TotalSeconds);

            return result;
        }
예제 #8
0
        public void Execute(Harness harness, IEnumerable<Suite> suites)
        {
			Console.WriteLine("<--- Run Suite(s) for {0} on {1} framework --->", harness.Name, harness.Framework.Name);
			
			if( suites.Count() == 0 ) 
			{
				Console.WriteLine ("No suites");
				return;
			}
			
            var cases = new List<Case>();
            var timeBefore = DateTime.Now;
            
            foreach (var suite in suites)
            {
                foreach (var description in suite.Descriptions)
                    cases.AddRange(description.Cases);

                harness.Cases = cases;
            }
			
			if( harness.Cases.Count () == 0 )
			{
				Console.WriteLine("no cases");
			} else 
			{
	            var page = _pageGenerator.GenerateFrom(harness);
	            _scriptEngine.Execute(page);
			}

            var delta = DateTime.Now.Subtract(timeBefore);

            Console.WriteLine("<--- Took {0} seconds --->\n", delta.TotalSeconds);
        }
        public static void ClearHarnessResults()
        {
            harness_result_used_to_render_page = null;

        }
예제 #10
0
 public HarnessResult(Harness harness)
 {
     Harness = harness;
     StartTime = DateTime.Now;
     EndTime = DateTime.Now;
 }
예제 #11
0
        public Page GenerateFrom(Harness harness)
        {
            var page = new Page();

            var harnessView = (HarnessView)_engine.CreateInstance(_descriptor);
            harnessView.Harness = harness;
            harnessView.RunnerScripts = new[] {"jquery.min.js","forseti.bootstrapper.js", "r.js", "forseti.js"} ;
            harnessView.FrameworkScript = harness.Framework.ScriptName;
            harnessView.FrameworkExecutionScript = harness.Framework.ExecuteScriptName;
            harnessView.FrameworkReportingScript = harness.Framework.ReportScriptName;

            page.RootPath = Path.GetTempPath() + @"Forseti/";
            page.Filename = string.Format("{0}runner.html", page.RootPath);

            if (!Directory.Exists(page.RootPath))
                Directory.CreateDirectory(page.RootPath);

            if (harness.HasDependencies())
            {
                var actualDependencies = new List<string>();
                foreach (var dependency in harness.Dependencies)
                {
                    CopyScript(page, dependency.RelativePath);
                    actualDependencies.Add(dependency.RelativePath);
                }
                harnessView.Dependencies = actualDependencies.ToArray();
            } else {
				harnessView.Dependencies = new string[0];
			}
							

            var writer = new StringWriter();

            foreach (var scriptFile in harnessView.SystemScripts)
                CopyScriptAndPossibleAdditionalReferences(harness, page, scriptFile);

            var actualCaseScripts = new List<CaseScriptDescriptor>();
            foreach (var caseDescriptor in harnessView.CaseScripts)
            {
                var additionalRefereces = CopyScriptAndPossibleAdditionalReferences(harness, page, caseDescriptor.Case);
                actualCaseScripts.Add(new CaseScriptDescriptor { CaseDependencies = additionalRefereces, Case = caseDescriptor.Case });
            }
            harnessView.CaseScripts = actualCaseScripts.ToArray();


            harnessView.RenderView(writer);

            var result = writer.ToString();

            File.WriteAllText(page.RootPath + "jquery.min.js", _jqueryJs);
            File.WriteAllText(page.RootPath + "forseti.bootstrapper.js", _forsetiBootstrapperJs);
            File.WriteAllText(page.RootPath + "r.js", _requireJs);
            File.WriteAllText(page.RootPath + "forseti.js", _forsetiJs);
            File.WriteAllText(page.RootPath + harness.Framework.ScriptName, harness.Framework.Script);
            File.WriteAllText(page.RootPath + harness.Framework.ExecuteScriptName, harness.Framework.ExecuteScript);
            File.WriteAllText(page.RootPath + harness.Framework.ReportScriptName, harness.Framework.ReportScript);

			
            
            File.WriteAllText(page.Filename, result);

            return page;
        }
예제 #12
0
        IEnumerable<string> CopyScriptAndPossibleAdditionalReferences(Harness harness, Page page, Files.File descriptionFile)
        {
            var currentDirectory = Directory.GetCurrentDirectory();
            var additionalReferences = new List<string>();
            if (harness.IncludeSubFoldersFromDescriptions)
            {
                var descriptionSourcePath = Path.GetDirectoryName(Path.Combine(currentDirectory, descriptionFile.Folder));
                var descriptionRelativePath = descriptionFile.Folder;
                var folders = Directory.GetDirectories(Path.GetDirectoryName(descriptionFile.FullPath));
                foreach (var folder in folders)
                {
                    var sourcePath = Path.Combine(currentDirectory, folder);
                    var targetPath = Path.Combine(page.RootPath, folder);

                    CopyFilesRecursively(page, descriptionRelativePath, descriptionFile, new DirectoryInfo(targetPath), new DirectoryInfo(sourcePath), additionalReferences);
                }
            }
            CopyScript(page, descriptionFile);

            return additionalReferences;
        }