Skip to content

Commit

Permalink
Enhance platform requirements mechanism
Browse files Browse the repository at this point in the history
- the new feature utilize regex to specify platform

fixes adoptium#166

Signed-off-by: renfeiw <[email protected]>
  • Loading branch information
renfeiw committed Apr 12, 2021
1 parent 22b282d commit 3b367c3
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 @@ -79,6 +79,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 @@ -89,12 +94,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 @@ -214,6 +219,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 @@ -262,7 +268,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 @@ -284,6 +290,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 3b367c3

Please sign in to comment.