Skip to content

Commit

Permalink
add a test: tests/cc/cpp_compile_error_with_local_defines
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyawk committed Apr 7, 2024
1 parent 6546b0e commit 7a8a7a5
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/cc/cpp_compile_error_with_local_defines/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
load("//lang/cc:defs.bzl", "cc_build_error")
load("//matcher:defs.bzl", "matcher")
load("@bazel_skylib//rules:build_test.bzl", "build_test")

cc_build_error(
name = "plain",
src = "cpp_compile_error.cpp",
local_defines = ["MACRO_IN_LOCAL_DEFINES"],
)

cc_build_error(
name = "with_substr_matcher",
src = "cpp_compile_error.cpp",
compile_stderr = matcher.has_substr("With local_defines, "),
local_defines = ["MACRO_IN_LOCAL_DEFINES"],
)

cc_build_error(
name = "with_basic_regex_matcher",
src = "cpp_compile_error.cpp",
compile_stderr = matcher.contains_basic_regex("With local_defines, this.*"),
local_defines = ["MACRO_IN_LOCAL_DEFINES"],
)

cc_build_error(
name = "with_extended_regex_matcher",
src = "cpp_compile_error.cpp",
compile_stderr = matcher.contains_extended_regex("With local_defines, this.*"),
local_defines = ["MACRO_IN_LOCAL_DEFINES"],
)

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_LOCAL_DEFINES
static_assert(false, "With local_defines, this error must show up");
#endif
return 0;
}

0 comments on commit 7a8a7a5

Please sign in to comment.