blob: 8292d5e67f20fc89c46472008b7f83b63a0d04b6 [file] [log] [blame]
Vinh Tran16fe8e12022-08-16 16:45:44 -04001package android
2
3import (
4 "path/filepath"
5 "testing"
6)
7
8func TestFileGroupWithPathProp(t *testing.T) {
Liz Kammer748209c2022-10-24 10:43:27 -04009 // TODO(b/247782695), TODO(b/242847534) Fix mixed builds for filegroups
10 t.Skip("Re-enable once filegroups are corrected for mixed builds")
Vinh Tran16fe8e12022-08-16 16:45:44 -040011 outBaseDir := "outputbase"
12 pathPrefix := outBaseDir + "/execroot/__main__"
13 expectedOutputfile := filepath.Join(pathPrefix, "a/b/c/d/test.aidl")
14
15 testCases := []struct {
16 bp string
17 rel string
18 }{
19 {
20 bp: `
21 filegroup {
22 name: "baz",
23 srcs: ["a/b/c/d/test.aidl"],
24 path: "a/b",
25 bazel_module: { label: "//:baz" },
26 }
27`,
28 rel: "c/d/test.aidl",
29 },
30 {
31 bp: `
32 filegroup {
33 name: "baz",
34 srcs: ["a/b/c/d/test.aidl"],
35 bazel_module: { label: "//:baz" },
36 }
37`,
38 rel: "a/b/c/d/test.aidl",
39 },
40 }
41
42 for _, testCase := range testCases {
43 outBaseDir := "outputbase"
44 result := GroupFixturePreparers(
45 PrepareForTestWithFilegroup,
46 FixtureModifyConfig(func(config Config) {
47 config.BazelContext = MockBazelContext{
48 OutputBaseDir: outBaseDir,
49 LabelToOutputFiles: map[string][]string{
50 "//:baz": []string{"a/b/c/d/test.aidl"},
51 },
52 }
53 }),
54 ).RunTestWithBp(t, testCase.bp)
55
56 fg := result.Module("baz", "").(*fileGroup)
57 AssertStringEquals(t, "src relativeRoot", testCase.rel, fg.srcs[0].Rel())
58 AssertStringEquals(t, "src full path", expectedOutputfile, fg.srcs[0].String())
59 }
60}