blob: d6afcc0dec076b5086766ce99082d18db0859b60 [file] [log] [blame]
Colin Cross12129292020-10-29 18:23:58 -07001// Copyright 2020 Google Inc. All rights reserved.
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 android
16
17import (
18 "testing"
19)
20
Colin Cross12129292020-10-29 18:23:58 -070021func testNinjaDepsSingletonFactory() Singleton {
22 return testNinjaDepsSingleton{}
23}
24
25type testNinjaDepsSingleton struct{}
26
27func (testNinjaDepsSingleton) GenerateBuildActions(ctx SingletonContext) {
Colin Cross662d6142022-11-03 20:38:01 -070028 ctx.Config().addNinjaFileDeps("foo")
Colin Cross12129292020-10-29 18:23:58 -070029}
30
31func TestNinjaDeps(t *testing.T) {
Paul Duffin30ac3e72021-03-20 00:36:14 +000032 result := GroupFixturePreparers(
Paul Duffind9ec7d22021-03-16 23:57:12 +000033 FixtureRegisterWithContext(func(ctx RegistrationContext) {
34 ctx.RegisterSingletonType("test_ninja_deps_singleton", testNinjaDepsSingletonFactory)
35 ctx.RegisterSingletonType("ninja_deps_singleton", ninjaDepsSingletonFactory)
36 }),
Paul Duffin30ac3e72021-03-20 00:36:14 +000037 ).RunTest(t)
Colin Cross12129292020-10-29 18:23:58 -070038
39 // Verify that the ninja file has a dependency on the test_ninja_deps directory.
Colin Cross662d6142022-11-03 20:38:01 -070040 if g, w := result.NinjaDeps, "foo"; !InList(w, g) {
Colin Cross12129292020-10-29 18:23:58 -070041 t.Errorf("expected %q in %q", w, g)
42 }
43}