`print`->`fail` and suppress the warning in another case. (#177)

This commit is contained in:
Thomas Van Lenten 2019-07-22 13:25:00 -04:00 committed by GitHub
parent a6c72f2b39
commit d2cf1cc2bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 46 deletions

35
lib.bzl
View File

@ -14,36 +14,7 @@
"""Index from which multiple modules can be loaded."""
load("//lib:collections.bzl", _collections = "collections")
load("//lib:dicts.bzl", _dicts = "dicts")
load("//lib:new_sets.bzl", _new_sets = "sets")
load("//lib:partial.bzl", _partial = "partial")
load("//lib:paths.bzl", _paths = "paths")
load("//lib:selects.bzl", _selects = "selects")
load("//lib:sets.bzl", _sets = "sets")
load("//lib:shell.bzl", _shell = "shell")
load("//lib:structs.bzl", _structs = "structs")
load("//lib:types.bzl", _types = "types")
load("//lib:unittest.bzl", _asserts = "asserts", _unittest = "unittest")
load("//lib:versions.bzl", _versions = "versions")
print(
"WARNING: lib.bzl is deprecated and will go away in the future, please" +
" directly load the bzl file(s) of the module(s) needed as it is more" +
" efficient.",
fail(
"lib.bzl has been removed, please directly load the bzl file(s) of the" +
" module(s) needed as it is more efficient.",
)
collections = _collections
dicts = _dicts
new_sets = _new_sets
partial = _partial
paths = _paths
selects = _selects
sets = _sets
shell = _shell
structs = _structs
types = _types
versions = _versions
asserts = _asserts
unittest = _unittest

View File

@ -335,6 +335,8 @@ def _fail(env, msg):
msg: The message to log describing the failure.
"""
full_msg = "In test %s: %s" % (env.ctx.attr._impl_name, msg)
# There isn't a better way to output the message in Starlark, so use print.
# buildifier: disable=print
print(full_msg)
env.failures.append(full_msg)

View File

@ -93,8 +93,7 @@ def _check_bazel_version(minimum_bazel_version, maximum_bazel_version = None, ba
minimum_bazel_version,
))
elif not native.bazel_version:
print("Current Bazel is not a release version; cannot check for compatibility. " +
"Make sure that you are running at least Bazel {}.".format(minimum_bazel_version))
# Using a non-release version, assume it is good.
return
else:
bazel_version = native.bazel_version

View File

@ -14,19 +14,10 @@
"""Skylib module containing a library rule for aggregating rules files.
Deprecated:
Removed:
Use bzl_library in bzl_library.bzl instead.
"""
load("//:bzl_library.bzl", "StarlarkLibraryInfo", "bzl_library")
print(
"WARNING: skylark_library.bzl is deprecated and will go away in the future, please" +
" use bzl_library.bzl instead.",
fail(
"skylark_library.bzl has been removed, please use bzl_library.bzl instead.",
)
# These are temporary forwarding macros to facilitate migration to
# the new names for these objects.
SkylarkLibraryInfo = StarlarkLibraryInfo
skylark_library = bzl_library