Skip to content

Commit 41d8456

Browse files
committed
native_deps: give up on testing cc_binary using rust_library
This only works on clang today, and can only work on clang for the near-term. It's not clear how to write a clang-only test in this case, so we just give up for now. "I promise it works!" etc
1 parent 6db880f commit 41d8456

File tree

5 files changed

+8
-61
lines changed

5 files changed

+8
-61
lines changed

test/unit/native_deps/alloc_shims.c

Lines changed: 0 additions & 24 deletions
This file was deleted.

test/unit/native_deps/cc_bin_uses_rust_library.cc

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/unit/native_deps/native_deps_test.bzl

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Unittests for rust rules."""
22

33
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts", "unittest")
4-
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
4+
load("@rules_cc//cc:defs.bzl", "cc_library")
55
load("//rust:defs.bzl", "rust_binary", "rust_library", "rust_proc_macro", "rust_shared_library", "rust_static_library")
66

77
def _assert_argv_contains_not(env, action, flag):
@@ -227,25 +227,6 @@ def _native_dep_test():
227227
deps = [":native_dep", ":alwayslink"],
228228
)
229229

230-
cc_library(
231-
name = "alloc_shims",
232-
srcs = ["alloc_shims.c"],
233-
)
234-
235-
rust_library(
236-
name = "print_hi_rust",
237-
srcs = ["print_hi_rust.rs"],
238-
)
239-
240-
cc_binary(
241-
name = "cc_bin_uses_rust_library",
242-
srcs = ["cc_bin_uses_rust_library.cc"],
243-
deps = [
244-
":print_hi_rust",
245-
":alloc_shims", # TODO: this should come in through the toolchain configuration
246-
],
247-
)
248-
249230
rlib_has_no_native_libs_test(
250231
name = "rlib_has_no_native_libs_test",
251232
target_under_test = ":rlib_has_no_native_dep",

test/unit/native_deps/print_hi_rust.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

test/unit/stdlib_ordering/stdlib_ordering.bzl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts", "unittest")
1+
"""Unittest to verify ordering of rust stdlib in rust_library() CcInfo"""
2+
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
23
load("//rust:defs.bzl", "rust_library")
34

45
def _categorize_library(name):
@@ -13,11 +14,11 @@ def _categorize_library(name):
1314
return "compiler_builtins"
1415
return "other"
1516

16-
def _dedup_preserving_order(l):
17+
def _dedup_preserving_order(list):
1718
"""Given a list, deduplicate its elements preserving order."""
1819
r = []
1920
seen = {}
20-
for e in l:
21+
for e in list:
2122
if e in seen:
2223
continue
2324
seen[e] = 1
@@ -27,9 +28,9 @@ def _dedup_preserving_order(l):
2728
def _libstd_ordering_test_impl(ctx):
2829
env = analysistest.begin(ctx)
2930
tut = analysistest.target_under_test(env)
30-
libs = [l.static_library for li in tut[CcInfo].linking_context.linker_inputs.to_list() for l in li.libraries]
31-
rlibs = [_categorize_library(l.basename) for l in libs if ".rlib" in l.basename]
32-
set_to_check = _dedup_preserving_order([l for l in rlibs if l != "other"])
31+
libs = [lib.static_library for li in tut[CcInfo].linking_context.linker_inputs.to_list() for lib in li.libraries]
32+
rlibs = [_categorize_library(lib.basename) for lib in libs if ".rlib" in lib.basename]
33+
set_to_check = _dedup_preserving_order([lib for lib in rlibs if lib != "other"])
3334
asserts.equals(env, ["std", "core", "compiler_builtins", "alloc"], set_to_check)
3435
return analysistest.end(env)
3536

0 commit comments

Comments
 (0)