blob: 314417362ca3e4e80e5e3a2f96c4a64cf5c0bb4d [file] [log] [blame]
Thiébaud Weksteen92f703b2020-06-22 13:28:02 +02001// Copyright 2020 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 "testing"
19)
20
21func TestClippy(t *testing.T) {
22 ctx := testRust(t, `
23 rust_library {
24 name: "libfoo",
25 srcs: ["foo.rs"],
26 crate_name: "foo",
27 }
28 rust_library {
29 name: "libfoobar",
30 srcs: ["foo.rs"],
31 crate_name: "foobar",
32 clippy: false,
33 }`)
34
Matthew Maurer2ae05132020-06-23 14:28:53 -070035 ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_dylib").Output("libfoo.dylib.so")
36 fooClippy := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_dylib").MaybeRule("clippy")
Thiébaud Weksteen92f703b2020-06-22 13:28:02 +020037 if fooClippy.Rule.String() != "android/soong/rust.clippy" {
38 t.Errorf("Clippy output (default) for libfoo was not generated: %+v", fooClippy)
39 }
40
Matthew Maurer2ae05132020-06-23 14:28:53 -070041 ctx.ModuleForTests("libfoobar", "android_arm64_armv8-a_dylib").Output("libfoobar.dylib.so")
42 foobarClippy := ctx.ModuleForTests("libfoobar", "android_arm64_armv8-a_dylib").MaybeRule("clippy")
Thiébaud Weksteen92f703b2020-06-22 13:28:02 +020043 if foobarClippy.Rule != nil {
44 t.Errorf("Clippy output for libfoobar is not empty")
45 }
46}