Skip to content

Commit

Permalink
Change CommandLineIT to get commands from docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rebecca Tauber committed Feb 5, 2018
1 parent b4d3165 commit cfb6226
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ bin/original-robot.jar
bin/owltools2.jar
bin/robot.jar
docs/_site/
examples/catalog-v001.xml
examples/out.owl
examples/results/
docs/examples/catalog-v001.xml
docs/examples/out.owl
docs/examples/results/
junk/
target/
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@
public class CommandLineIT {

/** Path to the executable script. */
private String execPath = "../bin/robot";
private String execPath = "../../bin/robot";

/** Path to the examples/ directory. */
private String examplesPath = "../examples/";
/** Path to the docs. */
private String docsPath = "../docs/";

/** Path to the examples README file. */
private String readmePath = examplesPath + "README.md";
/** Path to the examples/ directory. */
private String examplesPath = docsPath + "examples/";

/** Path to the examples/results/ directory. */
private String resultsPath = examplesPath + "results/";

/** Path to the command output log. */
private String outputPath = "target/integration-tests.txt";

// TODO: Change to single examples folder in docs dir
// and use the different MD files in docs dir

/**
* Trim whitespace and trailing backslash from the given string.
*
Expand All @@ -46,8 +49,8 @@ private String trim(String line) {
* @return a list of example commands
* @throws IOException if the README cannot be read
*/
private List<String> extractCommands() throws IOException {
String content = FileUtils.readFileToString(new File(readmePath));
private List<String> extractCommands(File docFile) throws IOException {
String content = FileUtils.readFileToString(docFile);
List<String> lines = Arrays.asList(content.replaceAll("\\r", "").split("\\n"));
List<String> commands = new ArrayList<String>();

Expand Down Expand Up @@ -178,14 +181,22 @@ private void compareResults() throws Exception {
}

/**
* Test all commands in the examples/README.md file.
* Test all commands in the docs/ folder.
*
* @throws Exception on any problem
*/
@Test
public void testExecute() throws Exception {
cleanResults();
List<String> commands = extractCommands();
File docsFolder = new File(docsPath);
File[] docs = docsFolder.listFiles();
// Get commands from each doc (that ends with .md and is not the index)
List<String> commands = new ArrayList<>();
for (File d : docs) {
if (d.getName().endsWith("md") && !d.getName().equals("index.md")) {
commands.addAll(extractCommands(d));
}
}
for (String command : commands) {
runCommand(command);
}
Expand Down

0 comments on commit cfb6226

Please sign in to comment.