diff options
author | 2020-06-11 13:25:36 -0400 | |
---|---|---|
committer | 2020-06-11 17:12:19 -0400 | |
commit | fc80fe7f2f08c99fd1f24dbe170116efc77f53a0 (patch) | |
tree | fadb92956db34912042ed07dd31f441e6280908d /rust/test_test.go | |
parent | 52481b445ba541d03d6bed20b7a97f245772f30c (diff) |
Make rust_test file output more similar to cc_test.
This changes the way the output filename is calculated for rust_test
binaries to be more similar to cc_test.
This also removes the option to define multiple test binaries in a
single rust_test module via the TestPerSrc mutator. Now each rust_test
module corresponds to a single test binary.
Bug: 158500462
Test: m -j pin-utils_tests_pin_utils
Test: m -j unicode-xid_device_tests_unicode_xid
Change-Id: I6e0f79dcb4e49fa49d6ebb36abeef67a9eb180a0
Diffstat (limited to 'rust/test_test.go')
-rw-r--r-- | rust/test_test.go | 38 |
1 files changed, 5 insertions, 33 deletions
diff --git a/rust/test_test.go b/rust/test_test.go index f131c6ebe..2382b1848 100644 --- a/rust/test_test.go +++ b/rust/test_test.go @@ -19,45 +19,17 @@ import ( "testing" ) -// Check if rust_test_host accepts multiple source files and applies --test flag. func TestRustTest(t *testing.T) { ctx := testRust(t, ` rust_test_host { name: "my_test", - srcs: ["foo.rs", "src/bar.rs"], - crate_name: "new_test", // not used for multiple source files - relative_install_path: "rust/my-test", - }`) - - for _, name := range []string{"foo", "bar"} { - testingModule := ctx.ModuleForTests("my_test", "linux_glibc_x86_64_"+name) - testingBuildParams := testingModule.Output(name) - rustcFlags := testingBuildParams.Args["rustcFlags"] - if !strings.Contains(rustcFlags, "--test") { - t.Errorf("%v missing --test flag, rustcFlags: %#v", name, rustcFlags) - } - outPath := "/my_test/linux_glibc_x86_64_" + name + "/" + name - if !strings.Contains(testingBuildParams.Output.String(), outPath) { - t.Errorf("wrong output: %v expect: %v", testingBuildParams.Output, outPath) - } - } -} - -// crate_name is output file name, when there is only one source file. -func TestRustTestSingleFile(t *testing.T) { - ctx := testRust(t, ` - rust_test_host { - name: "my-test", srcs: ["foo.rs"], - crate_name: "new_test", - relative_install_path: "my-pkg", }`) - name := "new_test" - testingModule := ctx.ModuleForTests("my-test", "linux_glibc_x86_64_"+name) - outPath := "/my-test/linux_glibc_x86_64_" + name + "/" + name - testingBuildParams := testingModule.Output(name) - if !strings.Contains(testingBuildParams.Output.String(), outPath) { - t.Errorf("wrong output: %v expect: %v", testingBuildParams.Output, outPath) + testingModule := ctx.ModuleForTests("my_test", "linux_glibc_x86_64") + expectedOut := "my_test/linux_glibc_x86_64/my_test" + outPath := testingModule.Output("my_test").Output.String() + if !strings.Contains(outPath, expectedOut) { + t.Errorf("wrong output path: %v; expected: %v", outPath, expectedOut) } } |