1# Copyright 2018 The Bazel Authors. All rights reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15"""Bazel Android testing libs.""" 16 17load( 18 ":file.bzl", 19 _file = "file", 20) 21load( 22 ":unittest.bzl", 23 _analysistest = "analysistest", 24 _unittest = "unittest", 25) 26load( 27 "@bazel_skylib//lib:unittest.bzl", 28 _asserts = "asserts", 29) 30 31file = _file 32 33unittest = _unittest 34 35analysistest = _analysistest 36 37asserts = _asserts 38 39def _failure_test_impl(ctx): 40 env = analysistest.begin(ctx) 41 if ctx.attr.expected_error_msg != "": 42 asserts.expect_failure(env, ctx.attr.expected_error_msg) 43 return analysistest.end(env) 44 45failure_test = analysistest.make( 46 _failure_test_impl, 47 expect_failure = True, 48 attrs = dict( 49 expected_error_msg = attr.string(), 50 ), 51) 52