1// 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 21func testNinjaDepsSingletonFactory() Singleton { 22 return testNinjaDepsSingleton{} 23} 24 25type testNinjaDepsSingleton struct{} 26 27func (testNinjaDepsSingleton) GenerateBuildActions(ctx SingletonContext) { 28 ctx.Config().addNinjaFileDeps("foo") 29} 30 31func TestNinjaDeps(t *testing.T) { 32 result := GroupFixturePreparers( 33 FixtureRegisterWithContext(func(ctx RegistrationContext) { 34 ctx.RegisterSingletonType("test_ninja_deps_singleton", testNinjaDepsSingletonFactory) 35 ctx.RegisterSingletonType("ninja_deps_singleton", ninjaDepsSingletonFactory) 36 }), 37 ).RunTest(t) 38 39 // Verify that the ninja file has a dependency on the test_ninja_deps directory. 40 if g, w := result.NinjaDeps, "foo"; !InList(w, g) { 41 t.Errorf("expected %q in %q", w, g) 42 } 43} 44