Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests/cc/cpp_compile_error_defines_is_transitive
Browse files Browse the repository at this point in the history
yuyawk committed Apr 7, 2024
1 parent 7a8a7a5 commit 6920cd9
Showing 2 changed files with 53 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/cc/cpp_compile_error_defines_is_transitive/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
load("//lang/cc:defs.bzl", "cc_build_error")
load("//matcher:defs.bzl", "matcher")
load("@bazel_skylib//rules:build_test.bzl", "build_test")

cc_library(
name = "library",
defines = ["MACRO_IN_DEFINES"],
)

cc_build_error(
name = "plain",
src = "cpp_compile_error.cpp",
deps = [":library"],
)

cc_build_error(
name = "with_substr_matcher",
src = "cpp_compile_error.cpp",
compile_stderr = matcher.has_substr("With transitive defines, "),
deps = [":library"],
)

cc_build_error(
name = "with_basic_regex_matcher",
src = "cpp_compile_error.cpp",
compile_stderr = matcher.contains_basic_regex("With transitive defines, this.*"),
deps = [":library"],
)

cc_build_error(
name = "with_extended_regex_matcher",
src = "cpp_compile_error.cpp",
compile_stderr = matcher.contains_extended_regex("With transitive defines, this.*"),
deps = [":library"],
)

build_test(
name = "build_test",
targets = [
":plain",
":with_substr_matcher",
":with_basic_regex_matcher",
":with_extended_regex_matcher",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
int main()
{

#ifdef MACRO_IN_DEFINES
static_assert(false, "With transitive defines, this error must show up");
#endif
return 0;
}

0 comments on commit 6920cd9

Please sign in to comment.