Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance platform requirements mechanism #178

Merged
merged 1 commit into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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