diff options
author | Ivan Lozano <ivanlozano@google.com> | 2019-10-31 19:38:29 -0700 |
---|---|---|
committer | Ivan Lozano <ivanlozano@google.com> | 2019-11-04 09:20:08 -0800 |
commit | ad8b18b87260a83aeadb28d637f77474158fcdb1 (patch) | |
tree | 0362797ca4b2cf0d34eb14ad3cfd0ed61ad67dc0 /rust/rust_test.go | |
parent | 5d0b3b7195e35199f48bc8cd685f0b5786487cfe (diff) |
Enforce correct rust library file names.
rustc expects libraries and proc_macro filenames to conform to
a particular format, alphanumeric with underscores and lib${crate_name}.*.
Enforce this with a check when getStem() is called.
This makes the crate_name property required for proc_macros and
libraries. This also removes the notion of a default crate name derived
from the module name. It's not needed for binaries, so this won't impact
them.
Bug: 143579265
Test: m -j crosvm.experimental
Change-Id: I2770cf7d02dd4291c3d240d58d242b940098dcee
Diffstat (limited to 'rust/rust_test.go')
-rw-r--r-- | rust/rust_test.go | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/rust/rust_test.go b/rust/rust_test.go index eb04e7257..599af098c 100644 --- a/rust/rust_test.go +++ b/rust/rust_test.go @@ -129,44 +129,33 @@ func TestLinkPathFromFilePath(t *testing.T) { } } -// Test default crate names from module names are generated correctly. -func TestDefaultCrateName(t *testing.T) { - ctx := testRust(t, ` - rust_library_host_dylib { - name: "fizz-buzz", - srcs: ["foo.rs"], - }`) - module := ctx.ModuleForTests("fizz-buzz", "linux_glibc_x86_64_dylib").Module().(*Module) - crateName := module.CrateName() - expectedResult := "fizz_buzz" - - if crateName != expectedResult { - t.Errorf("CrateName() returned the wrong default crate name; expected '%#v', got '%#v'", expectedResult, crateName) - } -} - // Test to make sure dependencies are being picked up correctly. func TestDepsTracking(t *testing.T) { ctx := testRust(t, ` rust_library_host_static { name: "libstatic", srcs: ["foo.rs"], + crate_name: "static", } rust_library_host_shared { name: "libshared", srcs: ["foo.rs"], + crate_name: "shared", } rust_library_host_dylib { name: "libdylib", srcs: ["foo.rs"], + crate_name: "dylib", } rust_library_host_rlib { name: "librlib", srcs: ["foo.rs"], + crate_name: "rlib", } rust_proc_macro { name: "libpm", srcs: ["foo.rs"], + crate_name: "pm", } rust_binary_host { name: "fizz-buzz", @@ -208,11 +197,13 @@ func TestProcMacroDeviceDeps(t *testing.T) { rust_library_host_rlib { name: "libbar", srcs: ["foo.rs"], + crate_name: "bar", } rust_proc_macro { name: "libpm", rlibs: ["libbar"], srcs: ["foo.rs"], + crate_name: "pm", } rust_binary { name: "fizz-buzz", |