Skip to content

Commit

Permalink
Merge pull request #178 from renfeiw/plat
Browse files Browse the repository at this point in the history
Enhance platform requirements mechanism
  • Loading branch information
Shelley Lambert authored Apr 27, 2021
2 parents f4ef295 + c60dc1c commit 81e9cbe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/org/testKitGen/TestInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
public class TestInfo {
private String testCaseName;
private String command;
private String platform;
private String platformRequirements;
private List<Variation> vars;
private Map<String, String> capabilities;
Expand All @@ -37,6 +38,7 @@ public class TestInfo {
public TestInfo(Arguments arg) {
this.testCaseName = null;
this.command = null;
this.platform = null;
this.platformRequirements = null;
this.vars = new ArrayList<Variation>();
this.aotOptions = "";
Expand Down Expand Up @@ -72,6 +74,14 @@ public void setCommand(String command) {
this.command = command;
}

public String getPlatform() {
return this.platform;
}

public void setPlatform(String platform) {
this.platform = platform;
}

public String getPlatformRequirements() {
return this.platformRequirements;
}
Expand Down
14 changes: 11 additions & 3 deletions src/org/testKitGen/TestInfoParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public TestInfo parse() {
}
if (!isValidAot) return null;

NodeList platNodes = testEle.getElementsByTagName("platform");
if (platNodes.getLength() > 0) {
ti.setPlatform(platNodes.item(0).getTextContent().trim());
}

NodeList preqNodes = testEle.getElementsByTagName("platformRequirements");
if (preqNodes.getLength() > 0) {
ti.setPlatformRequirements(preqNodes.item(0).getTextContent().trim());
Expand All @@ -85,12 +90,12 @@ public TestInfo parse() {
List<Variation> listOfVars = new ArrayList<Variation>();
for (int i = 0; i < variations.size(); i++) {
String subTestName = ti.getTestCaseName() + "_" + i;
Variation var = parseVariation(subTestName, variations.get(i), ti.getPlatformRequirements());
Variation var = parseVariation(subTestName, variations.get(i), ti.getPlatform(), ti.getPlatformRequirements());
listOfVars.add(var);
}
if (variations.size() == 0) {
String subTestName = ti.getTestCaseName() + "_0";
Variation var = parseVariation(subTestName, "NoOptions", ti.getPlatformRequirements());
Variation var = parseVariation(subTestName, "NoOptions", ti.getPlatform(), ti.getPlatformRequirements());
listOfVars.add(var);
}
ti.setVars(listOfVars);
Expand Down Expand Up @@ -206,6 +211,7 @@ private void parseDisableInfo(TestInfo ti) {
}

private boolean checkPlat(String plat) {
if (plat == null) return true;
Pattern pattern = Pattern.compile(plat);
Matcher matcher = pattern.matcher(arg.getPlat());
return matcher.matches();
Expand Down Expand Up @@ -254,7 +260,7 @@ private String joinStrList(List<String> list) {
return sb.toString();
}

private Variation parseVariation(String subTestName, String variation, String platformRequirements) {
private Variation parseVariation(String subTestName, String variation, String platform, String platformRequirements) {
Variation var = new Variation(subTestName, variation);

String jvmOptions = " " + variation + " ";
Expand All @@ -276,6 +282,8 @@ private Variation parseVariation(String subTestName, String variation, String pl
jvmOptions = jvmOptions.replace("Mode" + mode, clArgs);
}
jvmOptions = jvmOptions.trim();
isValid &= checkPlat(platform);
//TODO: remove platformRequirements
isValid &= checkPlatformReq(platformRequirements);

var.setJvmOptions(jvmOptions);
Expand Down

0 comments on commit 81e9cbe

Please sign in to comment.