summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Ostrovsky <david@ostrovsky.org>2020-05-22 16:25:36 +0200
committerLuca Milanesio <luca.milanesio@gmail.com>2020-06-08 09:06:24 +0000
commitf4da11a04a358bf62c48186490db60c810b7b4fb (patch)
tree37046dc01577426bffff871c926b2e99e401f64a
parentea720ae54cb4f24c39edca8da634c91edde6fc26 (diff)
Bazel: Add always pass test to avoid boilerplate in the CI
We don't know whether or not all plugins have test rules, so running a generic command: $ bazelisk test plugins/{name}/... can lead to no tests found outcome, in which case Bazel will return exit code 4 that needs to be checked to differentiate from test failure (exit code 1). To avoid those checks, pass the virtual test that will always succeed: $ bazelisk test //tools/bzl:always_pass_test plugins/{name}/... See also this upstream issue for this suggested workaround: [1]. [1] https://github.com/bazelbuild/bazel/issues/11465 Change-Id: Ideab64674482400cc48fad55f7ed9f8085909b84 (cherry picked from commit d69773ceb5c84cfcf13749b2f555bf92d22e6f71) (cherry picked from commit 938db887d803889e34a1adfd762c259eadcdd6a3)
-rw-r--r--tools/bzl/BUILD5
-rwxr-xr-xtools/bzl/always_pass_test.sh21
2 files changed, 26 insertions, 0 deletions
diff --git a/tools/bzl/BUILD b/tools/bzl/BUILD
index a0f5bd1408..7febbacd8f 100644
--- a/tools/bzl/BUILD
+++ b/tools/bzl/BUILD
@@ -3,3 +3,8 @@ exports_files([
"test_empty.sh",
"test_license.sh",
])
+
+sh_test(
+ name = "always_pass_test",
+ srcs = ["always_pass_test.sh"],
+)
diff --git a/tools/bzl/always_pass_test.sh b/tools/bzl/always_pass_test.sh
new file mode 100755
index 0000000000..15c58cad54
--- /dev/null
+++ b/tools/bzl/always_pass_test.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This is a dummy test to put on the command line to avoid no tests
+# found outcome in `bazel test` command. See this upstream issue:
+# https://github.com/bazelbuild/bazel/issues/11465
+
+exit 0