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

fix - Slice the build target list to 1 when running gradle tests #1518

Merged
merged 1 commit into from
Jul 11, 2024
Merged
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
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
Loading