Files
carbon-lang/toolchain/diagnostics/BUILD
T
Jon Ross-Perkins 806bee1063 Shift from ARGS to EXTRA-ARGS where possible (#5602)
Adds minimal defaults for codegen so that those tests don't need to
specify the full command line.

Moves driver/testdata/compile to check/testdata/basics/raw_sem_ir, which
seems like it better reflects the focus. Removes the textual IR test
because we have plenty of those now.

Moves a multiline token diagnostic test to parse because (a) diagnostics
doesn't have other tests and (b) this is really testing the way that
parse structures the location.

Drops `--include-diagnostic-kind` from some driver tests that aren't
testing a diagnostic, so the flag felt a bit like noise (even before
this change, there are a few tests that don't specify it because they're
not intended to test an emitted diagnostic, just high-level diagnostic
behaviors).

Adds some comments to reflect my understanding of why a test exists,
when I was pausing to think about it.

Modifies the stdin test to do more dumps; which happens to expose we
currently misbehave.
2025-06-03 22:09:57 +00:00

157 lines
3.4 KiB
Python

# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
# Exceptions. See /LICENSE for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
load("//bazel/cc_rules:defs.bzl", "cc_library", "cc_test")
load("//bazel/manifest:defs.bzl", "manifest")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "diagnostic_emitter",
srcs = [
"diagnostic.cpp",
"diagnostic_consumer.cpp",
],
hdrs = [
"diagnostic.h",
"diagnostic_consumer.h",
"diagnostic_emitter.h",
],
deps = [
":diagnostic_kind",
":format_providers",
"//common:check",
"//common:ostream",
"@llvm-project//llvm:Support",
],
)
cc_test(
name = "diagnostic_emitter_test",
size = "small",
srcs = ["diagnostic_emitter_test.cpp"],
deps = [
":diagnostic_emitter",
":mocks",
"//testing/base:gtest_main",
"@googletest//:gtest",
"@llvm-project//llvm:Support",
],
)
cc_library(
name = "diagnostic_kind",
srcs = ["diagnostic_kind.cpp"],
hdrs = ["diagnostic_kind.h"],
textual_hdrs = [
"diagnostic_kind.def",
],
deps = [
"//common:enum_base",
],
)
manifest(
name = "all_testdata.txt",
srcs = ["//toolchain/testing:all_testdata"],
)
cc_test(
name = "coverage_test",
size = "small",
srcs = ["coverage_test.cpp"],
args = ["--testdata_manifest=$(location :all_testdata.txt)"],
data = [
":all_testdata.txt",
"//toolchain/testing:all_testdata",
],
deps = [
":diagnostic_kind",
"//testing/base:gtest_main",
"//toolchain/testing:coverage_helper",
"@abseil-cpp//absl/flags:flag",
"@googletest//:gtest",
],
)
cc_library(
name = "file_diagnostics",
hdrs = ["file_diagnostics.h"],
deps = [
":diagnostic_emitter",
"@llvm-project//llvm:Support",
],
)
cc_library(
name = "format_providers",
srcs = ["format_providers.cpp"],
hdrs = ["format_providers.h"],
deps = [
"//common:check",
"//common:ostream",
"@llvm-project//llvm:Support",
],
)
cc_test(
name = "format_providers_test",
size = "small",
srcs = ["format_providers_test.cpp"],
deps = [
":diagnostic_emitter",
":format_providers",
":mocks",
"//testing/base:gtest_main",
"@googletest//:gtest",
"@llvm-project//llvm:Support",
],
)
cc_library(
name = "null_diagnostics",
testonly = 1,
hdrs = ["null_diagnostics.h"],
deps = [
":diagnostic_emitter",
"@llvm-project//llvm:Support",
],
)
cc_library(
name = "sorting_diagnostic_consumer",
hdrs = ["sorting_diagnostic_consumer.h"],
deps = [
":diagnostic_emitter",
"//common:check",
"@llvm-project//llvm:Support",
],
)
cc_test(
name = "sorting_diagnostic_consumer_test",
size = "small",
srcs = ["sorting_diagnostic_consumer_test.cpp"],
deps = [
":diagnostic_emitter",
":mocks",
":sorting_diagnostic_consumer",
"//testing/base:gtest_main",
"@googletest//:gtest",
"@llvm-project//llvm:Support",
],
)
cc_library(
name = "mocks",
testonly = 1,
srcs = ["mocks.cpp"],
hdrs = ["mocks.h"],
deps = [
":diagnostic_emitter",
"@googletest//:gtest",
"@llvm-project//llvm:Support",
],
)