Make sure rule_integration_test can actually be called.
PiperOrigin-RevId: 627860167
Change-Id: Ic7872ff1e291ea2e59f69da1750cf49453873dfa
diff --git a/src/test/shell/integration/BUILD b/src/test/shell/integration/BUILD
index c908806..1805cb3 100644
--- a/src/test/shell/integration/BUILD
+++ b/src/test/shell/integration/BUILD
@@ -890,6 +890,16 @@
)
sh_test(
+ name = "rule_transition_test",
+ srcs = ["rule_transition_test.sh"],
+ data = [
+ ":test-deps",
+ "@bazel_tools//tools/bash/runfiles",
+ ],
+ tags = ["no_windows"],
+)
+
+sh_test(
name = "unicode_test",
srcs = ["unicode_test.sh"],
data = [
diff --git a/src/test/shell/integration/rule_transition_test.sh b/src/test/shell/integration/rule_transition_test.sh
index 0df6415..91f5ed7 100755
--- a/src/test/shell/integration/rule_transition_test.sh
+++ b/src/test/shell/integration/rule_transition_test.sh
@@ -17,7 +17,7 @@
# Test rule transition can inspect configurable attribute.
# --- begin runfiles.bash initialization ---
-# Copy-pasted from Bazel's Bash runfiles library (tools/bash/runfiles/runfiles.bash).
+set -euo pipefail
if [[ ! -d "${RUNFILES_DIR:-/dev/null}" && ! -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
if [[ -f "$0.runfiles_manifest" ]]; then
export RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
@@ -41,16 +41,35 @@
source "$(rlocation "io_bazel/src/test/shell/integration_test_setup.sh")" \
|| { echo "integration_test_setup.sh not found!" >&2; exit 1; }
+#### SETUP #############################################################
+
+add_to_bazelrc "build --genrule_strategy=local"
+add_to_bazelrc "test --test_strategy=standalone"
+
function set_up() {
create_new_workspace
+
+ # Define common starlark flags.
+ mkdir -p settings
+ touch settings/BUILD
+ cat > settings/flag.bzl <<EOF
+BuildSettingInfo = provider(fields = ["value"])
+
+def _bool_flag_impl(ctx):
+ return [BuildSettingInfo(value = ctx.build_setting_value)]
+
+bool_flag = rule(
+ implementation = _bool_flag_impl,
+ build_setting = config.bool(flag = True)
+)
+EOF
}
function create_transitions() {
local pkg="${1}"
mkdir -p "${pkg}"
cat > "${pkg}/def.bzl" <<EOF
-
-load("//third_party/bazel_skylib/rules:common_settings.bzl", "BuildSettingInfo")
+load("//settings:flag.bzl", "BuildSettingInfo")
example_package = "${pkg}"
@@ -100,7 +119,7 @@
"transition_attached",
"transition_not_attached",
)
-load("//third_party/bazel_skylib/rules:common_settings.bzl", "bool_flag")
+load("//settings:flag.bzl", "bool_flag")
bool_flag(
name = "transition_input_flag",
@@ -189,8 +208,7 @@
# create transition definition
mkdir -p "${pkg}"
cat > "${pkg}/def.bzl" <<EOF
-
-load("//third_party/bazel_skylib/rules:common_settings.bzl", "BuildSettingInfo")
+load("//settings:flag.bzl", "BuildSettingInfo")
example_package = "${pkg}"
@@ -234,7 +252,7 @@
"//${pkg}:def.bzl",
"transition_attached",
)
-load("//third_party/bazel_skylib/rules:common_settings.bzl", "bool_flag")
+load("//settings:flag.bzl", "bool_flag")
bool_flag(
name = "transition_input_flag",
@@ -275,8 +293,7 @@
# create transition definition
mkdir -p "${pkg}"
cat > "${pkg}/def.bzl" <<EOF
-
-load("//third_party/bazel_skylib/rules:common_settings.bzl", "BuildSettingInfo")
+load("//settings:flag.bzl", "BuildSettingInfo")
example_package = "${pkg}"
@@ -343,8 +360,7 @@
# create transition definition
mkdir -p "${pkg}"
cat > "${pkg}/def.bzl" <<EOF
-
-load("//third_party/bazel_skylib/rules:common_settings.bzl", "BuildSettingInfo")
+load("//settings:flag.bzl", "BuildSettingInfo")
example_package = "${pkg}"