Skip to content

Commit

Permalink
[feature] Rust support (#394)
Browse files Browse the repository at this point in the history
* Changed bsp4j dep to Rust integreted

* Replaced bsp4 dependency with our implementation (temp)

* Added mock implementation for Rust endpoints

* Updated to use new interface

* Updated to use even newer interface

* initial

* add

* add

* sending proper env

* sending proper env v2

* dupa

* now works

* Added hello-world to .bazelignore as bazel configuration in hello-world wasn't working with bazel-bsp querrign

* temporarty changes with buildifier

* Add aspect for fetching rust-specific data

* Borrow some ideas from `rust_analyzer.bzl` to extract more rust-specific info

* Fix protos, add comments

* Add field, simplify

* Add helpful comments.

* hardcoded rust-bazel-bsp-sample data

* Proto-related fix in serializing RustCrateInfo

* Collect Rust data from protos

* Moved creating RustWorkspaceResult to proper place

* Solved failing test compilation.
Added temp solution for temp solution for mock project

* fixed xewar->mikolaj

* Extract output directory of build script using `BuildInfo` provider

* Fix tudny mistakes

* Modify rust plugin to use module list

* added dep packges - to be consulted about their usage

* started to remove mocking. New BSP model. Package collection. Targets merging. etc.

* added more missing version (heuristic). Added comments

* fixed missing version

* added raw dependencies

* todo docs

* checking if dep has CrateInfo provider

* aspect: extract version from `ctx.rule.attr`

* Removed cycles. Dependent targets can be in the same package.

* Treat all Rust targets as rootTargets

`BazelProjectMapper` now treats all Rust targets as rootTargets,
regardless of the workspace/external origin.

* Pass external Rust targets in `Project` class

Rust targets are now passed in `rustExternalModules` field in `Project`
data class. This reverts previous commit.

* BazelPathsResolver: Support for external targets in `labelToDirectoryUri`

* cometics

* solved missing package path

* added version in env, DEP proper name and package root hack

* Pass full URI for `crate_root`

* added all depth dependency packaging for Rust

* sending all targets related to package (updated BSP version), refactored externalRustModules

* RustPackage id should not be a BuildTargetIdentifier

* proc_macros are now discovered and treated like normal library

* sending proper rust target kind

* added proc macros artifacts

* Added Rust toolchain

* Rust: added stdlib path and proc-macro-srv path to metadata scraped from bazel

* Rust: added cargo binary path to target info

* Added stdlib info to RustWorkspace result

* Sending stdlib info in rust workspace result

* sending toolchain as seperate endpoint

* fixed toolchain paths'

* fixed proc macro

* removed DepInfo

* Added projectview.bazelproject to .gitignore

* added stdlib version to Rust info

* PR feedback: it'd be nice to write it using map and filter

* PR feedback: both methods are kinda similar; let's keep imports without wildcard

* PR feedback: block to expr

* PR feedback: $ in strings

* PR feedback: new line

* PR feedback: no wildcard

* PR feedback: new line

* PR feedback: a lot of nested things - it'd be nice to extract part of it to separate methods

* PR feedback: it can be top-level private class

* PR feedback: block to expr

* PR feedback: if u r using ! then u can just use maxBy instead of maxByOrNull

* PR feedback: prob we dont need it - it's a private methods and should know on what data we call ut

* PR feedback: refactored rustPackages function

* PR feedback: safe casting

* PR feedback: inner classes are now private

* PR feedback: aspect typo

* moved Rust workspace resolving methods to another class

* PR feedback: distributed dependency resolver to methods

* Remove unnecessary returns and comments

* Use when instead of if-else

* Move some things around

* Move nested code to separate methods

* Added simple rust project and started rust e2e test class

* removed hello-world

* Add a basic `LanguagePluginService` test for Rust

* updated bsp version to include sysroot in rust toolchain

* Setting CARGO_BAZEL_REPIN in every bazel call to enable bazel lock files refreshing

* Printing custom env varaibles when calling bazel

* Changes 'env' to 'processEnv'

* Extracting toolchain host for Rust targets

* removed DEBUG flag from aspect

* this SHOULD (i don't know if it does) create missing proc-macros dynlibs

* Add basic unit tests for `RustWorkspaceResolver`

* Add a test for `RustWorkspaceResolver` with multiple targets and deps

* Rename methods

* Update labels and host in `RustWorkspaceResolverTest`

* Fix some issues with the data in `RustWorkspaceResolverTest`

* Change bsp to use rustcInfo

* Add `RustLanguagePluginTest`

* PR feedback: Use map instead of mapNotNull

* PR feedback: Use data class instead of typealias

* Move common testing code to a separate file

* Add raw dependencies testing

* removed debug info in from aspects.bzl

* Change BSP to use new interface

* Add aspects for rust and update bsp version

* Update bsp version and fix target resolution for rust

* Do not filter rust test build targets

* Sync with the newest BSP Rust extension

* Update BSP version and fix server tests

* Fix after merging upstream

* Delete RustToolchain request

* Add basic onReadStdin and onReadStderr handling

* Resolve PR issues amd refactor code

* Fix after merge with master

* Fix naming

* Add `rustExternalModules` to `modules` in `Project`

* README update

* First fixed to e2e tests

* Fix e2e tests

* Fix formatting

* Fix CI

* Move `expectedTargetIdentifiers` and `expectedWorkspaceBuildTargetsResult` to `BazelBspTestBaseScenario`

* Add e2e RustWorkspaceRequest test

* Fix after merging master

* Fix Rust e2e test

* Fix .bazelrc

* Fix `main function not found` error for integration tests

* Resolve PR issues part 1

* Fix buildifier

* Fix after merge

* Update testkit version

* Make `findAllRelatedRustTargets` tailrec

* Remove empty file

* Resolve PR issues

---------

Co-authored-by: Mikołaj Komar <mikokomar@op.pl>
Co-authored-by: Perlik <mp429581@students.mimuw.edu.pl>
Co-authored-by: Przemysław Kusiak <przemyslaw.r.kusiak@gmail.com>
Co-authored-by: juliapodrazka <juliapodrazka@poczta.onet.pl>
Co-authored-by: Julia Podrażka <73885839+julia-podrazka@users.noreply.github.com>
  • Loading branch information
6 people committed Dec 15, 2023
1 parent e7ae683 commit ec66172
Show file tree
Hide file tree
Showing 55 changed files with 2,203 additions and 72 deletions.
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ e2e/test-resources/remote-jdk-project/bazel-remote-jdk-project
e2e/test-resources/local-jdk-project/bazel-local-jdk-project
e2e/test-resources/python-project/bazel-python-project
e2e/test-resources/cpp-project/bazel-cpp-project
e2e/test-resources/rust-project/bazel-rust-project
4 changes: 2 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ common --enable_bzlmod

# To update these lines, execute
# `bazel run @rules_bazel_integration_test//tools:update_deleted_packages`
build --deleted_packages=.bazelbsp,.bazelbsp/aspects,e2e/test-resources/cpp-project/example,e2e/test-resources/local-jdk-project/example,e2e/test-resources/python-project/example,e2e/test-resources/python-project/lib,e2e/test-resources/python-project/test,e2e/test-resources/remote-jdk-project/example,e2e/test-resources/sample-repo/environment_variables,e2e/test-resources/sample-repo/java_targets,e2e/test-resources/sample-repo/java_targets/subpackage,e2e/test-resources/sample-repo/manual_target,e2e/test-resources/sample-repo/scala_targets,e2e/test-resources/sample-repo/target_with_dependency,e2e/test-resources/sample-repo/target_without_args,e2e/test-resources/sample-repo/target_without_jvm_flags,e2e/test-resources/sample-repo/target_without_main_class,e2e/test-resources/sample-repo/target_with_resources
query --deleted_packages=.bazelbsp,.bazelbsp/aspects,e2e/test-resources/cpp-project/example,e2e/test-resources/local-jdk-project/example,e2e/test-resources/python-project/example,e2e/test-resources/python-project/lib,e2e/test-resources/python-project/test,e2e/test-resources/remote-jdk-project/example,e2e/test-resources/sample-repo/environment_variables,e2e/test-resources/sample-repo/java_targets,e2e/test-resources/sample-repo/java_targets/subpackage,e2e/test-resources/sample-repo/manual_target,e2e/test-resources/sample-repo/scala_targets,e2e/test-resources/sample-repo/target_with_dependency,e2e/test-resources/sample-repo/target_without_args,e2e/test-resources/sample-repo/target_without_jvm_flags,e2e/test-resources/sample-repo/target_without_main_class,e2e/test-resources/sample-repo/target_with_resources
build --deleted_packages=.bazelbsp,.bazelbsp/aspects,e2e/test-resources/cpp-project/example,e2e/test-resources/local-jdk-project/example,e2e/test-resources/python-project/example,e2e/test-resources/python-project/lib,e2e/test-resources/python-project/test,e2e/test-resources/remote-jdk-project/example,e2e/test-resources/rust-project,e2e/test-resources/rust-project/example,e2e/test-resources/rust-project/example-lib,e2e/test-resources/sample-repo/environment_variables,e2e/test-resources/sample-repo/java_targets,e2e/test-resources/sample-repo/java_targets/subpackage,e2e/test-resources/sample-repo/manual_target,e2e/test-resources/sample-repo/scala_targets,e2e/test-resources/sample-repo/target_with_dependency,e2e/test-resources/sample-repo/target_with_resources,e2e/test-resources/sample-repo/target_without_args,e2e/test-resources/sample-repo/target_without_jvm_flags,e2e/test-resources/sample-repo/target_without_main_class
query --deleted_packages=.bazelbsp,.bazelbsp/aspects,e2e/test-resources/cpp-project/example,e2e/test-resources/local-jdk-project/example,e2e/test-resources/python-project/example,e2e/test-resources/python-project/lib,e2e/test-resources/python-project/test,e2e/test-resources/remote-jdk-project/example,e2e/test-resources/rust-project,e2e/test-resources/rust-project/example,e2e/test-resources/rust-project/example-lib,e2e/test-resources/sample-repo/environment_variables,e2e/test-resources/sample-repo/java_targets,e2e/test-resources/sample-repo/java_targets/subpackage,e2e/test-resources/sample-repo/manual_target,e2e/test-resources/sample-repo/scala_targets,e2e/test-resources/sample-repo/target_with_dependency,e2e/test-resources/sample-repo/target_with_resources,e2e/test-resources/sample-repo/target_without_args,e2e/test-resources/sample-repo/target_without_jvm_flags,e2e/test-resources/sample-repo/target_without_main_class

# From https://blog.aspect.dev/bazelrc-flags
build --incompatible_strict_action_env
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bazel_dep(

git_override(
module_name = "bsp-testkit2",
commit = "2b733e5a8671d10546a7002f00e89da0e48a53db",
commit = "8ca184e8dc543c01b121a2535371c65dcf3c9e57",
remote = "https://github.com/build-server-protocol/bsp-testkit2.git",
)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Bazel.
- Scala
- Python
- Thrift
- Rust (coming soon!)
- Rust

## Installation

Expand Down
1 change: 1 addition & 0 deletions aspects/core.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ COMPILE_DEPS = [
"jars",
"exports",
"associates",
"proc_macro_deps",
]

PRIVATE_COMPILE_DEPS = [
Expand Down
80 changes: 80 additions & 0 deletions aspects/rules/rust/rust_info.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
load("@rules_rust//rust:rust_common.bzl", "BuildInfo", "CrateInfo")
load("//aspects:utils/utils.bzl", "create_proto", "create_struct", "filter", "flatmap")

# This is supposed to be enum, but Starlark does not support enums.
# See bsp_target_info.proto:RustCrateLocation.
WORKSPACE_DIR = 0
EXEC_ROOT = 1

RUST_TOOLCHAIN_TYPE = "@rules_rust//rust:toolchain_type"

def collect_proc_macro_artifacts(target, kind, ext):
if not hasattr(target, "actions") or kind != "proc-macro":
return []

def is_proc_macro_output_with_ext(output):
return output.path.endswith(ext)

return filter(
is_proc_macro_output_with_ext,
flatmap(
lambda _action: _action.outputs.to_list(),
target.actions,
),
)

def extract_rust_crate_info(target, ctx, **kwargs):
if CrateInfo not in target:
return None, None

if RUST_TOOLCHAIN_TYPE not in ctx.toolchains:
return None, None

crate_info = target[CrateInfo]
build_info = None if not BuildInfo in target else target[BuildInfo]
toolchain = ctx.toolchains[RUST_TOOLCHAIN_TYPE]

crate_root_path = crate_info.root.path

def is_same_crate(dep):
if CrateInfo not in dep:
return False

return dep[CrateInfo].root.path == crate_root_path

crate_is_from_workspace = not crate_info.root.path.startswith("external/")
crate_is_generated = not crate_info.root.is_source
crate_is_in_exec_root = not crate_is_from_workspace or crate_is_generated

deps = [
dep[CrateInfo].root.path
for dep in (ctx.rule.attr.deps + ctx.rule.attr.proc_macro_deps)
if not is_same_crate(dep) and CrateInfo in dep
]

proc_macro_artifacts = collect_proc_macro_artifacts(target, crate_info.type, toolchain.dylib_ext)
proc_macro_artifacts_paths = [artifact.path for artifact in proc_macro_artifacts]

# To obtain crate root file, find directory corresponding to
# `crate_location` and concatenate it with `crate_id` (relative crate root
# file path); this has be done in bazel-bsp
# (see rules_rust/tools/rust_analyzer/rust_project.rs:write_rust_project).
rust_crate_struct = create_struct(
# The `crate-id` field must be unique. The deduplication has to be done
# in bazel-bsp
# (see rules_rust/tools/rust_analyzer/aquery.rs:consolidate_crate_specs).
crate_id = crate_info.root.path,
location = EXEC_ROOT if crate_is_in_exec_root else WORKSPACE_DIR,
from_workspace = crate_is_from_workspace,
name = crate_info.name,
kind = crate_info.type,
edition = crate_info.edition,
out_dir = "" if build_info == None else build_info.out_dir.path,
crate_features = ctx.rule.attr.crate_features,
dependencies_crate_ids = deps,
crate_root = crate_info.root.path,
version = ctx.rule.attr.version,
proc_macro_artifacts = proc_macro_artifacts_paths,
)

return create_proto(target, ctx, rust_crate_struct, "rust_crate_info"), None
6 changes: 6 additions & 0 deletions aspects/utils/utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ def map(f, xs):
def filter(f, xs):
return [x for x in xs if f(x)]

def flatten(xss):
return [x for xs in xss for x in xs]

def flatmap(f, xs):
return flatten(map(f, xs))

def file_location(file):
if file == None:
return None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class BazelRunner private constructor(
command: List<String>,
flags: List<String>,
arguments: List<String>,
environment: Map<String, String>,
originId: String?,
eventTextFile: Path,
): BazelProcess {
Expand All @@ -41,13 +42,21 @@ class BazelRunner private constructor(
)

// TODO https://youtrack.jetbrains.com/issue/BAZEL-617
return runBazelCommand(command, flags = besFlags() + flags, arguments, originId, true)
return runBazelCommand(
command,
flags = besFlags() + flags,
arguments,
environment,
originId,
true
)
}

fun runBazelCommand(
command: List<String>,
flags: List<String>,
arguments: List<String>,
environment: Map<String, String>,
originId: String?,
parseProcessOutput: Boolean,
useBuildFlags: Boolean = true,
Expand All @@ -56,8 +65,9 @@ class BazelRunner private constructor(
val usedBuildFlags = if (useBuildFlags) buildFlags(workspaceContext) else emptyList()
val processArgs =
listOf(bazel(workspaceContext)) + command + usedBuildFlags + flags + arguments
logInvocation(processArgs, originId)
logInvocation(processArgs, environment, originId)
val processBuilder = ProcessBuilder(processArgs)
processBuilder.environment() += environment
val outputLogger = bspClientLogger.takeIf { parseProcessOutput }
workspaceRoot?.let { processBuilder.directory(it.toFile()) }
val process = processBuilder.start()
Expand All @@ -68,8 +78,11 @@ class BazelRunner private constructor(
)
}

private fun logInvocation(processArgs: List<String>, originId: String?) {
"Invoking: ${processArgs.joinToString(" ")}"
private fun envToString(environment: Map<String, String>): String =
environment.entries.joinToString(" ") { "${it.key}=${it.value}" }

private fun logInvocation(processArgs: List<String>, processEnv: Map<String, String>, originId: String?) {
"Invoking: ${envToString(processEnv)} ${processArgs.joinToString(" ")}"
.also { LOGGER.info(it) }
.also { bspClientLogger.withOriginId(originId).message(it) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ open class BazelRunnerBuilder internal constructor(

private val flags = mutableListOf<String>()
private val arguments = mutableListOf<String>()
private val environmentVariables = mutableMapOf<String, String>()
private var useBuildFlags = false

fun withUseBuildFlags(useBuildFlags: Boolean = true): BazelRunnerBuilder {
Expand Down Expand Up @@ -89,14 +90,31 @@ open class BazelRunnerBuilder internal constructor(
return this
}

fun executeBazelCommand(
originId: String? = null,
parseProcessOutput: Boolean = true,
): BazelProcess {
return bazelRunner.runBazelCommand(bazelCommand, flags, arguments, originId, parseProcessOutput, useBuildFlags)
fun withEnvironment(environmentVariable: Pair<String, String>): BazelRunnerBuilder {
environmentVariables.putAll(listOf(environmentVariable))
return this
}

fun executeBazelCommand(originId: String? = null, parseProcessOutput: Boolean = true): BazelProcess {
return bazelRunner.runBazelCommand(
bazelCommand,
flags,
arguments,
environmentVariables,
originId,
parseProcessOutput,
useBuildFlags
)
}

fun executeBazelBesCommand(originId: String? = null, buildEventFile: Path): BazelProcess {
return bazelRunner.runBazelCommandBes(bazelCommand, flags, arguments, originId, buildEventFile.toAbsolutePath())
return bazelRunner.runBazelCommandBes(
bazelCommand,
flags,
arguments,
environmentVariables,
originId,
buildEventFile.toAbsolutePath()
)
}
}
8 changes: 8 additions & 0 deletions e2e/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,11 @@ bazel_integration_tests(
test_runner = "//e2e/src/main/kotlin/org/jetbrains/bsp/bazel:ServerDownloadsBazeliskTest",
workspace_path = "test-resources/sample-repo",
)

bazel_integration_tests(
name = "rust_project_test",
timeout = "eternal",
bazel_versions = bazel_binaries.versions.all,
test_runner = "//e2e/src/main/kotlin/org/jetbrains/bsp/bazel:BazelBspRustProjectTest",
workspace_path = "test-resources/rust-project",
)
13 changes: 13 additions & 0 deletions e2e/src/main/kotlin/org/jetbrains/bsp/bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,16 @@ kt_jvm_binary(
"@maven//:ch_epfl_scala_bsp4j",
],
)

kt_jvm_binary(
name = "BazelBspRustProjectTest",
srcs = ["BazelBspRustProjectTest.kt"],
main_class = "org.jetbrains.bsp.bazel.BazelBspRustProjectTest",
resources = ["//e2e/src/main/resources:bsp-e2e-resources"],
visibility = ["//e2e:__subpackages__"],
deps = [
"//commons",
"//e2e/src/main/kotlin/org/jetbrains/bsp/bazel/base",
"@maven//:ch_epfl_scala_bsp4j",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ object BazelBspCppProjectTest : BazelBspTestBaseScenario() {
listOf(compareWorkspaceTargetsResults(), cppOptions())

private fun compareWorkspaceTargetsResults(): BazelBspTestScenarioStep {
val expectedWorkspaceBuildTargetsResult = expectedWorkspaceBuildTargetsResult()

return BazelBspTestScenarioStep("cpp project") {
testClient.testWorkspaceTargets(20.seconds, expectedWorkspaceBuildTargetsResult)
}
}

override fun expectedWorkspaceBuildTargetsResult(): WorkspaceBuildTargetsResult {
val exampleExampleCppBuildTarget = CppBuildTarget().also { it.version = null; it.compiler = "compiler"; it.cCompiler = "/bin/gcc"; it.cppCompiler= "/bin/gcc" }

val exampleExampleBuildTarget =
Expand All @@ -51,16 +59,12 @@ object BazelBspCppProjectTest : BazelBspTestBaseScenario() {
ImmutableList.of(),
ImmutableList.of(),
ImmutableList.of(),
BuildTargetCapabilities().also { it.canCompile = false; it.canTest = false; it.canRun = false; it.canDebug = false }
BuildTargetCapabilities().also { it.canCompile = false; it.canTest = false; it.canRun = false; it.canDebug = false }
)
bspWorkspaceRootExampleBuildTarget.baseDirectory = "file://\$WORKSPACE/"
bspWorkspaceRootExampleBuildTarget.displayName = "bsp-workspace-root"
val expectedWorkspaceBuildTargetsResult =
WorkspaceBuildTargetsResult(ImmutableList.of(exampleExampleBuildTarget, bspWorkspaceRootExampleBuildTarget))

return BazelBspTestScenarioStep("cpp project") {
testClient.testWorkspaceTargets(20.seconds, expectedWorkspaceBuildTargetsResult)
}
return WorkspaceBuildTargetsResult(ImmutableList.of(exampleExampleBuildTarget, bspWorkspaceRootExampleBuildTarget))
}

private fun cppOptions(): BazelBspTestScenarioStep {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ object BazelBspLocalJdkTest : BazelBspTestBaseScenario() {
override fun scenarioSteps(): List<BazelBspTestScenarioStep> = listOf(workspaceBuildTargets())

private fun workspaceBuildTargets(): BazelBspTestScenarioStep {
val workspaceBuildTargetsResult = expectedWorkspaceBuildTargetsResult()

return BazelBspTestScenarioStep("workspace build targets") {
testClient.testWorkspaceTargets(
60.seconds,
workspaceBuildTargetsResult
)
}
}

override fun expectedWorkspaceBuildTargetsResult(): WorkspaceBuildTargetsResult {
val exampleExampleJvmBuildTarget = JvmBuildTarget().also {
it.javaHome = "file://\$BAZEL_OUTPUT_BASE_PATH/external/local_jdk/"
it.javaVersion = "17"
Expand All @@ -42,14 +53,8 @@ object BazelBspLocalJdkTest : BazelBspTestBaseScenario() {
exampleExampleBuildTarget.data = exampleExampleJvmBuildTarget
exampleExampleBuildTarget.dataKind = BuildTargetDataKind.JVM

val workspaceBuildTargetsResult = WorkspaceBuildTargetsResult(
return WorkspaceBuildTargetsResult(
listOf(exampleExampleBuildTarget)
)
return BazelBspTestScenarioStep("workspace build targets") {
testClient.testWorkspaceTargets(
60.seconds,
workspaceBuildTargetsResult
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object BazelBspPythonProjectTest : BazelBspTestBaseScenario() {
resourcesResults()
)

private fun expectedWorkspaceBuildTargetsResult(): WorkspaceBuildTargetsResult {
override fun expectedWorkspaceBuildTargetsResult(): WorkspaceBuildTargetsResult {
val bspWorkspaceRootExampleBuildTarget =
BuildTarget(
BuildTargetIdentifier("bsp-workspace-root"),
Expand Down Expand Up @@ -158,9 +158,4 @@ object BazelBspPythonProjectTest : BazelBspTestBaseScenario() {
testClient.testResources(30.seconds, resourcesParams, expectedResourcesResult)
}
}

private fun expectedTargetIdentifiers(): List<BuildTargetIdentifier> =
expectedWorkspaceBuildTargetsResult()
.targets
.map { it.id }
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ object BazelBspRemoteJdkTest : BazelBspTestBaseScenario() {
override fun scenarioSteps(): List<BazelBspTestScenarioStep> = listOf(workspaceBuildTargets())

private fun workspaceBuildTargets(): BazelBspTestScenarioStep {
val workspaceBuildTargetsResult = expectedWorkspaceBuildTargetsResult()

return BazelBspTestScenarioStep("workspace build targets") {
testClient.testWorkspaceTargets(
1.minutes,
workspaceBuildTargetsResult
)
}
}

override fun expectedWorkspaceBuildTargetsResult(): WorkspaceBuildTargetsResult {
val exampleExampleJvmBuildTarget = JvmBuildTarget().also {
it.javaVersion = "11"
it.javaHome = "file://\$BAZEL_OUTPUT_BASE_PATH/external/remotejdk11_linux/"
Expand All @@ -37,14 +48,8 @@ object BazelBspRemoteJdkTest : BazelBspTestBaseScenario() {
exampleExampleBuildTarget.data = exampleExampleJvmBuildTarget
exampleExampleBuildTarget.dataKind = BuildTargetDataKind.JVM

val workspaceBuildTargetsResult = WorkspaceBuildTargetsResult(
return WorkspaceBuildTargetsResult(
listOf(exampleExampleBuildTarget)
)
return BazelBspTestScenarioStep("workspace build targets") {
testClient.testWorkspaceTargets(
1.minutes,
workspaceBuildTargetsResult
)
}
}
}
Loading

0 comments on commit ec66172

Please sign in to comment.