Skip to content

Commit 9d46311

Browse files
committed
refactor: Migrate resource-strip-prefix and library-suite build failures to Bazel
Move test_expect_failure/mismatching_resource_strip_prefix and test_expect_failure/scala_library_suite into test/resource_strip_prefix and test/scala_library_suite, driven by expect_build_failure_test instead of the scala_library_jar_without_srcs_must_fail_on_mismatching_resource_strip_prefix (test/shell/test_scala_library_jar.sh) and test_scala_library_suite (test/shell/test_scala_library.sh) cases. scala_library_suite now forwards `tags` to the aggregate suite target as well (children already receive them via **kwargs), so `tags = ["manual"]` keeps the whole suite -- which depends on a deliberately invalid child -- out of wildcard builds.
1 parent 633dacc commit 9d46311

9 files changed

Lines changed: 37 additions & 23 deletions

File tree

scala/private/rules/scala_library.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ def scala_library_suite(
145145
visibility = visibility,
146146
exports = exports + ts,
147147
deps = ts,
148+
# Forward tags to the aggregate target too (children already get them via
149+
# **kwargs), so e.g. `tags = ["manual"]` can keep the whole suite -- which
150+
# depends on every child -- out of wildcard builds.
151+
tags = kwargs.get("tags", []),
148152
)
149153

150154
##

test/resource_strip_prefix/BUILD

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
load("//scala:scala.bzl", "scala_library")
2+
load("//test/expect_build_failure:expect_build_failure.bzl", "expect_build_failure_test")
3+
4+
# A resource_strip_prefix that does not match the resource's path must be
5+
# rejected. Tagged "manual" so wildcard builds skip it; the sh_test drives a
6+
# nested `bazel build` and asserts the failure.
7+
scala_library(
8+
name = "noSrcsJarWithWrongStripPrefix",
9+
resource_strip_prefix = "wrong_prefix",
10+
resources = ["resource.txt"],
11+
tags = ["manual"],
12+
)
13+
14+
expect_build_failure_test(
15+
name = "mismatching_resource_strip_prefix_build_test",
16+
target = ":noSrcsJarWithWrongStripPrefix",
17+
)

test_expect_failure/mismatching_resource_strip_prefix/resource.txt renamed to test/resource_strip_prefix/resource.txt

File renamed without changes.

test/scala_library_suite/BUILD

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
load("//scala:scala.bzl", "scala_library_suite")
2+
load("//test/expect_build_failure:expect_build_failure.bzl", "expect_build_failure_test")
3+
4+
# A scala_library_suite whose children depend on one another must be rejected.
5+
# Tagged "manual" so wildcard builds skip it; the sh_test drives a nested
6+
# `bazel build` and asserts the failure.
7+
scala_library_suite(
8+
name = "library_suite_dep_on_children",
9+
srcs = glob(["Data*.scala"]),
10+
tags = ["manual"],
11+
)
12+
13+
expect_build_failure_test(
14+
name = "scala_library_suite_build_test",
15+
target = ":library_suite_dep_on_children",
16+
)
File renamed without changes.

test/shell/test_scala_library.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ test_scala_library_expect_no_recompilation_of_target_on_internal_change_of_depen
4949
test_scala_library_expect_no_recompilation_on_internal_change $1 $2 ":user" "'user'"
5050
}
5151

52-
test_scala_library_suite() {
53-
action_should_fail build test_expect_failure/scala_library_suite:library_suite_dep_on_children
54-
}
55-
5652
test_scala_library_expect_failure_on_missing_direct_internal_deps() {
5753
dependenecy_target='//test_expect_failure/missing_direct_deps/internal_deps:transitive_dependency'
5854
test_target='test_expect_failure/missing_direct_deps/internal_deps:transitive_dependency_user'
@@ -179,7 +175,6 @@ test_scala_library_expect_better_failure_message_on_missing_transitive_dependenc
179175
test_expect_failure_or_warning_on_missing_direct_deps_with_expected_message "${expected_message}" $test_target "--extra_toolchains=//test/toolchains:high_level_transitive_deps_strict_deps_error"
180176
}
181177

182-
$runner test_scala_library_suite
183178
$runner test_scala_library_expect_failure_on_missing_direct_internal_deps
184179
$runner test_scala_library_expect_failure_on_missing_direct_external_deps_jar
185180
$runner test_scala_library_expect_failure_on_missing_direct_external_deps_file_group

test/shell/test_scala_library_jar.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,5 @@ scala_library_jar_without_srcs_must_include_filegroup_resources(){
2121
test_resources "noSrcsWithFilegroupResources"
2222
}
2323

24-
scala_library_jar_without_srcs_must_fail_on_mismatching_resource_strip_prefix() {
25-
action_should_fail build test_expect_failure/mismatching_resource_strip_prefix:noSrcsJarWithWrongStripPrefix
26-
}
27-
28-
$runner scala_library_jar_without_srcs_must_fail_on_mismatching_resource_strip_prefix
2924
$runner scala_library_jar_without_srcs_must_include_direct_file_resources
3025
$runner scala_library_jar_without_srcs_must_include_filegroup_resources

test_expect_failure/mismatching_resource_strip_prefix/BUILD

Lines changed: 0 additions & 7 deletions
This file was deleted.

test_expect_failure/scala_library_suite/BUILD

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)