-
Notifications
You must be signed in to change notification settings - Fork 710
Add functionality to include pages based on tags defined for test page. #1368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| Test | ||
| --- | ||
| !define INCLUDE_TAG_LIBRARIES {true} | ||
|
|
||
| !contents |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| Suite: no | ||
| Test | ||
| --- | ||
| !contents |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| Suites: TagTwo, TagOne | ||
| Test | ||
| --- | ||
| !|script| | ||
| |one| | ||
| |two| | ||
| |check|echo|$ONE|1| | ||
| |check|echo|$TWO|2| |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| Test | ||
| --- | ||
| !|scenario|one| | ||
| |$ONE=|echo|1| |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| !|scenario|two| | ||
| |$TWO=|echo|2| |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,19 +2,12 @@ | |||||
|
|
||||||
| import fitnesse.testsystems.ClassPath; | ||||||
| import fitnesse.testsystems.TestPage; | ||||||
| import fitnesse.wiki.BaseWikitextPage; | ||||||
| import fitnesse.wiki.PageData; | ||||||
| import fitnesse.wiki.PathParser; | ||||||
| import fitnesse.wiki.SymbolicPage; | ||||||
| import fitnesse.wiki.WikiPage; | ||||||
| import fitnesse.wiki.WikiPagePath; | ||||||
| import fitnesse.wiki.*; | ||||||
| import fitnesse.wikitext.MarkUpSystem; | ||||||
| import fitnesse.wikitext.parser.Include; | ||||||
|
|
||||||
| import java.io.File; | ||||||
| import java.util.Collections; | ||||||
| import java.util.LinkedList; | ||||||
| import java.util.List; | ||||||
| import java.util.*; | ||||||
| import java.util.function.BiConsumer; | ||||||
|
|
||||||
| // TODO: need 2 implementations, one for wiki text pages (Fit, Slim) and one for non-wiki text pages. See PagesByTestSystem | ||||||
|
|
@@ -192,9 +185,15 @@ public boolean shouldIncludeScenarioLibraries() { | |||||
| return includeScenarios || (!notIncludeScenarios && isSlim); | ||||||
| } | ||||||
|
|
||||||
| public boolean shouldIncludeTagLibraries() { | ||||||
| String includeVar = sourcePage.getVariable("INCLUDE_TAG_LIBRARIES"); | ||||||
| return includeVar != null && "true".equalsIgnoreCase(includeVar); | ||||||
| } | ||||||
|
|
||||||
| public List<WikiPage> getScenarioLibraries() { | ||||||
| if (scenarioLibraries == null) { | ||||||
| scenarioLibraries = findScenarioLibraries(); | ||||||
| scenarioLibraries.addAll(findTagLibraries()); | ||||||
| } | ||||||
| return scenarioLibraries; | ||||||
| } | ||||||
|
|
@@ -226,11 +225,27 @@ private List<WikiPage> findScenarioLibraries() { | |||||
| if (shouldIncludeScenarioLibraries()) { | ||||||
| uncles = findUncles(SCENARIO_LIBRARY); | ||||||
| } else { | ||||||
| uncles = Collections.emptyList(); | ||||||
| uncles = new LinkedList<>(); | ||||||
| } | ||||||
| return uncles; | ||||||
| } | ||||||
|
|
||||||
| private List<WikiPage> findTagLibraries() { | ||||||
| List<WikiPage> pages = new LinkedList<>(); | ||||||
| WikiPageProperty suitesProperty = sourcePage.getData().getProperties().getProperty(WikiPageProperty.SUITES); | ||||||
| if (shouldIncludeTagLibraries() && suitesProperty != null){ | ||||||
| String[] tags1 = Arrays.stream(suitesProperty.getValue().split(",")).map(e -> e.trim()).filter(e -> checkIfTagIsNotReserved(e)).toArray(String[]::new); | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't this just be
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated in newest commit |
||||||
| for(int i=0;i<tags1.length;i++){ | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated in newest commit |
||||||
| pages.addAll(findUncles(tags1[i].trim())); | ||||||
| } | ||||||
| } | ||||||
| return pages; | ||||||
| } | ||||||
|
|
||||||
| private boolean checkIfTagIsNotReserved(String s){ | ||||||
| return !(s.trim().equals(SET_UP) || s.trim().equals(TEAR_DOWN) || s.trim().equals(SCENARIO_LIBRARY)); | ||||||
| } | ||||||
|
|
||||||
| protected List<WikiPage> findUncles(String uncleName) { | ||||||
| LinkedList<WikiPage> uncles = new LinkedList<>(); | ||||||
| sourcePage.getPageCrawler().traverseUncles(uncleName, uncles::addFirst); | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do explicit imports instead of
.*? (Also for test class)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in newest commit