blob: b909f5948afa64ee4c0a16b782f2f250973d85dd [file] [log] [blame]
Colin Cross1496fb12024-09-09 16:44:10 -07001// 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
15package golang
16
17import (
18 "android/soong/android"
19 "github.com/google/blueprint/bootstrap"
20 "path/filepath"
21 "testing"
22)
23
24func 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 Crossb8533a82024-10-05 15:25:09 -070042 ctx.BottomUpBlueprint("bootstrap_deps", bootstrap.BootstrapDeps).UsesReverseDependencies()
Colin Cross1496fb12024-09-09 16:44:10 -070043 })
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}