Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
Entire repository import test (#53)
Browse files Browse the repository at this point in the history
* testkit version bump

* test

* todo

* style

* style v2

* ci fix 1

* ci fix

* variable update + gitignore update
  • Loading branch information
abrams27 committed Apr 22, 2021
1 parent 93e39c1 commit 5032915
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
/.idea/
/.ijwb/
/bazel-*
.DS_Store
.DS_Store
test-resources/.bazelbsp/
test-resources/.bsp/
20 changes: 17 additions & 3 deletions src/test/java/org/jetbrains/bsp/bazel/BazelBspServerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

// TODO: these tests need some love again...
public class BazelBspServerTest {

private static final Logger LOGGER = LogManager.getLogger(BazelBspServerTest.class);
Expand All @@ -27,16 +28,17 @@ private static <T> Stream<T> concat(Stream<T>... streams) {
}

public void run() {

LOGGER.info("Creating TestClients...");

List<BazelBspServerSingleTest> testsToRun =
concat(
getSampleRepoTests().stream(),
getActionGraphV1Tests().stream(),
getActionGraphV2Tests().stream(),
getJava8ProjectTests().stream(),
getJava11ProjectTests().stream(),
getJavaDefaultProjectTests().stream())
getJavaDefaultProjectTests().stream(),
getEntireRepositoryImportTests().stream())
.collect(Collectors.toList());

LOGGER.info("Created TestClients. Running BazelBspServerTest...");
Expand Down Expand Up @@ -85,6 +87,17 @@ private List<BazelBspServerSingleTest> getJavaDefaultProjectTests() {
BazelBspServerTestData.EXPECTED_BUILD_TARGETS_JAVA_11)));
}

private List<BazelBspServerSingleTest> getEntireRepositoryImportTests() {
TestClient client =
TestClient$.MODULE$.testInitialStructure(
BazelBspServerTestData.REPO_PATH,
ImmutableMap.of(),
BazelBspServerTestData.TEST_CLIENT_TIMEOUT_IN_MINUTES);
return ImmutableList.of(
new BazelBspServerSingleTest(
"import entire repo", () -> client.testResolveProject(true, false)));
}

private List<BazelBspServerSingleTest> getActionGraphV1Tests() {
TestClient client =
TestClient$.MODULE$.testInitialStructure(
Expand Down Expand Up @@ -137,7 +150,8 @@ private List<BazelBspServerSingleTest> getSampleRepoTests() {
BazelBspServerTestData.TEST_CLIENT_TIMEOUT_IN_MINUTES);

return ImmutableList.of(
new BazelBspServerSingleTest("resolve project", client::testResolveProject),
new BazelBspServerSingleTest(
"resolve project", () -> client.testResolveProject(false, false)),
new BazelBspServerSingleTest(
"compare workspace targets results",
() ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@

class BazelBspServerTestData {

private static final String BUILD_WORKSPACE_DIRECTORY = "BUILD_WORKSPACE_DIRECTORY";
static final String REPO_PATH = System.getenv(BUILD_WORKSPACE_DIRECTORY);

private static final String SAMPLE_REPO_PATH = "sample-repo";
private static final String ACTION_GRAPH_V2 = "action-graph-v2";
private static final String JAVA_8 = "java-8-project";
Expand All @@ -48,9 +51,7 @@ class BazelBspServerTestData {
private static final String SAMPLE_REPO_DEP_PATH = SAMPLE_REPO_PATH + "/dep";

private static final String TEST_RESOURCES_PATH = "test-resources";
private static final String BUILD_WORKSPACE_DIRECTORY = "BUILD_WORKSPACE_DIRECTORY";
private static final String WORKSPACE_DIR_PATH =
System.getenv(BUILD_WORKSPACE_DIRECTORY) + "/" + TEST_RESOURCES_PATH;
private static final String WORKSPACE_DIR_PATH = REPO_PATH + "/" + TEST_RESOURCES_PATH;

private static final BuildTargetIdentifier EXAMPLE_EXAMPLE_TARGET =
new BuildTargetIdentifier("//example:example");
Expand Down
5 changes: 5 additions & 0 deletions test-resources/action-graph-v2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.bazelbsp/
/.bsp/
/.idea/
/.ijwb/
/bazel-*
6 changes: 5 additions & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ test_bsp_server() {

bazel run --define "maven_repo=file://$HOME/.m2/repository" //:bsp.publish
bsp_path="$(bazel info bazel-bin)/bsp-project.jar"
cd test-resources

log_test_progress "Installing BSP..."

java -cp "$bsp_path" org.jetbrains.bsp.bazel.install.Install

cd test-resources

for project in "${TEST_PROJECTS[@]}"
do
cd "$project"
Expand Down
2 changes: 1 addition & 1 deletion third_party.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ _deps = [
_dependency("com.google.code.gson:gson:2.8.5"),
_dependency("com.google.guava:guava:28.1-jre"),
_dependency("ch.epfl.scala:bsp4j:2.0.0-M13+37-43869cf9-SNAPSHOT"),
_dependency("ch.epfl.scala:bsp-testkit_2.13:2.0.0-M13+37-43869cf9-SNAPSHOT"),
_dependency("ch.epfl.scala:bsp-testkit_2.13:2.0.0-M13+38-664bda5b-SNAPSHOT"),
_dependency("org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:0.8.0"),
_dependency("org.eclipse.xtext:org.eclipse.xtext.xbase.lib:2.19.0"),
_dependency("commons-cli:commons-cli:jar:1.4"),
Expand Down

0 comments on commit 5032915

Please sign in to comment.