Skip to content

Commit

Permalink
handling for debugging python test targets with transitions - fix for…
Browse files Browse the repository at this point in the history
… query test
  • Loading branch information
andponlin-canva committed Dec 18, 2024
1 parent 9e974d3 commit 14b09bf
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import com.google.idea.blaze.qsync.BlazeQueryParser;
import java.nio.file.Path;
import java.util.stream.Stream;
import java.util.stream.Collectors;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand Down Expand Up @@ -86,6 +88,22 @@ public void testGetQueryExpression_includes_and_excludes() {

@Test
public void testGetQueryExpression_experimental_includes_and_excludes() {

// There are a number of Kinds that are expected to be queried for. It is also
// necessary to include the same Kinds with the prefix `_transition_` as well because it
// could be that any given rule is subject to a transition.

String kindsExpression = Stream.of(
"android_library", "android_binary", "android_local_test",
"android_instrumentation_test", "kt_android_library_helper", "java_library", "java_binary",
"kt_jvm_library", "kt_jvm_binary", "kt_jvm_library_helper", "java_test",
"java_proto_library", "java_lite_proto_library", "java_mutable_proto_library",
"_java_grpc_library", "_kotlin_library", "_java_lite_grpc_library", "_iml_module_",
"cc_library", "cc_binary", "cc_shared_library", "cc_test", "proto_library", "py_library",
"py_binary", "py_test")
.flatMap(k -> Stream.of(k, "_transition_" + k))
.collect(Collectors.joining("|"));

QuerySpec qs =
QuerySpec.builder(QuerySpec.QueryStrategy.FILTERING_TO_KNOWN_AND_USED_TARGETS)
.workspaceRoot(Path.of("/workspace/"))
Expand All @@ -98,7 +116,7 @@ public void testGetQueryExpression_experimental_includes_and_excludes() {
assertThat(qs.getQueryExpression())
.hasValue(
"let base = //some/included/path/...:* + //another/included/path/...:* - //some/included/path/excluded/...:* - //another/included/path/excluded/...:*\n" +
" in let known = kind(\"source file|android_library|android_binary|android_local_test|android_instrumentation_test|kt_android_library_helper|java_library|java_binary|kt_jvm_library|kt_jvm_binary|kt_jvm_library_helper|java_test|java_proto_library|java_lite_proto_library|java_mutable_proto_library|_java_grpc_library|_kotlin_library|_java_lite_grpc_library|_iml_module_|cc_library|cc_binary|cc_shared_library|cc_test|proto_library|py_library|py_binary|py_test\", $base) \n" +
" in let known = kind(\"source file|" + kindsExpression + "\", $base) \n" +
" in let unknown = $base except $known \n" +
" in $known union ($base intersect allpaths($known, $unknown)) \n");
}
Expand Down

0 comments on commit 14b09bf

Please sign in to comment.