|
| 1 | +# Copyright 2024 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 | +"""Tests for `swift.emit_diagnostics` feature.""" |
| 16 | + |
| 17 | +load( |
| 18 | + "//test/rules:action_command_line_test.bzl", |
| 19 | + "make_action_command_line_test_rule", |
| 20 | +) |
| 21 | +load( |
| 22 | + "//test/rules:provider_test.bzl", |
| 23 | + "provider_test", |
| 24 | +) |
| 25 | + |
| 26 | +diagnostics_command_line_test = make_action_command_line_test_rule( |
| 27 | + config_settings = { |
| 28 | + "//command_line_option:features": [ |
| 29 | + "swift.emit_diagnostics", |
| 30 | + ], |
| 31 | + }, |
| 32 | +) |
| 33 | + |
| 34 | +def diagnostics_test_suite(name, tags = []): |
| 35 | + """Test suite for `swift_library` producing .dia files. |
| 36 | +
|
| 37 | + Args: |
| 38 | + name: The base name to be used in things created by this macro. |
| 39 | + tags: Additional tags to apply to each test. |
| 40 | + """ |
| 41 | + all_tags = [name] + tags |
| 42 | + |
| 43 | + diagnostics_command_line_test( |
| 44 | + name = "{}_serialize_diagnostics_flag".format(name), |
| 45 | + expected_argv = [ |
| 46 | + "-serialize-diagnostics", |
| 47 | + ], |
| 48 | + mnemonic = "SwiftCompile", |
| 49 | + tags = all_tags, |
| 50 | + target_under_test = "//test/fixtures/basic:first", |
| 51 | + ) |
| 52 | + |
| 53 | + native.test_suite( |
| 54 | + name = name, |
| 55 | + tags = all_tags, |
| 56 | + ) |
| 57 | + |
0 commit comments