-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly parse a space inside command-line option (#96)
- Loading branch information
Showing
6 changed files
with
160 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
load("@bazel_skylib//rules:build_test.bzl", "build_test") | ||
load("//matcher:defs.bzl", "matcher") | ||
load("//tests/cc:utils.bzl", "check_build_and_test") | ||
|
||
check_build_and_test( | ||
name = "using_copts_plain", | ||
src = "c_compile_error.c", | ||
copts = ['-DCAUSE_COMPILATION_ERROR=static_assert(0, "Compile error message for c_compile_error.c")'], | ||
) | ||
|
||
check_build_and_test( | ||
name = "using_copts_with_substr_matcher", | ||
src = "c_compile_error.c", | ||
compile_stderr = matcher.has_substr("for c_compile_error.c"), | ||
copts = ['-DCAUSE_COMPILATION_ERROR=static_assert(0, "Compile error message for c_compile_error.c")'], | ||
) | ||
|
||
check_build_and_test( | ||
name = "using_copts_with_basic_regex_matcher", | ||
src = "c_compile_error.c", | ||
compile_stderr = matcher.contains_basic_regex(r"for[[:space:]]c_compile_error\.\(c\|cxx\)"), | ||
copts = ['-DCAUSE_COMPILATION_ERROR=static_assert(0, "Compile error message for c_compile_error.c")'], | ||
) | ||
|
||
check_build_and_test( | ||
name = "using_copts_with_extended_regex_matcher", | ||
src = "c_compile_error.c", | ||
compile_stderr = matcher.contains_extended_regex(r"for[[:space:]]c_compile_error\.(c|cxx)"), | ||
copts = ['-DCAUSE_COMPILATION_ERROR=static_assert(0, "Compile error message for c_compile_error.c")'], | ||
) | ||
|
||
check_build_and_test( | ||
name = "using_local_defines_plain", | ||
src = "c_compile_error.c", | ||
local_defines = ['CAUSE_COMPILATION_ERROR=static_assert(0, "Compile error message for c_compile_error.c")'], | ||
) | ||
|
||
check_build_and_test( | ||
name = "using_local_defines_with_substr_matcher", | ||
src = "c_compile_error.c", | ||
compile_stderr = matcher.has_substr("for c_compile_error.c"), | ||
local_defines = ['CAUSE_COMPILATION_ERROR=static_assert(0, "Compile error message for c_compile_error.c")'], | ||
) | ||
|
||
check_build_and_test( | ||
name = "using_local_defines_with_basic_regex_matcher", | ||
src = "c_compile_error.c", | ||
compile_stderr = matcher.contains_basic_regex(r"for[[:space:]]c_compile_error\.\(c\|cxx\)"), | ||
local_defines = ['CAUSE_COMPILATION_ERROR=static_assert(0, "Compile error message for c_compile_error.c")'], | ||
) | ||
|
||
check_build_and_test( | ||
name = "using_local_defines_with_extended_regex_matcher", | ||
src = "c_compile_error.c", | ||
compile_stderr = matcher.contains_extended_regex(r"for[[:space:]]c_compile_error\.(c|cxx)"), | ||
local_defines = ['CAUSE_COMPILATION_ERROR=static_assert(0, "Compile error message for c_compile_error.c")'], | ||
) | ||
|
||
build_test( | ||
name = "build_test", | ||
targets = [ | ||
":using_copts_plain", | ||
":using_copts_with_substr_matcher", | ||
":using_copts_with_basic_regex_matcher", | ||
":using_copts_with_extended_regex_matcher", | ||
":using_local_defines_plain", | ||
":using_local_defines_with_substr_matcher", | ||
":using_local_defines_with_basic_regex_matcher", | ||
":using_local_defines_with_extended_regex_matcher", | ||
], | ||
) |
6 changes: 6 additions & 0 deletions
6
tests/cc/c_compile_error_options_with_space/c_compile_error.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <assert.h> | ||
|
||
int main() { | ||
CAUSE_COMPILATION_ERROR; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
load("@bazel_skylib//rules:build_test.bzl", "build_test") | ||
load("//matcher:defs.bzl", "matcher") | ||
load("//tests/cc:utils.bzl", "check_build_and_test") | ||
|
||
check_build_and_test( | ||
name = "using_copts_plain", | ||
src = "cpp_compile_error.cpp", | ||
copts = ['-DCAUSE_COMPILATION_ERROR=static_assert(false, "Compile error message for cpp_compile_error.cpp")'], | ||
) | ||
|
||
check_build_and_test( | ||
name = "using_copts_with_substr_matcher", | ||
src = "cpp_compile_error.cpp", | ||
compile_stderr = matcher.has_substr("for cpp_compile_error.cpp"), | ||
copts = ['-DCAUSE_COMPILATION_ERROR=static_assert(false, "Compile error message for cpp_compile_error.cpp")'], | ||
) | ||
|
||
check_build_and_test( | ||
name = "using_copts_with_basic_regex_matcher", | ||
src = "cpp_compile_error.cpp", | ||
compile_stderr = matcher.contains_basic_regex(r"for[[:space:]]cpp_compile_error\.\(cpp\|cxx\)"), | ||
copts = ['-DCAUSE_COMPILATION_ERROR=static_assert(false, "Compile error message for cpp_compile_error.cpp")'], | ||
) | ||
|
||
check_build_and_test( | ||
name = "using_copts_with_extended_regex_matcher", | ||
src = "cpp_compile_error.cpp", | ||
compile_stderr = matcher.contains_extended_regex(r"for[[:space:]]cpp_compile_error\.(cpp|cxx)"), | ||
copts = ['-DCAUSE_COMPILATION_ERROR=static_assert(false, "Compile error message for cpp_compile_error.cpp")'], | ||
) | ||
|
||
check_build_and_test( | ||
name = "using_local_defines_plain", | ||
src = "cpp_compile_error.cpp", | ||
local_defines = ['CAUSE_COMPILATION_ERROR=static_assert(false, "Compile error message for cpp_compile_error.cpp")'], | ||
) | ||
|
||
check_build_and_test( | ||
name = "using_local_defines_with_substr_matcher", | ||
src = "cpp_compile_error.cpp", | ||
compile_stderr = matcher.has_substr("for cpp_compile_error.cpp"), | ||
local_defines = ['CAUSE_COMPILATION_ERROR=static_assert(false, "Compile error message for cpp_compile_error.cpp")'], | ||
) | ||
|
||
check_build_and_test( | ||
name = "using_local_defines_with_basic_regex_matcher", | ||
src = "cpp_compile_error.cpp", | ||
compile_stderr = matcher.contains_basic_regex(r"for[[:space:]]cpp_compile_error\.\(cpp\|cxx\)"), | ||
local_defines = ['CAUSE_COMPILATION_ERROR=static_assert(false, "Compile error message for cpp_compile_error.cpp")'], | ||
) | ||
|
||
check_build_and_test( | ||
name = "using_local_defines_with_extended_regex_matcher", | ||
src = "cpp_compile_error.cpp", | ||
compile_stderr = matcher.contains_extended_regex(r"for[[:space:]]cpp_compile_error\.(cpp|cxx)"), | ||
local_defines = ['CAUSE_COMPILATION_ERROR=static_assert(false, "Compile error message for cpp_compile_error.cpp")'], | ||
) | ||
|
||
build_test( | ||
name = "build_test", | ||
targets = [ | ||
":using_copts_plain", | ||
":using_copts_with_substr_matcher", | ||
":using_copts_with_basic_regex_matcher", | ||
":using_copts_with_extended_regex_matcher", | ||
":using_local_defines_plain", | ||
":using_local_defines_with_substr_matcher", | ||
":using_local_defines_with_basic_regex_matcher", | ||
":using_local_defines_with_extended_regex_matcher", | ||
], | ||
) |
4 changes: 4 additions & 0 deletions
4
tests/cc/cpp_compile_error_options_with_space/cpp_compile_error.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
int main() { | ||
CAUSE_COMPILATION_ERROR; | ||
return 0; | ||
} |