/* Function: TestFolder * Tests all the input files contained in this folder. See <EngineInstanceManager.Start()> for how relative paths are handled. */ public void TestFolder(Path testDataFolder, Path projectConfigFolder = default(Path), bool autoGroup = false) { TestList allTests = new TestList(); engineInstanceManager = new EngineInstanceManager(); engineInstanceManager.Start(testDataFolder, projectConfigFolder, autoGroup: autoGroup); // Store this so we can still use it for error messages after the engine is disposed of. Path inputFolder = engineInstanceManager.InputFolder; try { // Build a test for each input file we find string[] files = System.IO.Directory.GetFiles(inputFolder); foreach (string file in files) { if (Test.IsInputFile(file)) { Test test = Test.FromInputFile(file); try { Language language = EngineInstance.Languages.FromFileExtension(test.InputFile.Extension); if (language == null) { throw new Exception("Extension " + test.InputFile.Extension + " did not resolve to a language."); } IList <Topic> topics; LinkSet classParentLinks; language.Parser.Parse(test.InputFile, -1, Engine.Delegates.NeverCancel, out topics, out classParentLinks); test.SetActualOutput(OutputOf(topics)); } catch (Exception e) { test.TestException = e; } test.Run(); allTests.Add(test); } } } finally { engineInstanceManager.Dispose(); engineInstanceManager = null; } if (allTests.Count == 0) { Assert.Fail("There were no tests found in " + inputFolder); } else if (allTests.Passed == false) { Assert.Fail(allTests.BuildFailureMessage()); } }
/* Function: TestFolder * * Tests all the input files contained in this folder. See <EngineInstanceManager.Start()> for how relative paths are handled. * * Unless you override <ExtractHTML()>, the output will be all the tags that match the passed tag name and, if specified, the * passed class name. */ public void TestFolder(Path testDataFolder, Path projectConfigFolder, string tagName, string className = null, bool reformatHTML = false, string outputTitle = null, string outputSubtitle = null) { TestList allTests = new TestList(); engineInstanceManager = new EngineInstanceManager(); engineInstanceManager.Start(testDataFolder, projectConfigFolder, true, outputTitle, outputSubtitle); // Store this so we can still use it for error messages after the engine is disposed of. Path inputFolder = engineInstanceManager.InputFolder; try { engineInstanceManager.Run(); // Build a test for each input file we find string[] files = System.IO.Directory.GetFiles(inputFolder); foreach (string file in files) { if (Test.IsInputFile(file)) { Test test = Test.FromInputFile(file); try { var fileInfo = EngineInstance.Files.FromPath(file); if (fileInfo == null) { throw new Exception("Could not get file info of " + file); } Engine.Output.Components.HTMLTopicPages.File fileTopicPage = new Engine.Output.Components.HTMLTopicPages.File(engineInstanceManager.HTMLBuilder, fileInfo.ID); Path htmlFile = fileTopicPage.OutputFile; string html = System.IO.File.ReadAllText(htmlFile); html = ExtractHTML(html, tagName, className); if (reformatHTML) { html = ReformatHTML(html); } test.SetActualOutput(html); } catch (Exception e) { test.TestException = e; } test.Run(); allTests.Add(test); } } } finally { engineInstanceManager.Dispose(); engineInstanceManager = null; } if (allTests.Count == 0) { Assert.Fail("There were no tests found in " + inputFolder); } else if (allTests.Passed == false) { Assert.Fail(allTests.BuildFailureMessage()); } }
/* Function: TestFolder * Tests all the input files contained in this folder. See <EngineInstanceManager.Start()> for how relative paths are handled. */ public void TestFolder(Path testDataFolder, Path projectConfigFolder = default(Path)) { TestList allTests = new TestList(); engineInstanceManager = new EngineInstanceManager(); engineInstanceManager.Start(testDataFolder, projectConfigFolder); // Store this so we can still use it for error messages after the engine is disposed of. Path inputFolder = engineInstanceManager.InputFolder; try { // Build a test for each input file we find string[] files = System.IO.Directory.GetFiles(inputFolder); foreach (string file in files) { if (Test.IsInputFile(file)) { Test test = Test.FromInputFile(file); try { Language language = EngineInstance.Languages.FromExtension(test.InputFile.Extension); if (language == null) { throw new Exception("Extension " + test.InputFile.Extension + " did not resolve to a language."); } string code = System.IO.File.ReadAllText(test.InputFile); Tokenizer tokenizedCode = new Tokenizer(code); List <Element> codeElements = language.GetCodeElements(tokenizedCode); if (codeElements == null) { throw new Exception("GetCodeElements() returned null."); } test.SetActualOutput(OutputOf(codeElements)); } catch (Exception e) { test.TestException = e; } test.Run(); allTests.Add(test); } } } finally { engineInstanceManager.Dispose(); engineInstanceManager = null; } if (allTests.Count == 0) { Assert.Fail("There were no tests found in " + inputFolder); } else if (allTests.Passed == false) { Assert.Fail(allTests.BuildFailureMessage()); } }