-
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.
add build failure example with
ctest
(#29)
Change-Id: I49f2a9991686715dda2e529b19206909ec1a7c79
- Loading branch information
Showing
14 changed files
with
172 additions
and
47 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,11 @@ | ||
#include "skytest/skytest.hpp" | ||
|
||
auto main() -> int | ||
{ | ||
using namespace skytest::literals; | ||
using ::skytest::expect; | ||
using ::skytest::lt; | ||
|
||
static auto n = 0; | ||
"read non-const"_ctest = [] { return expect(lt(0, n)); }; | ||
} |
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 @@ | ||
external/skytest/src/detail/test_style.hpp:43:27: error: the value of 'n' is not usable in a constant expression | ||
43 | static constexpr auto value = std::optional<bool>{bool{F{}()}}; | ||
| ^~~~~ | ||
ctest_fail.cpp:9:15: note: 'int n' is not const | ||
9 | static auto n = 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,43 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
source $(find -L . -path \*/rules/prelude.sh -print -quit) | ||
prelude "${BASH_SOURCE[0]}" | ||
|
||
cp $(find -L . -path \*/example/ctest_fail.cpp -print -quit) . | ||
|
||
cat >>BUILD.bazel <<EOF | ||
cc_binary( | ||
name = "ctest_fail", | ||
srcs = ["ctest_fail.cpp"], | ||
copts = [ | ||
"-Werror", | ||
"-Wall", | ||
"-Wextra", | ||
], | ||
deps = [":external_skytest"], | ||
) | ||
EOF | ||
|
||
startup_opts=( | ||
--output_user_root=/tmp/bazel | ||
--output_base=/tmp/bazel/output | ||
) | ||
build_opts=( | ||
--symlink_prefix=/ | ||
--noshow_progress | ||
--ui_event_filters=-info,-stdout | ||
--color=no | ||
) | ||
|
||
start="error: the value of 'n' is not usable in a constant expression" | ||
stop="Target .*:ctest_fail failed to build" | ||
|
||
bazel \ | ||
${startup_opts[@]} \ | ||
build \ | ||
${build_opts[@]} \ | ||
//:ctest_fail 2>&1 \ | ||
| sed -n "/$start/,/$stop/ p" `# only print from start to stop` \ | ||
| sed '$d' # remove the stop line | ||
|
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 |
---|---|---|
@@ -1,4 +1,36 @@ | ||
load("@bazel_skylib//rules:expand_template.bzl", "expand_template") | ||
load( | ||
"@local_config_info//:defs.bzl", | ||
"BAZEL_BIN", | ||
"BAZEL_EXTERNAL_DIR", | ||
"BAZEL_WORKSPACE_ROOT", | ||
"XDG_CACHE_HOME", | ||
) | ||
|
||
exports_files( | ||
["skytest_test.sh"], | ||
visibility = ["//test:__pkg__"], | ||
) | ||
|
||
expand_template( | ||
name = "gen_prelude_sh", | ||
out = "prelude.sh", | ||
substitutions = { | ||
"$BAZEL_BIN": BAZEL_BIN, | ||
"$BAZEL_EXTERNAL_DIR": BAZEL_EXTERNAL_DIR, | ||
"$BAZEL_WORKSPACE_ROOT": BAZEL_WORKSPACE_ROOT, | ||
"$XDG_CACHE_HOME": XDG_CACHE_HOME, | ||
}, | ||
tags = ["manual"], | ||
template = "prelude.sh.tmpl", | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
sh_library( | ||
name = "prelude_sh", | ||
srcs = ["prelude.sh"], | ||
visibility = [ | ||
"//example:__pkg__", | ||
"//test:__pkg__", | ||
], | ||
) |
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
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
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