Skip to content

Commit

Permalink
implemented comma separated part numbers for run-tests.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ibm5 committed Dec 6, 2023
1 parent cc772f9 commit de0b429
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
16 changes: 10 additions & 6 deletions framework/tst/dslabs/framework/testing/junit/DSLabsTestCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ public static void main(String[] args) throws Exception {
final Option lab =
Option.builder("l").longOpt("lab").argName("LAB").hasArg(true)
.numberOfArgs(1).desc("lab identifier").build();
final Option part = Option.builder("p").longOpt("part").required(false)
.argName("PART").hasArg(true).numberOfArgs(1)
.desc("part number").build();
final Option part =
Option.builder("p").longOpt("part").required(false)
.hasArg(true).numberOfArgs(1).argName("PART_NUMS")
.desc("comma-separated list of part numbers")
.build();
final Option testNum =
Option.builder("n").longOpt("test-num").required(false)
.hasArg(true).numberOfArgs(1).argName("TEST_NUMS")
Expand Down Expand Up @@ -186,20 +188,22 @@ public String describe() {

// Only run test classes for this part
if (line.hasOption(part)) {
final int partNum = Integer.parseInt(line.getOptionValue(part));
final Set<String> partNumbers =
Sets.newHashSet(line.getOptionValue(part).split(","));

request = request.filterWith(new Filter() {
@Override
public boolean shouldRun(Description description) {
if (!description.isSuite()) {
return true;
}
var p = description.getAnnotation(Part.class);
return p != null && p.value() == partNum;
return p != null && partNumbers.contains(String.valueOf(p.value()));
}

@Override
public String describe() {
return "part " + partNum;
return "parts " + partNumbers;
}
});
}
Expand Down
5 changes: 3 additions & 2 deletions handout-files/run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ def main():
group = run_modes.add_mutually_exclusive_group()

parser.add_argument('-l', '--lab', help="lab to run tests for")
parser.add_argument('-p', '--part', type=int,
help="part number for tests to run")

parser.add_argument('-p', '--part', type=str,
help="part numbers for tests to run")

parser.add_argument('-n', '--test-num',
help="specific, comma-separated test numbers to run "
Expand Down

0 comments on commit de0b429

Please sign in to comment.