Colin Cross | 1496fb1 | 2024-09-09 16:44:10 -0700 | [diff] [blame] | 1 | // Copyright 2024 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 | |
| 15 | package golang |
| 16 | |
| 17 | import ( |
| 18 | "android/soong/android" |
| 19 | "github.com/google/blueprint/bootstrap" |
| 20 | "path/filepath" |
| 21 | "testing" |
| 22 | ) |
| 23 | |
| 24 | func TestGolang(t *testing.T) { |
| 25 | bp := ` |
| 26 | bootstrap_go_package { |
| 27 | name: "gopkg", |
| 28 | pkgPath: "test/pkg", |
| 29 | } |
| 30 | |
| 31 | blueprint_go_binary { |
| 32 | name: "gobin", |
| 33 | deps: ["gopkg"], |
| 34 | } |
| 35 | ` |
| 36 | |
| 37 | result := android.GroupFixturePreparers( |
| 38 | android.PrepareForTestWithArchMutator, |
| 39 | android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) { |
| 40 | RegisterGoModuleTypes(ctx) |
| 41 | ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { |
Colin Cross | b8533a8 | 2024-10-05 15:25:09 -0700 | [diff] [blame^] | 42 | ctx.BottomUpBlueprint("bootstrap_deps", bootstrap.BootstrapDeps).UsesReverseDependencies() |
Colin Cross | 1496fb1 | 2024-09-09 16:44:10 -0700 | [diff] [blame] | 43 | }) |
| 44 | }), |
| 45 | ).RunTestWithBp(t, bp) |
| 46 | |
| 47 | bin := result.ModuleForTests("gobin", result.Config.BuildOSTarget.String()) |
| 48 | |
| 49 | expected := filepath.Join("out/soong/host", result.Config.PrebuiltOS(), "bin/go/gobin/obj/gobin") |
| 50 | android.AssertPathsRelativeToTopEquals(t, "output files", []string{expected}, bin.OutputFiles(result.TestContext, t, "")) |
| 51 | } |