Skip to content

Commit 0dccc84

Browse files
committed
Add tests for diagnostics
1 parent 38ca191 commit 0dccc84

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

test/BUILD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ load(":compiler_arguments_tests.bzl", "compiler_arguments_test_suite")
77
load(":const_values_tests.bzl", "const_values_test_suite")
88
load(":coverage_settings_tests.bzl", "coverage_settings_test_suite")
99
load(":debug_settings_tests.bzl", "debug_settings_test_suite")
10+
load(":diagnostics_tests.bzl", "diagnostics_test_suite")
1011
load(":environment_tests.bzl", "environment_test_suite")
1112
load(":features_tests.bzl", "features_test_suite")
1213
load(":generated_header_tests.bzl", "generated_header_test_suite")
@@ -45,6 +46,8 @@ coverage_settings_test_suite(name = "coverage_settings")
4546

4647
debug_settings_test_suite(name = "debug_settings")
4748

49+
diagnostics_test_suite(name = "diagnostics")
50+
4851
environment_test_suite(name = "environment")
4952

5053
features_test_suite(name = "features")

test/diagnostics_tests.bzl

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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

Comments
 (0)