Skip to content

Commit 1a7f5b9

Browse files
committed
Attempt to fix windows ci
1 parent 949751c commit 1a7f5b9

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

test/unit/native_deps/native_deps_test.bzl

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ def _cdylib_has_native_libs_test_impl(ctx):
3030
assert_argv_contains_prefix_suffix(env, action, "-Lnative=", "/native_deps")
3131
assert_argv_contains(env, action, "--crate-type=cdylib")
3232
assert_argv_contains(env, action, "-lstatic=native_dep")
33-
assert_argv_contains(env, action, "-Clink-arg=-lnative_dep")
33+
native_link_arg = "-Clink-arg=native_dep.lib" if ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]) else "-Clink-arg=-lnative_dep"
34+
assert_argv_contains(env, action, native_link_arg)
3435
assert_argv_contains_prefix(env, action, "--codegen=linker=")
3536
return analysistest.end(env)
3637

@@ -41,7 +42,8 @@ def _staticlib_has_native_libs_test_impl(ctx):
4142
assert_argv_contains_prefix_suffix(env, action, "-Lnative=", "/native_deps")
4243
assert_argv_contains(env, action, "--crate-type=staticlib")
4344
assert_argv_contains(env, action, "-lstatic=native_dep")
44-
assert_argv_contains(env, action, "-Clink-arg=-lnative_dep")
45+
native_link_arg = "-Clink-arg=native_dep.lib" if ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]) else "-Clink-arg=-lnative_dep"
46+
assert_argv_contains(env, action, native_link_arg)
4547
assert_argv_contains_prefix(env, action, "--codegen=linker=")
4648
return analysistest.end(env)
4749

@@ -53,7 +55,8 @@ def _proc_macro_has_native_libs_test_impl(ctx):
5355
assert_argv_contains_prefix_suffix(env, action, "-Lnative=", "/native_deps")
5456
assert_argv_contains(env, action, "--crate-type=proc-macro")
5557
assert_argv_contains(env, action, "-lstatic=native_dep")
56-
assert_argv_contains(env, action, "-Clink-arg=-lnative_dep")
58+
native_link_arg = "-Clink-arg=native_dep.lib" if ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]) else "-Clink-arg=-lnative_dep"
59+
assert_argv_contains(env, action, native_link_arg)
5760
assert_argv_contains_prefix(env, action, "--codegen=linker=")
5861
return analysistest.end(env)
5962

@@ -63,7 +66,8 @@ def _bin_has_native_libs_test_impl(ctx):
6366
action = tut.actions[0]
6467
assert_argv_contains_prefix_suffix(env, action, "-Lnative=", "/native_deps")
6568
assert_argv_contains(env, action, "-lstatic=native_dep")
66-
assert_argv_contains(env, action, "-Clink-arg=-lnative_dep")
69+
native_link_arg = "-Clink-arg=native_dep.lib" if ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]) else "-Clink-arg=-lnative_dep"
70+
assert_argv_contains(env, action, native_link_arg)
6771
assert_argv_contains_prefix(env, action, "--codegen=linker=")
6872
return analysistest.end(env)
6973

@@ -140,10 +144,18 @@ def _cdylib_has_native_dep_and_alwayslink_test_impl(ctx):
140144
return analysistest.end(env)
141145

142146
rlib_has_no_native_libs_test = analysistest.make(_rlib_has_no_native_libs_test_impl)
143-
staticlib_has_native_libs_test = analysistest.make(_staticlib_has_native_libs_test_impl)
144-
cdylib_has_native_libs_test = analysistest.make(_cdylib_has_native_libs_test_impl)
145-
proc_macro_has_native_libs_test = analysistest.make(_proc_macro_has_native_libs_test_impl)
146-
bin_has_native_libs_test = analysistest.make(_bin_has_native_libs_test_impl)
147+
staticlib_has_native_libs_test = analysistest.make(_staticlib_has_native_libs_test_impl, attrs = {
148+
"_windows_constraint": attr.label(default = Label("@platforms//os:windows")),
149+
})
150+
cdylib_has_native_libs_test = analysistest.make(_cdylib_has_native_libs_test_impl, attrs = {
151+
"_windows_constraint": attr.label(default = Label("@platforms//os:windows")),
152+
})
153+
proc_macro_has_native_libs_test = analysistest.make(_proc_macro_has_native_libs_test_impl, attrs = {
154+
"_windows_constraint": attr.label(default = Label("@platforms//os:windows")),
155+
})
156+
bin_has_native_libs_test = analysistest.make(_bin_has_native_libs_test_impl, attrs = {
157+
"_windows_constraint": attr.label(default = Label("@platforms//os:windows")),
158+
})
147159
bin_has_native_dep_and_alwayslink_test = analysistest.make(_bin_has_native_dep_and_alwayslink_test_impl, attrs = {
148160
"_macos_constraint": attr.label(default = Label("@platforms//os:macos")),
149161
"_windows_constraint": attr.label(default = Label("@platforms//os:windows")),

test/unit/proc_macro/leaks_deps/proc_macro_does_not_leak_deps.bzl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,22 @@ def _proc_macro_does_not_leak_deps_impl(ctx):
2222
asserts.equals(env, 0, len(proc_macro_dep_inputs))
2323
asserts.equals(env, 0, len(proc_macro_dep_args))
2424

25+
link_arg_prefix = "-Clink-arg=native" if ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstrainValueInfo]) else "-Clink-arg=-lnative"
26+
2527
# Our test target depends on proc_macro_dep:native directly, as well as transitively through the
2628
# proc_macro. The proc_macro should not leak its dependency, so we should only get the "native"
2729
# library once on the command line.
28-
native_deps = [arg for arg in rustc_action.argv if arg.startswith("-Clink-arg=-lnative")]
30+
native_deps = [arg for arg in rustc_action.argv if arg.startswith(link_arg_prefix)]
2931
asserts.equals(env, 1, len(native_deps))
3032

3133
return analysistest.end(env)
3234

33-
proc_macro_does_not_leak_deps_test = analysistest.make(_proc_macro_does_not_leak_deps_impl)
35+
proc_macro_does_not_leak_deps_test = analysistest.make(
36+
_proc_macro_does_not_leak_deps_impl,
37+
attrs = {
38+
"_windows_constraint": attr.label(default = Label("@platforms//os:windows")),
39+
},
40+
)
3441

3542
def _proc_macro_does_not_leak_deps_test():
3643
rust_proc_macro(

0 commit comments

Comments
 (0)