blob: aa4c3c8cb64db02f3adb0c94dd68d9be51879844 [file] [log] [blame]
Chih-Hung Hsieha5f22ed2019-10-24 20:47:54 -07001// Copyright 2019 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package rust
16
17import (
18 "strings"
19 "testing"
20)
21
22// Check if rust_test_host accepts multiple source files and applies --test flag.
23func TestRustTest(t *testing.T) {
24 ctx := testRust(t, `
25 rust_test_host {
26 name: "my_test",
27 srcs: ["foo.rs", "src/bar.rs"],
28 relative_install_path: "rust/my-test",
29 }`)
30
31 for _, name := range []string{"foo", "bar"} {
32 testingModule := ctx.ModuleForTests("my_test", "linux_glibc_x86_64_"+name)
33 testingBuildParams := testingModule.Output(name)
34 rustcFlags := testingBuildParams.Args["rustcFlags"]
35 if !strings.Contains(rustcFlags, "--test") {
36 t.Errorf("%v missing --test flag, rustcFlags: %#v", name, rustcFlags)
37 }
38 outPath := "/my_test/linux_glibc_x86_64_" + name + "/" + name
39 if !strings.Contains(testingBuildParams.Output.String(), outPath) {
40 t.Errorf("wrong output: %v expect: %v", testingBuildParams.Output, outPath)
41 }
42 }
43}