Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cargo_build_script: Add regression test for revert #2925 #2936

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions test/cargo_build_script/cc_args_and_env/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ load(
"isystem_absolute_test",
"isystem_relative_test",
"sysroot_absolute_test",
"sysroot_next_absolute_test",
"sysroot_relative_test",
)

sysroot_relative_test(name = "sysroot_relative_test")

sysroot_absolute_test(name = "sysroot_absolute_test")

sysroot_next_absolute_test(name = "sysroot_next_absolute_test")

isystem_relative_test(name = "isystem_relative_test")

isystem_absolute_test(name = "isystem_absolute_test")
17 changes: 14 additions & 3 deletions test/cargo_build_script/cc_args_and_env/cc_args_and_env_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _cc_args_and_env_analysis_test_impl(ctx):
env = analysistest.begin(ctx)
tut = analysistest.target_under_test(env)
cargo_action = tut[DepActionsInfo].actions[0]
cflags = cargo_action.env["CFLAGS"]
cflags = cargo_action.env["CFLAGS"].split(" ")
for flag in ctx.attr.expected_cflags:
asserts.true(
env,
Expand Down Expand Up @@ -173,6 +173,17 @@ def sysroot_absolute_test(name):
expected_cflags = ["--sysroot=/test/absolute/sysroot"],
)

def sysroot_next_absolute_test(name):
cargo_build_script_with_extra_cc_compile_flags(
name = "%s/cargo_build_script" % name,
extra_cc_compile_flags = ["--sysroot=/test/absolute/sysroot", "test/relative/another"],
)
cc_args_and_env_analysis_test(
name = name,
target_under_test = "%s/cargo_build_script" % name,
expected_cflags = ["--sysroot=/test/absolute/sysroot", "test/relative/another"],
)

def isystem_relative_test(name):
cargo_build_script_with_extra_cc_compile_flags(
name = "%s/cargo_build_script" % name,
Expand All @@ -181,7 +192,7 @@ def isystem_relative_test(name):
cc_args_and_env_analysis_test(
name = name,
target_under_test = "%s/cargo_build_script" % name,
expected_cflags = ["-isystem ${pwd}/test/relative/path"],
expected_cflags = ["-isystem", "${pwd}/test/relative/path"],
)

def isystem_absolute_test(name):
Expand All @@ -192,5 +203,5 @@ def isystem_absolute_test(name):
cc_args_and_env_analysis_test(
name = name,
target_under_test = "%s/cargo_build_script" % name,
expected_cflags = ["-isystem /test/absolute/path"],
expected_cflags = ["-isystem", "/test/absolute/path"],
)
Loading