Skip to content

Commit

Permalink
fix - Slice the build target list to 1 when running gradle tests (#1518)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdneo authored Jul 11, 2024
1 parent 19af24a commit d904c27
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,17 @@ public Object executeCommand(String commandId, List<Object> arguments, IProgress
List<BuildTargetIdentifier> btIds = targets.stream().filter(bt -> {
return bt.getTags().contains(BuildTargetTag.INTEGRATION_TEST) || bt.getTags().contains(BuildTargetTag.TEST);
}).map(BuildTarget::getId).collect(Collectors.toList());
if (btIds.isEmpty() || btIds.size() > 1) {
if (btIds.isEmpty()) {
throw new IllegalStateException("Invalid number of build targets: " + btIds.size());
}

if (btIds.size() > 1) {
// The build server only allows to accept one build target per test request. At client side,
// each test request is sent per project, so even multiple build targets are found, they
// belongs to the same project. Thus, we only use the first one here. Build server will use
// this single build target to locate the project to test.
btIds = btIds.subList(0, 1);
}
TestParams testParams = new TestParams(btIds);
testParams.setDataKind("scala-test-suites-selection");
testParams.setArguments(getArguments(arguments));
Expand All @@ -64,8 +72,8 @@ public Object executeCommand(String commandId, List<Object> arguments, IProgress
}
ScalaTestSuites scalaTestSuites = new ScalaTestSuites(
testSelections,
getJvmOptions(arguments), // jvmOptions
getEnvVarPairs(arguments) // envVariables
getJvmOptions(arguments),
getEnvVarPairs(arguments)
);
testParams.setData(scalaTestSuites);
buildServerConnection.buildTargetTest(testParams).join();
Expand Down

0 comments on commit d904c27

Please sign in to comment.