Skip to content

Commit

Permalink
Add TestRunner free args (#423)
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Davis <[email protected]>
  • Loading branch information
dr-jts authored Apr 25, 2019
1 parent a429c43 commit 37d46b8
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 27 deletions.
22 changes: 12 additions & 10 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ The JTS build chain uses Maven. Build commands are executed at the project root
* Build JTS, with tests:

mvn clean install

* Build JTS, no tests:

mvn clean install -DskipTests

* Build `jts-io-ora`:

mvn install -Poracle

* Build `jts-io-sde`:

mvn install -Parcsde

* Build everything:

mvn install -Pall
Expand Down Expand Up @@ -47,7 +47,7 @@ Field | Value
Type | Java Application
Project | `jts-tests`
Main class | `org.locationtech.jtstest.testrunner.JTSTestRunnerCmd`
Program arguments | `-files validate general`
Program arguments | `validate general`
Working directory | `${workspace_loc:jts-tests/src/test/resources/testxml}`

* **JTS TestBuilder** - for viewing and processing geometry with JTS
Expand All @@ -59,19 +59,19 @@ Project | `jts-app`
Main class | `org.locationtech.jtstest.testbuilder.JTSTestBuilder`
Program arguments (optional) | `-geomfunc <classname> ...`
VM args | `-Xmx1000M`
VM args (optional, for Mac) | `-Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel`
VM args (optional, for Mac) | `-Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel`
Working directory | Default

## Testing

JTS aims for 100% code coverage for unit tests.
JTS aims for 100% code coverage for unit tests.

There are two kinds of unit tests:

### JUnit tests

Used for verifying API code, internal data structures, and ancillary algorithms.
These tests are written in Java.
These tests are written in Java.
This allows testing all parts of the codebase,
and can provide richer error detection and reporting.
However, the tests are not as readable or portable
Expand All @@ -83,15 +83,17 @@ as the XML tests.

### XML Tests

JTS provides a code-independent, declarative XML-based format for expressing geometric functional tests.
JTS provides a code-independent, declarative XML-based format for expressing geometric functional tests.
This format has the following advantages:

* allows encoding large geometries
* provides geometric test cases in a reusable way
* easily consumed by external tools such as the JTS TestBuilder or other geometry libraries (e.g. GEOS)
* easily consumed by tools such as the JTS TestBuilder or by other geometry libraries (e.g. GEOS)
* allows geometric tests to be used with other operation implementations, for testing or comparison purposes

This format should be used for tests which involve large geometries, or which
This format should be used for tests which involve large geometries, or which
express fundamental geometric semantics of the JTS library.

The XML test format can be executed using the JTS TestRunner, or imported into the JTS TestBuilder.


8 changes: 7 additions & 1 deletion doc/JTS_Version_History.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Distributions for older JTS versions can be obtained at the

* Change `Polygon` `getExteriorRing` and `getInteriorRingN` accessors to return `LinearRing`. *This is a binary incompatible change to the method signature. Recompilation is necessary. No source code changes are required.*


### Functionality Improvements

* Added `IndexedFacetDistance.isWithinDistance`
Expand All @@ -37,6 +36,13 @@ Distributions for older JTS versions can be obtained at the
* Fix bug in `Quadtree.ensureExtent` (#416)
* Fix bugs in `LinearLocation` endpoint handling (#421)

## JTS TestRunner

### Functionality Improvements

* Allow test files/dirs to be specified as free args


<!-- ================================================================ -->

# Version 1.16.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,15 @@ private static TestRunnerOptions readOptions(String[] args) throws ParseExceptio

private static List<String> extractTestFilenames(CommandLine commandLine) throws FileNotFoundException, IOException {
List<String> testFiles = new ArrayList<String>();

if (commandLine.hasOption(OptionSpec.OPTION_FREE_ARGS)) {
testFiles.addAll(FilesUtil.expand(cmdOptionArgList(commandLine, OptionSpec.OPTION_FREE_ARGS)));
}

if (commandLine.hasOption(OPT_FILES)) {
testFiles.addAll(FilesUtil.expand(cmdOptionArgList(commandLine, OPT_FILES)));
}

if (commandLine.hasOption(OPT_PROPERTIES)) {
Properties properties = new Properties();
File file = new File(commandLine.getOption(OPT_PROPERTIES).getArg(0));
Expand All @@ -196,6 +202,9 @@ private static CommandLine createCommandLine() throws ParseException {
CommandLine commandLine = new CommandLine('-');
OptionSpec os;

os = new OptionSpec(OptionSpec.OPTION_FREE_ARGS, OptionSpec.NARGS_ONE_OR_MORE);
commandLine.addOptionSpec(os);

os = new OptionSpec(OPT_FILES, OptionSpec.NARGS_ONE_OR_MORE);
commandLine.addOptionSpec(os);

Expand All @@ -211,23 +220,28 @@ private static CommandLine createCommandLine() throws ParseException {
return commandLine;
}

static final String[] help = new String[] {
"",
"Usage: java org.locationtech.jtstest.testrunner.JTSTestRunnerCmd",
" [ -geomfunc <classname>]",
" [ -geomop <GeometryOperation classname>]",
" [ -testIndex <number>]",
" [ -verbose]",
" [ -properties <file.properties>]",
" [ -files <.xml file or dir> ...]",
" [ <.xml file or dir> ... ]",
" -files run a list of .xml files or directories containing .xml files",
" -properties load .xml filenames from a .properties file",
" -geomfunc specifies the class providing the geometry operations",
" -geomop specifies the class providing the geometry operations",
" -testIndex specfies the index of a single test to run",
" -verbose display the results of successful tests"
};

private static void printHelp() {
System.out.println("");
System.out.println("Usage: java com.vividsolutions.jtstest.testrunner.TopologyTestApp ");
System.out.println(" [-files <.xml files>] [-gui] ");
System.out.println(" [-geomfunc <classname>]");
System.out.println(" [-geomop <GeometryOperation classname>]");
System.out.println(" [-testIndex <number>]");
System.out.println(" [-verbose]");
System.out.println(" [-properties <file.properties>]");
System.out.println("");
System.out.println(" -files run a list of .xml files or directories");
System.out.println(" containing .xml files");
System.out.println(" -properties load .xml filenames from a .properties file");
System.out.println(" -geomfunc specifies the class providing the geometry operations");
System.out.println(" -geomop specifies the class providing the geometry operations");
System.out.println(" -testIndex specfies the index of a single test to run");
System.out.println(" -verbose display the results of successful tests");
for (String s : help) {
System.out.println(s);
}
}

public static List<String> cmdOptionArgList(CommandLine commandLine, String optionName) {
Expand Down

0 comments on commit 37d46b8

Please sign in to comment.