2019-05-29 23:40:35 +02:00
|
|
|
// Copyright 2015 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package android
|
|
|
|
|
2019-08-23 04:18:57 +02:00
|
|
|
import (
|
2021-11-09 22:17:44 +01:00
|
|
|
"path/filepath"
|
|
|
|
"runtime"
|
2019-08-23 04:18:57 +02:00
|
|
|
"testing"
|
2024-01-18 21:12:02 +01:00
|
|
|
|
|
|
|
"github.com/google/blueprint"
|
2019-08-23 04:18:57 +02:00
|
|
|
)
|
2019-05-29 23:40:35 +02:00
|
|
|
|
|
|
|
func TestSrcIsModule(t *testing.T) {
|
|
|
|
type args struct {
|
|
|
|
s string
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
args args
|
|
|
|
wantModule string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "file",
|
|
|
|
args: args{
|
|
|
|
s: "foo",
|
|
|
|
},
|
|
|
|
wantModule: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "module",
|
|
|
|
args: args{
|
|
|
|
s: ":foo",
|
|
|
|
},
|
|
|
|
wantModule: "foo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "tag",
|
|
|
|
args: args{
|
|
|
|
s: ":foo{.bar}",
|
|
|
|
},
|
|
|
|
wantModule: "foo{.bar}",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "extra colon",
|
|
|
|
args: args{
|
|
|
|
s: ":foo:bar",
|
|
|
|
},
|
|
|
|
wantModule: "foo:bar",
|
|
|
|
},
|
2021-07-12 21:12:12 +02:00
|
|
|
{
|
|
|
|
name: "fully qualified",
|
|
|
|
args: args{
|
|
|
|
s: "//foo:bar",
|
|
|
|
},
|
|
|
|
wantModule: "//foo:bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "fully qualified with tag",
|
|
|
|
args: args{
|
|
|
|
s: "//foo:bar{.tag}",
|
|
|
|
},
|
|
|
|
wantModule: "//foo:bar{.tag}",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "invalid unqualified name",
|
|
|
|
args: args{
|
|
|
|
s: ":foo/bar",
|
|
|
|
},
|
|
|
|
wantModule: "",
|
|
|
|
},
|
2019-05-29 23:40:35 +02:00
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
if gotModule := SrcIsModule(tt.args.s); gotModule != tt.wantModule {
|
|
|
|
t.Errorf("SrcIsModule() = %v, want %v", gotModule, tt.wantModule)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSrcIsModuleWithTag(t *testing.T) {
|
|
|
|
type args struct {
|
|
|
|
s string
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
args args
|
|
|
|
wantModule string
|
|
|
|
wantTag string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "file",
|
|
|
|
args: args{
|
|
|
|
s: "foo",
|
|
|
|
},
|
|
|
|
wantModule: "",
|
|
|
|
wantTag: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "module",
|
|
|
|
args: args{
|
|
|
|
s: ":foo",
|
|
|
|
},
|
|
|
|
wantModule: "foo",
|
|
|
|
wantTag: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "tag",
|
|
|
|
args: args{
|
|
|
|
s: ":foo{.bar}",
|
|
|
|
},
|
|
|
|
wantModule: "foo",
|
|
|
|
wantTag: ".bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "empty tag",
|
|
|
|
args: args{
|
|
|
|
s: ":foo{}",
|
|
|
|
},
|
|
|
|
wantModule: "foo",
|
|
|
|
wantTag: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "extra colon",
|
|
|
|
args: args{
|
|
|
|
s: ":foo:bar",
|
|
|
|
},
|
|
|
|
wantModule: "foo:bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "invalid tag",
|
|
|
|
args: args{
|
|
|
|
s: ":foo{.bar",
|
|
|
|
},
|
|
|
|
wantModule: "foo{.bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "invalid tag 2",
|
|
|
|
args: args{
|
|
|
|
s: ":foo.bar}",
|
|
|
|
},
|
|
|
|
wantModule: "foo.bar}",
|
|
|
|
},
|
2021-07-12 21:12:12 +02:00
|
|
|
{
|
|
|
|
name: "fully qualified",
|
|
|
|
args: args{
|
|
|
|
s: "//foo:bar",
|
|
|
|
},
|
|
|
|
wantModule: "//foo:bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "fully qualified with tag",
|
|
|
|
args: args{
|
|
|
|
s: "//foo:bar{.tag}",
|
|
|
|
},
|
|
|
|
wantModule: "//foo:bar",
|
|
|
|
wantTag: ".tag",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "invalid unqualified name",
|
|
|
|
args: args{
|
|
|
|
s: ":foo/bar",
|
|
|
|
},
|
|
|
|
wantModule: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "invalid unqualified name with tag",
|
|
|
|
args: args{
|
|
|
|
s: ":foo/bar{.tag}",
|
|
|
|
},
|
|
|
|
wantModule: "",
|
|
|
|
},
|
2019-05-29 23:40:35 +02:00
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
gotModule, gotTag := SrcIsModuleWithTag(tt.args.s)
|
|
|
|
if gotModule != tt.wantModule {
|
|
|
|
t.Errorf("SrcIsModuleWithTag() gotModule = %v, want %v", gotModule, tt.wantModule)
|
|
|
|
}
|
|
|
|
if gotTag != tt.wantTag {
|
|
|
|
t.Errorf("SrcIsModuleWithTag() gotTag = %v, want %v", gotTag, tt.wantTag)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2019-08-23 04:18:57 +02:00
|
|
|
|
|
|
|
type depsModule struct {
|
|
|
|
ModuleBase
|
|
|
|
props struct {
|
|
|
|
Deps []string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *depsModule) GenerateAndroidBuildActions(ctx ModuleContext) {
|
2021-11-09 22:17:44 +01:00
|
|
|
outputFile := PathForModuleOut(ctx, ctx.ModuleName())
|
|
|
|
ctx.Build(pctx, BuildParams{
|
|
|
|
Rule: Touch,
|
|
|
|
Output: outputFile,
|
|
|
|
})
|
|
|
|
installFile := ctx.InstallFile(PathForModuleInstall(ctx), ctx.ModuleName(), outputFile)
|
|
|
|
ctx.InstallSymlink(PathForModuleInstall(ctx, "symlinks"), ctx.ModuleName(), installFile)
|
2019-08-23 04:18:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *depsModule) DepsMutator(ctx BottomUpMutatorContext) {
|
2021-11-09 22:17:44 +01:00
|
|
|
ctx.AddDependency(ctx.Module(), installDepTag{}, m.props.Deps...)
|
2019-08-23 04:18:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func depsModuleFactory() Module {
|
|
|
|
m := &depsModule{}
|
|
|
|
m.AddProperties(&m.props)
|
2021-11-09 22:17:44 +01:00
|
|
|
InitAndroidArchModule(m, HostAndDeviceDefault, MultilibCommon)
|
2019-08-23 04:18:57 +02:00
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-16 20:44:51 +01:00
|
|
|
var prepareForModuleTests = FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
|
|
|
ctx.RegisterModuleType("deps", depsModuleFactory)
|
|
|
|
})
|
|
|
|
|
2019-08-23 04:18:57 +02:00
|
|
|
func TestErrorDependsOnDisabledModule(t *testing.T) {
|
|
|
|
bp := `
|
|
|
|
deps {
|
|
|
|
name: "foo",
|
|
|
|
deps: ["bar"],
|
|
|
|
}
|
|
|
|
deps {
|
|
|
|
name: "bar",
|
|
|
|
enabled: false,
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
2021-03-20 01:36:14 +01:00
|
|
|
prepareForModuleTests.
|
2021-03-16 20:44:51 +01:00
|
|
|
ExtendWithErrorHandler(FixtureExpectsAtLeastOneErrorMatchingPattern(`module "foo": depends on disabled module "bar"`)).
|
2021-03-20 01:36:14 +01:00
|
|
|
RunTestWithBp(t, bp)
|
2019-08-23 04:18:57 +02:00
|
|
|
}
|
2020-09-23 06:30:02 +02:00
|
|
|
|
2020-11-23 19:17:03 +01:00
|
|
|
func TestDistErrorChecking(t *testing.T) {
|
|
|
|
bp := `
|
|
|
|
deps {
|
|
|
|
name: "foo",
|
|
|
|
dist: {
|
|
|
|
dest: "../invalid-dest",
|
|
|
|
dir: "../invalid-dir",
|
|
|
|
suffix: "invalid/suffix",
|
|
|
|
},
|
|
|
|
dists: [
|
|
|
|
{
|
|
|
|
dest: "../invalid-dest0",
|
|
|
|
dir: "../invalid-dir0",
|
|
|
|
suffix: "invalid/suffix0",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
dest: "../invalid-dest1",
|
|
|
|
dir: "../invalid-dir1",
|
|
|
|
suffix: "invalid/suffix1",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
expectedErrs := []string{
|
|
|
|
"\\QAndroid.bp:5:13: module \"foo\": dist.dest: Path is outside directory: ../invalid-dest\\E",
|
|
|
|
"\\QAndroid.bp:6:12: module \"foo\": dist.dir: Path is outside directory: ../invalid-dir\\E",
|
|
|
|
"\\QAndroid.bp:7:15: module \"foo\": dist.suffix: Suffix may not contain a '/' character.\\E",
|
|
|
|
"\\QAndroid.bp:11:15: module \"foo\": dists[0].dest: Path is outside directory: ../invalid-dest0\\E",
|
|
|
|
"\\QAndroid.bp:12:14: module \"foo\": dists[0].dir: Path is outside directory: ../invalid-dir0\\E",
|
|
|
|
"\\QAndroid.bp:13:17: module \"foo\": dists[0].suffix: Suffix may not contain a '/' character.\\E",
|
|
|
|
"\\QAndroid.bp:16:15: module \"foo\": dists[1].dest: Path is outside directory: ../invalid-dest1\\E",
|
|
|
|
"\\QAndroid.bp:17:14: module \"foo\": dists[1].dir: Path is outside directory: ../invalid-dir1\\E",
|
|
|
|
"\\QAndroid.bp:18:17: module \"foo\": dists[1].suffix: Suffix may not contain a '/' character.\\E",
|
|
|
|
}
|
2021-03-16 20:44:51 +01:00
|
|
|
|
2021-03-20 01:36:14 +01:00
|
|
|
prepareForModuleTests.
|
2021-03-16 20:44:51 +01:00
|
|
|
ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern(expectedErrs)).
|
2021-03-20 01:36:14 +01:00
|
|
|
RunTestWithBp(t, bp)
|
2020-11-23 19:17:03 +01:00
|
|
|
}
|
2021-11-09 22:17:44 +01:00
|
|
|
|
|
|
|
func TestInstall(t *testing.T) {
|
|
|
|
if runtime.GOOS != "linux" {
|
|
|
|
t.Skip("requires linux")
|
|
|
|
}
|
|
|
|
bp := `
|
|
|
|
deps {
|
|
|
|
name: "foo",
|
|
|
|
deps: ["bar"],
|
|
|
|
}
|
|
|
|
|
|
|
|
deps {
|
|
|
|
name: "bar",
|
|
|
|
deps: ["baz", "qux"],
|
|
|
|
}
|
|
|
|
|
|
|
|
deps {
|
|
|
|
name: "baz",
|
|
|
|
deps: ["qux"],
|
|
|
|
}
|
|
|
|
|
|
|
|
deps {
|
|
|
|
name: "qux",
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
result := GroupFixturePreparers(
|
|
|
|
prepareForModuleTests,
|
|
|
|
PrepareForTestWithArchMutator,
|
|
|
|
).RunTestWithBp(t, bp)
|
|
|
|
|
|
|
|
module := func(name string, host bool) TestingModule {
|
|
|
|
variant := "android_common"
|
|
|
|
if host {
|
|
|
|
variant = result.Config.BuildOSCommonTarget.String()
|
|
|
|
}
|
|
|
|
return result.ModuleForTests(name, variant)
|
|
|
|
}
|
|
|
|
|
|
|
|
outputRule := func(name string) TestingBuildParams { return module(name, false).Output(name) }
|
|
|
|
|
|
|
|
installRule := func(name string) TestingBuildParams {
|
|
|
|
return module(name, false).Output(filepath.Join("out/soong/target/product/test_device/system", name))
|
|
|
|
}
|
|
|
|
|
|
|
|
symlinkRule := func(name string) TestingBuildParams {
|
|
|
|
return module(name, false).Output(filepath.Join("out/soong/target/product/test_device/system/symlinks", name))
|
|
|
|
}
|
|
|
|
|
|
|
|
hostOutputRule := func(name string) TestingBuildParams { return module(name, true).Output(name) }
|
|
|
|
|
|
|
|
hostInstallRule := func(name string) TestingBuildParams {
|
|
|
|
return module(name, true).Output(filepath.Join("out/soong/host/linux-x86", name))
|
|
|
|
}
|
|
|
|
|
|
|
|
hostSymlinkRule := func(name string) TestingBuildParams {
|
|
|
|
return module(name, true).Output(filepath.Join("out/soong/host/linux-x86/symlinks", name))
|
|
|
|
}
|
|
|
|
|
|
|
|
assertInputs := func(params TestingBuildParams, inputs ...Path) {
|
|
|
|
t.Helper()
|
|
|
|
AssertArrayString(t, "expected inputs", Paths(inputs).Strings(),
|
|
|
|
append(PathsIfNonNil(params.Input), params.Inputs...).Strings())
|
|
|
|
}
|
|
|
|
|
|
|
|
assertImplicits := func(params TestingBuildParams, implicits ...Path) {
|
|
|
|
t.Helper()
|
|
|
|
AssertArrayString(t, "expected implicit dependencies", Paths(implicits).Strings(),
|
|
|
|
append(PathsIfNonNil(params.Implicit), params.Implicits...).Strings())
|
|
|
|
}
|
|
|
|
|
|
|
|
assertOrderOnlys := func(params TestingBuildParams, orderonlys ...Path) {
|
|
|
|
t.Helper()
|
|
|
|
AssertArrayString(t, "expected orderonly dependencies", Paths(orderonlys).Strings(),
|
|
|
|
params.OrderOnly.Strings())
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check host install rule dependencies
|
|
|
|
assertInputs(hostInstallRule("foo"), hostOutputRule("foo").Output)
|
|
|
|
assertImplicits(hostInstallRule("foo"),
|
|
|
|
hostInstallRule("bar").Output,
|
|
|
|
hostSymlinkRule("bar").Output,
|
|
|
|
hostInstallRule("baz").Output,
|
|
|
|
hostSymlinkRule("baz").Output,
|
|
|
|
hostInstallRule("qux").Output,
|
|
|
|
hostSymlinkRule("qux").Output,
|
|
|
|
)
|
|
|
|
assertOrderOnlys(hostInstallRule("foo"))
|
|
|
|
|
2021-11-10 01:37:52 +01:00
|
|
|
// Check host symlink rule dependencies. Host symlinks must use a normal dependency, not an
|
|
|
|
// order-only dependency, so that the tool gets updated when the symlink is depended on.
|
2021-11-09 22:17:44 +01:00
|
|
|
assertInputs(hostSymlinkRule("foo"), hostInstallRule("foo").Output)
|
|
|
|
assertImplicits(hostSymlinkRule("foo"))
|
|
|
|
assertOrderOnlys(hostSymlinkRule("foo"))
|
|
|
|
|
|
|
|
// Check device install rule dependencies
|
|
|
|
assertInputs(installRule("foo"), outputRule("foo").Output)
|
|
|
|
assertImplicits(installRule("foo"))
|
|
|
|
assertOrderOnlys(installRule("foo"),
|
|
|
|
installRule("bar").Output,
|
|
|
|
symlinkRule("bar").Output,
|
|
|
|
installRule("baz").Output,
|
|
|
|
symlinkRule("baz").Output,
|
|
|
|
installRule("qux").Output,
|
|
|
|
symlinkRule("qux").Output,
|
|
|
|
)
|
|
|
|
|
2021-11-10 01:37:52 +01:00
|
|
|
// Check device symlink rule dependencies. Device symlinks could use an order-only dependency,
|
|
|
|
// but the current implementation uses a normal dependency.
|
2021-11-09 22:17:44 +01:00
|
|
|
assertInputs(symlinkRule("foo"), installRule("foo").Output)
|
|
|
|
assertImplicits(symlinkRule("foo"))
|
|
|
|
assertOrderOnlys(symlinkRule("foo"))
|
|
|
|
}
|
|
|
|
|
2021-11-12 03:59:15 +01:00
|
|
|
func TestInstallKatiEnabled(t *testing.T) {
|
2021-11-09 22:17:44 +01:00
|
|
|
if runtime.GOOS != "linux" {
|
|
|
|
t.Skip("requires linux")
|
|
|
|
}
|
|
|
|
bp := `
|
|
|
|
deps {
|
|
|
|
name: "foo",
|
|
|
|
deps: ["bar"],
|
|
|
|
}
|
|
|
|
|
|
|
|
deps {
|
|
|
|
name: "bar",
|
|
|
|
deps: ["baz", "qux"],
|
|
|
|
}
|
|
|
|
|
|
|
|
deps {
|
|
|
|
name: "baz",
|
|
|
|
deps: ["qux"],
|
|
|
|
}
|
|
|
|
|
|
|
|
deps {
|
|
|
|
name: "qux",
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
result := GroupFixturePreparers(
|
|
|
|
prepareForModuleTests,
|
|
|
|
PrepareForTestWithArchMutator,
|
|
|
|
FixtureModifyConfig(SetKatiEnabledForTests),
|
2022-02-11 00:34:28 +01:00
|
|
|
PrepareForTestWithMakevars,
|
2021-11-09 22:17:44 +01:00
|
|
|
).RunTestWithBp(t, bp)
|
|
|
|
|
2022-02-11 00:34:28 +01:00
|
|
|
rules := result.InstallMakeRulesForTesting(t)
|
2021-11-09 22:17:44 +01:00
|
|
|
|
|
|
|
module := func(name string, host bool) TestingModule {
|
|
|
|
variant := "android_common"
|
|
|
|
if host {
|
|
|
|
variant = result.Config.BuildOSCommonTarget.String()
|
|
|
|
}
|
|
|
|
return result.ModuleForTests(name, variant)
|
|
|
|
}
|
|
|
|
|
|
|
|
outputRule := func(name string) TestingBuildParams { return module(name, false).Output(name) }
|
|
|
|
|
2022-02-11 00:34:28 +01:00
|
|
|
ruleForOutput := func(output string) InstallMakeRule {
|
2021-11-09 22:17:44 +01:00
|
|
|
for _, rule := range rules {
|
2022-02-11 00:34:28 +01:00
|
|
|
if rule.Target == output {
|
2021-11-09 22:17:44 +01:00
|
|
|
return rule
|
|
|
|
}
|
|
|
|
}
|
|
|
|
t.Fatalf("no make install rule for %s", output)
|
2022-02-11 00:34:28 +01:00
|
|
|
return InstallMakeRule{}
|
2021-11-09 22:17:44 +01:00
|
|
|
}
|
|
|
|
|
2022-02-11 00:34:28 +01:00
|
|
|
installRule := func(name string) InstallMakeRule {
|
2021-11-09 22:17:44 +01:00
|
|
|
return ruleForOutput(filepath.Join("out/target/product/test_device/system", name))
|
|
|
|
}
|
|
|
|
|
2022-02-11 00:34:28 +01:00
|
|
|
symlinkRule := func(name string) InstallMakeRule {
|
2021-11-09 22:17:44 +01:00
|
|
|
return ruleForOutput(filepath.Join("out/target/product/test_device/system/symlinks", name))
|
|
|
|
}
|
|
|
|
|
|
|
|
hostOutputRule := func(name string) TestingBuildParams { return module(name, true).Output(name) }
|
|
|
|
|
2022-02-11 00:34:28 +01:00
|
|
|
hostInstallRule := func(name string) InstallMakeRule {
|
2021-11-09 22:17:44 +01:00
|
|
|
return ruleForOutput(filepath.Join("out/host/linux-x86", name))
|
|
|
|
}
|
|
|
|
|
2022-02-11 00:34:28 +01:00
|
|
|
hostSymlinkRule := func(name string) InstallMakeRule {
|
2021-11-09 22:17:44 +01:00
|
|
|
return ruleForOutput(filepath.Join("out/host/linux-x86/symlinks", name))
|
|
|
|
}
|
|
|
|
|
2022-02-11 00:34:28 +01:00
|
|
|
assertDeps := func(rule InstallMakeRule, deps ...string) {
|
2021-11-09 22:17:44 +01:00
|
|
|
t.Helper()
|
2022-02-11 00:34:28 +01:00
|
|
|
AssertArrayString(t, "expected inputs", deps, rule.Deps)
|
2021-11-09 22:17:44 +01:00
|
|
|
}
|
|
|
|
|
2022-02-11 00:34:28 +01:00
|
|
|
assertOrderOnlys := func(rule InstallMakeRule, orderonlys ...string) {
|
2021-11-09 22:17:44 +01:00
|
|
|
t.Helper()
|
2022-02-11 00:34:28 +01:00
|
|
|
AssertArrayString(t, "expected orderonly dependencies", orderonlys, rule.OrderOnlyDeps)
|
2021-11-09 22:17:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check host install rule dependencies
|
|
|
|
assertDeps(hostInstallRule("foo"),
|
|
|
|
hostOutputRule("foo").Output.String(),
|
2022-02-11 00:34:28 +01:00
|
|
|
hostInstallRule("bar").Target,
|
|
|
|
hostSymlinkRule("bar").Target,
|
|
|
|
hostInstallRule("baz").Target,
|
|
|
|
hostSymlinkRule("baz").Target,
|
|
|
|
hostInstallRule("qux").Target,
|
|
|
|
hostSymlinkRule("qux").Target,
|
2021-11-09 22:17:44 +01:00
|
|
|
)
|
|
|
|
assertOrderOnlys(hostInstallRule("foo"))
|
|
|
|
|
2021-11-10 01:37:52 +01:00
|
|
|
// Check host symlink rule dependencies. Host symlinks must use a normal dependency, not an
|
|
|
|
// order-only dependency, so that the tool gets updated when the symlink is depended on.
|
2022-02-11 00:34:28 +01:00
|
|
|
assertDeps(hostSymlinkRule("foo"), hostInstallRule("foo").Target)
|
2021-11-10 01:37:52 +01:00
|
|
|
assertOrderOnlys(hostSymlinkRule("foo"))
|
2021-11-09 22:17:44 +01:00
|
|
|
|
|
|
|
// Check device install rule dependencies
|
|
|
|
assertDeps(installRule("foo"), outputRule("foo").Output.String())
|
|
|
|
assertOrderOnlys(installRule("foo"),
|
2022-02-11 00:34:28 +01:00
|
|
|
installRule("bar").Target,
|
|
|
|
symlinkRule("bar").Target,
|
|
|
|
installRule("baz").Target,
|
|
|
|
symlinkRule("baz").Target,
|
|
|
|
installRule("qux").Target,
|
|
|
|
symlinkRule("qux").Target,
|
2021-11-09 22:17:44 +01:00
|
|
|
)
|
|
|
|
|
2021-11-10 01:37:52 +01:00
|
|
|
// Check device symlink rule dependencies. Device symlinks could use an order-only dependency,
|
|
|
|
// but the current implementation uses a normal dependency.
|
2022-02-11 00:34:28 +01:00
|
|
|
assertDeps(symlinkRule("foo"), installRule("foo").Target)
|
2021-11-10 01:37:52 +01:00
|
|
|
assertOrderOnlys(symlinkRule("foo"))
|
2021-11-09 22:17:44 +01:00
|
|
|
}
|
|
|
|
|
2022-01-05 19:46:24 +01:00
|
|
|
type PropsTestModuleEmbedded struct {
|
|
|
|
Embedded_prop *string
|
|
|
|
}
|
|
|
|
|
2022-03-22 16:27:26 +01:00
|
|
|
type StructInSlice struct {
|
|
|
|
G string
|
|
|
|
H bool
|
|
|
|
I []string
|
|
|
|
}
|
|
|
|
|
2022-01-05 19:46:24 +01:00
|
|
|
type propsTestModule struct {
|
|
|
|
ModuleBase
|
|
|
|
DefaultableModuleBase
|
|
|
|
props struct {
|
|
|
|
A string `android:"arch_variant"`
|
|
|
|
B *bool
|
|
|
|
C []string
|
|
|
|
}
|
|
|
|
otherProps struct {
|
|
|
|
PropsTestModuleEmbedded
|
|
|
|
|
|
|
|
D *int64
|
|
|
|
Nested struct {
|
|
|
|
E *string
|
|
|
|
}
|
|
|
|
F *string `blueprint:"mutated"`
|
2022-03-22 16:27:26 +01:00
|
|
|
|
|
|
|
Slice_of_struct []StructInSlice
|
2022-01-05 19:46:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func propsTestModuleFactory() Module {
|
|
|
|
module := &propsTestModule{}
|
|
|
|
module.AddProperties(&module.props, &module.otherProps)
|
|
|
|
InitAndroidArchModule(module, HostAndDeviceSupported, MultilibBoth)
|
|
|
|
InitDefaultableModule(module)
|
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
|
|
|
type propsTestModuleDefaults struct {
|
|
|
|
ModuleBase
|
|
|
|
DefaultsModuleBase
|
|
|
|
}
|
|
|
|
|
|
|
|
func propsTestModuleDefaultsFactory() Module {
|
|
|
|
defaults := &propsTestModuleDefaults{}
|
|
|
|
module := propsTestModule{}
|
|
|
|
defaults.AddProperties(&module.props, &module.otherProps)
|
|
|
|
InitDefaultsModule(defaults)
|
|
|
|
return defaults
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *propsTestModule) GenerateAndroidBuildActions(ctx ModuleContext) {
|
|
|
|
str := "abc"
|
|
|
|
p.otherProps.F = &str
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestUsedProperties(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
|
|
|
bp string
|
|
|
|
expectedProps []propInfo
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "only name",
|
|
|
|
bp: `test {
|
|
|
|
name: "foo",
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
expectedProps: []propInfo{
|
2022-03-22 16:27:26 +01:00
|
|
|
propInfo{Name: "Name", Type: "string", Value: "foo"},
|
2022-01-05 19:46:24 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "some props",
|
|
|
|
bp: `test {
|
|
|
|
name: "foo",
|
|
|
|
a: "abc",
|
|
|
|
b: true,
|
|
|
|
d: 123,
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
expectedProps: []propInfo{
|
2022-03-22 16:27:26 +01:00
|
|
|
propInfo{Name: "A", Type: "string", Value: "abc"},
|
|
|
|
propInfo{Name: "B", Type: "bool", Value: "true"},
|
|
|
|
propInfo{Name: "D", Type: "int64", Value: "123"},
|
|
|
|
propInfo{Name: "Name", Type: "string", Value: "foo"},
|
2022-01-05 19:46:24 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "unused non-pointer prop",
|
|
|
|
bp: `test {
|
|
|
|
name: "foo",
|
|
|
|
b: true,
|
|
|
|
d: 123,
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
expectedProps: []propInfo{
|
|
|
|
// for non-pointer cannot distinguish between unused and intentionally set to empty
|
2022-03-22 16:27:26 +01:00
|
|
|
propInfo{Name: "A", Type: "string", Value: ""},
|
|
|
|
propInfo{Name: "B", Type: "bool", Value: "true"},
|
|
|
|
propInfo{Name: "D", Type: "int64", Value: "123"},
|
|
|
|
propInfo{Name: "Name", Type: "string", Value: "foo"},
|
2022-01-05 19:46:24 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "nested props",
|
|
|
|
bp: `test {
|
|
|
|
name: "foo",
|
|
|
|
nested: {
|
|
|
|
e: "abc",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
expectedProps: []propInfo{
|
2022-03-22 16:27:26 +01:00
|
|
|
propInfo{Name: "Name", Type: "string", Value: "foo"},
|
|
|
|
propInfo{Name: "Nested.E", Type: "string", Value: "abc"},
|
2022-01-05 19:46:24 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "arch props",
|
|
|
|
bp: `test {
|
|
|
|
name: "foo",
|
|
|
|
arch: {
|
|
|
|
x86_64: {
|
|
|
|
a: "abc",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
expectedProps: []propInfo{
|
2022-03-22 16:27:26 +01:00
|
|
|
propInfo{Name: "Arch.X86_64.A", Type: "string", Value: "abc"},
|
|
|
|
propInfo{Name: "Name", Type: "string", Value: "foo"},
|
2022-01-05 19:46:24 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "embedded props",
|
|
|
|
bp: `test {
|
|
|
|
name: "foo",
|
|
|
|
embedded_prop: "a",
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
expectedProps: []propInfo{
|
2022-03-22 16:27:26 +01:00
|
|
|
propInfo{Name: "Embedded_prop", Type: "string", Value: "a"},
|
|
|
|
propInfo{Name: "Name", Type: "string", Value: "foo"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "struct slice",
|
|
|
|
bp: `test {
|
|
|
|
name: "foo",
|
|
|
|
slice_of_struct: [
|
|
|
|
{
|
|
|
|
g: "abc",
|
|
|
|
h: false,
|
|
|
|
i: ["baz"],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
g: "def",
|
|
|
|
h: true,
|
|
|
|
i: [],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
expectedProps: []propInfo{
|
|
|
|
propInfo{Name: "Name", Type: "string", Value: "foo"},
|
|
|
|
propInfo{Name: "Slice_of_struct", Type: "struct slice", Values: []string{
|
|
|
|
`android.StructInSlice{G: abc, H: false, I: [baz]}`,
|
|
|
|
`android.StructInSlice{G: def, H: true, I: []}`,
|
|
|
|
}},
|
2022-01-05 19:46:24 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "defaults",
|
|
|
|
bp: `
|
|
|
|
test_defaults {
|
|
|
|
name: "foo_defaults",
|
|
|
|
a: "a",
|
|
|
|
b: true,
|
2022-03-22 16:27:26 +01:00
|
|
|
c: ["default_c"],
|
2022-01-05 19:46:24 +01:00
|
|
|
embedded_prop:"a",
|
|
|
|
arch: {
|
|
|
|
x86_64: {
|
2022-03-22 16:27:26 +01:00
|
|
|
a: "x86_64 a",
|
2022-01-05 19:46:24 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
test {
|
|
|
|
name: "foo",
|
|
|
|
defaults: ["foo_defaults"],
|
2022-03-22 16:27:26 +01:00
|
|
|
c: ["c"],
|
2022-01-05 19:46:24 +01:00
|
|
|
nested: {
|
2022-03-22 16:27:26 +01:00
|
|
|
e: "nested e",
|
2022-01-05 19:46:24 +01:00
|
|
|
},
|
|
|
|
target: {
|
|
|
|
linux: {
|
|
|
|
a: "a",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
expectedProps: []propInfo{
|
2022-03-22 16:27:26 +01:00
|
|
|
propInfo{Name: "A", Type: "string", Value: "a"},
|
|
|
|
propInfo{Name: "Arch.X86_64.A", Type: "string", Value: "x86_64 a"},
|
|
|
|
propInfo{Name: "B", Type: "bool", Value: "true"},
|
|
|
|
propInfo{Name: "C", Type: "string slice", Values: []string{"default_c", "c"}},
|
|
|
|
propInfo{Name: "Defaults", Type: "string slice", Values: []string{"foo_defaults"}},
|
|
|
|
propInfo{Name: "Embedded_prop", Type: "string", Value: "a"},
|
|
|
|
propInfo{Name: "Name", Type: "string", Value: "foo"},
|
|
|
|
propInfo{Name: "Nested.E", Type: "string", Value: "nested e"},
|
|
|
|
propInfo{Name: "Target.Linux.A", Type: "string", Value: "a"},
|
2022-01-05 19:46:24 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tc := range testCases {
|
|
|
|
t.Run(tc.desc, func(t *testing.T) {
|
|
|
|
result := GroupFixturePreparers(
|
|
|
|
PrepareForTestWithAllowMissingDependencies,
|
|
|
|
PrepareForTestWithDefaults,
|
|
|
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
|
|
|
ctx.RegisterModuleType("test", propsTestModuleFactory)
|
|
|
|
ctx.RegisterModuleType("test_defaults", propsTestModuleDefaultsFactory)
|
|
|
|
}),
|
|
|
|
FixtureWithRootAndroidBp(tc.bp),
|
|
|
|
).RunTest(t)
|
|
|
|
|
|
|
|
foo := result.ModuleForTests("foo", "").Module().base()
|
|
|
|
|
|
|
|
AssertDeepEquals(t, "foo ", tc.expectedProps, foo.propertiesWithValues())
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2022-02-09 20:54:35 +01:00
|
|
|
|
|
|
|
func TestSortedUniqueNamedPaths(t *testing.T) {
|
|
|
|
type np struct {
|
|
|
|
path, name string
|
|
|
|
}
|
|
|
|
makePaths := func(l []np) NamedPaths {
|
|
|
|
result := make(NamedPaths, 0, len(l))
|
|
|
|
for _, p := range l {
|
|
|
|
result = append(result, NamedPath{PathForTesting(p.path), p.name})
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
in []np
|
|
|
|
expectedOut []np
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "empty",
|
|
|
|
in: []np{},
|
|
|
|
expectedOut: []np{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "all_same",
|
|
|
|
in: []np{
|
|
|
|
{"a.txt", "A"},
|
|
|
|
{"a.txt", "A"},
|
|
|
|
{"a.txt", "A"},
|
|
|
|
{"a.txt", "A"},
|
|
|
|
{"a.txt", "A"},
|
|
|
|
},
|
|
|
|
expectedOut: []np{
|
|
|
|
{"a.txt", "A"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "same_path_different_names",
|
|
|
|
in: []np{
|
|
|
|
{"a.txt", "C"},
|
|
|
|
{"a.txt", "A"},
|
|
|
|
{"a.txt", "D"},
|
|
|
|
{"a.txt", "B"},
|
|
|
|
{"a.txt", "E"},
|
|
|
|
},
|
|
|
|
expectedOut: []np{
|
|
|
|
{"a.txt", "A"},
|
|
|
|
{"a.txt", "B"},
|
|
|
|
{"a.txt", "C"},
|
|
|
|
{"a.txt", "D"},
|
|
|
|
{"a.txt", "E"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "different_paths_same_name",
|
|
|
|
in: []np{
|
|
|
|
{"b/b.txt", "A"},
|
|
|
|
{"a/a.txt", "A"},
|
|
|
|
{"a/txt", "A"},
|
|
|
|
{"b", "A"},
|
|
|
|
{"a/b/d", "A"},
|
|
|
|
},
|
|
|
|
expectedOut: []np{
|
|
|
|
{"a/a.txt", "A"},
|
|
|
|
{"a/b/d", "A"},
|
|
|
|
{"a/txt", "A"},
|
|
|
|
{"b/b.txt", "A"},
|
|
|
|
{"b", "A"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "all_different",
|
|
|
|
in: []np{
|
|
|
|
{"b/b.txt", "A"},
|
|
|
|
{"a/a.txt", "B"},
|
|
|
|
{"a/txt", "D"},
|
|
|
|
{"b", "C"},
|
|
|
|
{"a/b/d", "E"},
|
|
|
|
},
|
|
|
|
expectedOut: []np{
|
|
|
|
{"a/a.txt", "B"},
|
|
|
|
{"a/b/d", "E"},
|
|
|
|
{"a/txt", "D"},
|
|
|
|
{"b/b.txt", "A"},
|
|
|
|
{"b", "C"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "some_different",
|
|
|
|
in: []np{
|
|
|
|
{"b/b.txt", "A"},
|
|
|
|
{"a/a.txt", "B"},
|
|
|
|
{"a/txt", "D"},
|
|
|
|
{"a/b/d", "E"},
|
|
|
|
{"b", "C"},
|
|
|
|
{"a/a.txt", "B"},
|
|
|
|
{"a/b/d", "E"},
|
|
|
|
},
|
|
|
|
expectedOut: []np{
|
|
|
|
{"a/a.txt", "B"},
|
|
|
|
{"a/b/d", "E"},
|
|
|
|
{"a/txt", "D"},
|
|
|
|
{"b/b.txt", "A"},
|
|
|
|
{"b", "C"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
actual := SortedUniqueNamedPaths(makePaths(tt.in))
|
|
|
|
expected := makePaths(tt.expectedOut)
|
|
|
|
t.Logf("actual: %v", actual)
|
|
|
|
t.Logf("expected: %v", expected)
|
|
|
|
AssertDeepEquals(t, "SortedUniqueNamedPaths ", expected, actual)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2022-08-12 12:49:20 +02:00
|
|
|
|
2022-08-22 10:00:05 +02:00
|
|
|
func TestSetAndroidMkEntriesWithTestOptions(t *testing.T) {
|
2022-08-12 12:49:20 +02:00
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
testOptions CommonTestOptions
|
|
|
|
expected map[string][]string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "empty",
|
|
|
|
testOptions: CommonTestOptions{},
|
|
|
|
expected: map[string][]string{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "is unit test",
|
|
|
|
testOptions: CommonTestOptions{
|
|
|
|
Unit_test: boolPtr(true),
|
|
|
|
},
|
|
|
|
expected: map[string][]string{
|
|
|
|
"LOCAL_IS_UNIT_TEST": []string{"true"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "is not unit test",
|
|
|
|
testOptions: CommonTestOptions{
|
|
|
|
Unit_test: boolPtr(false),
|
|
|
|
},
|
|
|
|
expected: map[string][]string{},
|
|
|
|
},
|
2022-08-22 10:00:05 +02:00
|
|
|
{
|
|
|
|
name: "empty tag",
|
|
|
|
testOptions: CommonTestOptions{
|
|
|
|
Tags: []string{},
|
|
|
|
},
|
|
|
|
expected: map[string][]string{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "single tag",
|
|
|
|
testOptions: CommonTestOptions{
|
|
|
|
Tags: []string{"tag1"},
|
|
|
|
},
|
|
|
|
expected: map[string][]string{
|
|
|
|
"LOCAL_TEST_OPTIONS_TAGS": []string{"tag1"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "multiple tag",
|
|
|
|
testOptions: CommonTestOptions{
|
|
|
|
Tags: []string{"tag1", "tag2", "tag3"},
|
|
|
|
},
|
|
|
|
expected: map[string][]string{
|
|
|
|
"LOCAL_TEST_OPTIONS_TAGS": []string{"tag1", "tag2", "tag3"},
|
|
|
|
},
|
|
|
|
},
|
2022-08-12 12:49:20 +02:00
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
actualEntries := AndroidMkEntries{
|
|
|
|
EntryMap: map[string][]string{},
|
|
|
|
}
|
|
|
|
tt.testOptions.SetAndroidMkEntries(&actualEntries)
|
|
|
|
actual := actualEntries.EntryMap
|
|
|
|
t.Logf("actual: %v", actual)
|
|
|
|
t.Logf("expected: %v", tt.expected)
|
|
|
|
AssertDeepEquals(t, "TestProcessCommonTestOptions ", tt.expected, actual)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2022-10-04 06:02:27 +02:00
|
|
|
|
|
|
|
type fakeBlueprintModule struct{}
|
|
|
|
|
|
|
|
func (fakeBlueprintModule) Name() string { return "foo" }
|
|
|
|
|
|
|
|
func (fakeBlueprintModule) GenerateBuildActions(blueprint.ModuleContext) {}
|
|
|
|
|
|
|
|
type sourceProducerTestModule struct {
|
|
|
|
fakeBlueprintModule
|
|
|
|
source Path
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s sourceProducerTestModule) Srcs() Paths { return Paths{s.source} }
|
|
|
|
|
|
|
|
type outputFileProducerTestModule struct {
|
|
|
|
fakeBlueprintModule
|
|
|
|
output map[string]Path
|
|
|
|
error map[string]error
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o outputFileProducerTestModule) OutputFiles(tag string) (Paths, error) {
|
|
|
|
return PathsIfNonNil(o.output[tag]), o.error[tag]
|
|
|
|
}
|
|
|
|
|
|
|
|
type pathContextAddMissingDependenciesWrapper struct {
|
|
|
|
PathContext
|
|
|
|
missingDeps []string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *pathContextAddMissingDependenciesWrapper) AddMissingDependencies(deps []string) {
|
|
|
|
p.missingDeps = append(p.missingDeps, deps...)
|
|
|
|
}
|
|
|
|
func (p *pathContextAddMissingDependenciesWrapper) OtherModuleName(module blueprint.Module) string {
|
|
|
|
return module.Name()
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestOutputFileForModule(t *testing.T) {
|
|
|
|
testcases := []struct {
|
|
|
|
name string
|
|
|
|
module blueprint.Module
|
|
|
|
tag string
|
|
|
|
env map[string]string
|
|
|
|
config func(*config)
|
|
|
|
expected string
|
|
|
|
missingDeps []string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "SourceFileProducer",
|
|
|
|
module: &sourceProducerTestModule{source: PathForTesting("foo.txt")},
|
|
|
|
expected: "foo.txt",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "OutputFileProducer",
|
|
|
|
module: &outputFileProducerTestModule{output: map[string]Path{"": PathForTesting("foo.txt")}},
|
|
|
|
expected: "foo.txt",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "OutputFileProducer_tag",
|
|
|
|
module: &outputFileProducerTestModule{output: map[string]Path{"foo": PathForTesting("foo.txt")}},
|
|
|
|
tag: "foo",
|
|
|
|
expected: "foo.txt",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "OutputFileProducer_AllowMissingDependencies",
|
|
|
|
config: func(config *config) {
|
|
|
|
config.TestProductVariables.Allow_missing_dependencies = boolPtr(true)
|
|
|
|
},
|
|
|
|
module: &outputFileProducerTestModule{},
|
|
|
|
missingDeps: []string{"foo"},
|
|
|
|
expected: "missing_output_file/foo",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range testcases {
|
|
|
|
config := TestConfig(buildDir, tt.env, "", nil)
|
|
|
|
if tt.config != nil {
|
|
|
|
tt.config(config.config)
|
|
|
|
}
|
|
|
|
ctx := &pathContextAddMissingDependenciesWrapper{
|
|
|
|
PathContext: PathContextForTesting(config),
|
|
|
|
}
|
|
|
|
got := OutputFileForModule(ctx, tt.module, tt.tag)
|
|
|
|
AssertPathRelativeToTopEquals(t, "expected source path", tt.expected, got)
|
|
|
|
AssertArrayString(t, "expected missing deps", tt.missingDeps, ctx.missingDeps)
|
|
|
|
}
|
|
|
|
}
|