gen all targets now pays attention to -o option. Simplified target spec. `Regen tests with java org.antlr.v4.testgen.TestGenerator -root /Users/parrt/antlr/code/antlr4` from command-line.

This commit is contained in:
parrt 2015-06-25 15:19:52 -07:00
parent 7b5ac5a751
commit 8e361ef401
3 changed files with 18 additions and 46 deletions

View File

@ -14,13 +14,11 @@
<sourceFolder url="file://$MODULE_DIR$/runtime-testsuite/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/runtime-testsuite/test" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/runtime-testsuite/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/tool/resources" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/tool/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tool/target/generated-sources/antlr3" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tool-testsuite/test" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/runtime" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/runtime/Python2/src" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/runtime/Python3/src" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/tool/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/runtime-testsuite/test/org/antlr/v4/test/runtime/javascript/chrome" />
<excludeFolder url="file://$MODULE_DIR$/runtime-testsuite/test/org/antlr/v4/test/runtime/javascript/explorer" />
<excludeFolder url="file://$MODULE_DIR$/runtime-testsuite/test/org/antlr/v4/test/runtime/javascript/firefox" />

View File

@ -1,36 +0,0 @@
package org.antlr.v4.testgen;
import java.util.Arrays;
import java.util.List;
public class TargetConfiguration {
/** WARNING: this must be kept in sync with the bild.py directories. */
public static List<TargetConfiguration> ALL = Arrays.asList(
new TargetConfiguration("tool/test/",
"tool/test/org/antlr/v4/test/runtime/java/Java.test.stg"),
new TargetConfiguration("../antlr4-csharp/tool/test/",
"../antlr4-csharp/tool/test/org/antlr/v4/test/runtime/csharp/CSharp.test.stg"),
new TargetConfiguration("../antlr4-python2/tool/test/",
"../antlr4-python2/tool/test/org/antlr/v4/test/runtime/python2/Python2.test.stg"),
new TargetConfiguration("../antlr4-python3/tool/test/",
"../antlr4-python3/tool/test/org/antlr/v4/test/runtime/python3/Python3.test.stg"),
new TargetConfiguration("../antlr4-javascript/tool/test/",
"../antlr4-javascript/tool/test/org/antlr/v4/test/runtime/javascript/node/Node.test.stg"),
new TargetConfiguration("../antlr4-javascript/tool/test/",
"../antlr4-javascript/tool/test/org/antlr/v4/test/runtime/javascript/chrome/Chrome.test.stg"),
new TargetConfiguration("../antlr4-javascript/tool/test/",
"../antlr4-javascript/tool/test/org/antlr/v4/test/runtime/javascript/safari/Safari.test.stg"),
new TargetConfiguration("../antlr4-javascript/tool/test/",
"../antlr4-javascript/tool/test/org/antlr/v4/test/runtime/javascript/firefox/Firefox.test.stg"),
new TargetConfiguration("../antlr4-javascript/tool/test/",
"../antlr4-javascript/tool/test/org/antlr/v4/test/runtime/javascript/explorer/Explorer.test.stg")
);
String outDir;
String templates;
public TargetConfiguration(String outDir, String templates) {
this.outDir = outDir;
this.templates = templates;
}
}

View File

@ -45,7 +45,7 @@ import java.util.List;
import java.util.Map;
public class TestGenerator {
public static final String antlrRoot = "."; // assume antlr4 root dir is current working dir
public final static String[] targets = {"CSharp", "Java", "Python2", "Python3", "JavaScript"};
// This project uses UTF-8, but the plugin might be used in another project
// which is not. Always load templates with UTF-8, but write using the
@ -65,6 +65,10 @@ public class TestGenerator {
* Example:
*
* $ java org.antlr.v4.testgen.TestGenerator -o /tmp -templates /Users/parrt/antlr/code/antlr4/tool/test/org/antlr/v4/test/runtime/java/Java.test.stg
*
* Most commonly:
*
* $ java org.antlr.v4.testgen.TestGenerator -root /Users/parrt/antlr/code/antlr4
*/
public static void main(String[] args) {
String rootDir = null;
@ -93,7 +97,7 @@ public class TestGenerator {
i++;
}
if ( rootDir!=null) {
genAllTargets(rootDir, viz);
genAllTargets(outDir, rootDir, viz);
System.exit(0);
}
@ -105,13 +109,19 @@ public class TestGenerator {
genTarget(outDir, targetSpecificTemplateFile, viz);
}
public static void genAllTargets(final String rootDir, boolean viz) {
for(TargetConfiguration config : TargetConfiguration.ALL) {
String outDir = rootDir + config.outDir;
String templates = rootDir + config.templates;
public static void genAllTargets(String outDirRoot, final String rootDir, boolean viz) {
for (String t : targets) {
String templatesPackage = rootDir + "/runtime-testsuite/resources/org/antlr/v4/test/runtime/" + t.toLowerCase();
String templates = templatesPackage + "/" + t + ".test.stg";
if ( t.equals("JavaScript") ) {
templates = templatesPackage+"/node/Node.test.stg";
}
String outDir = rootDir + "/runtime-testsuite/test";
if ( outDirRoot!=null ) {
outDir = outDirRoot;
}
genTarget(outDir, templates, viz);
}
}
public static void genTarget(final String outDir, String targetSpecificTemplateFile, boolean viz) {