blob: 40343408def9de70eb8584c113056f331aa67469 [file] [log] [blame]
Colin Cross72bb3632017-07-13 16:23:21 -07001// Copyright 2017 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 java
16
17import (
18 "android/soong/android"
Colin Cross0f37af02017-09-27 17:42:05 -070019 "android/soong/genrule"
Colin Cross72bb3632017-07-13 16:23:21 -070020 "fmt"
21 "io/ioutil"
22 "os"
23 "path/filepath"
Colin Cross227d4362017-08-30 14:14:52 -070024 "reflect"
Colin Cross72bb3632017-07-13 16:23:21 -070025 "strings"
26 "testing"
27)
28
29var buildDir string
30
31func setUp() {
32 var err error
33 buildDir, err = ioutil.TempDir("", "soong_java_test")
34 if err != nil {
35 panic(err)
36 }
37}
38
39func tearDown() {
40 os.RemoveAll(buildDir)
41}
42
43func TestMain(m *testing.M) {
44 run := func() int {
45 setUp()
46 defer tearDown()
47
48 return m.Run()
49 }
50
51 os.Exit(run())
52}
53
54func testJava(t *testing.T, bp string) *android.TestContext {
Colin Cross4c428df2017-09-15 17:36:05 -070055 config := android.TestArchConfig(buildDir)
Colin Cross72bb3632017-07-13 16:23:21 -070056
Colin Cross4c428df2017-09-15 17:36:05 -070057 ctx := android.NewTestArchContext()
Colin Cross72bb3632017-07-13 16:23:21 -070058 ctx.RegisterModuleType("android_app", android.ModuleFactoryAdaptor(AndroidAppFactory))
Colin Crossa60ead82017-10-02 18:10:21 -070059 ctx.RegisterModuleType("java_library", android.ModuleFactoryAdaptor(LibraryFactory(true)))
Colin Cross2acdae82017-09-15 19:44:24 -070060 ctx.RegisterModuleType("java_library_host", android.ModuleFactoryAdaptor(LibraryHostFactory))
Colin Cross74d73e22017-08-02 11:05:49 -070061 ctx.RegisterModuleType("java_import", android.ModuleFactoryAdaptor(ImportFactory))
Colin Cross89536d42017-07-07 14:35:50 -070062 ctx.RegisterModuleType("java_defaults", android.ModuleFactoryAdaptor(defaultsFactory))
Colin Cross0f37af02017-09-27 17:42:05 -070063 ctx.RegisterModuleType("filegroup", android.ModuleFactoryAdaptor(genrule.FileGroupFactory))
Colin Cross54190b32017-10-09 15:34:10 -070064 ctx.RegisterModuleType("genrule", android.ModuleFactoryAdaptor(genrule.GenRuleFactory))
Colin Cross5ea9bcc2017-07-27 15:41:32 -070065 ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators)
66 ctx.PreArchMutators(android.RegisterPrebuiltsPostDepsMutators)
Colin Cross89536d42017-07-07 14:35:50 -070067 ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
Colin Cross72bb3632017-07-13 16:23:21 -070068 ctx.Register()
69
Colin Cross4c428df2017-09-15 17:36:05 -070070 extraModules := []string{
71 "core-oj",
72 "core-libart",
73 "framework",
74 "ext",
75 "okhttp",
Colin Cross2acdae82017-09-15 19:44:24 -070076 "android_stubs_current",
77 "android_system_stubs_current",
78 "android_test_stubs_current",
Colin Cross4c428df2017-09-15 17:36:05 -070079 }
Colin Cross72bb3632017-07-13 16:23:21 -070080
81 for _, extra := range extraModules {
82 bp += fmt.Sprintf(`
83 java_library {
84 name: "%s",
Colin Cross0a6e0072017-08-30 14:24:55 -070085 srcs: ["a.java"],
Colin Cross76b5f0c2017-08-29 16:02:06 -070086 no_standard_libs: true,
Colin Cross72bb3632017-07-13 16:23:21 -070087 }
88 `, extra)
89 }
90
91 ctx.MockFileSystem(map[string][]byte{
Colin Crossfc3674a2017-09-18 17:41:52 -070092 "Android.bp": []byte(bp),
93 "a.java": nil,
94 "b.java": nil,
95 "c.java": nil,
96 "a.jar": nil,
97 "b.jar": nil,
Colin Cross0f37af02017-09-27 17:42:05 -070098 "res/a": nil,
99 "res/b": nil,
Colin Cross0532fb02017-10-02 16:57:40 -0700100 "res2/a": nil,
101
Colin Crossfc3674a2017-09-18 17:41:52 -0700102 "prebuilts/sdk/14/android.jar": nil,
103 "prebuilts/sdk/14/framework.aidl": nil,
Colin Cross72bb3632017-07-13 16:23:21 -0700104 })
105
106 _, errs := ctx.ParseBlueprintsFiles("Android.bp")
107 fail(t, errs)
108 _, errs = ctx.PrepareBuildActions(config)
109 fail(t, errs)
110
111 return ctx
112}
113
Colin Cross2acdae82017-09-15 19:44:24 -0700114func moduleToPath(name string) string {
115 switch {
116 case name == `""`:
117 return name
Colin Crossfc3674a2017-09-18 17:41:52 -0700118 case strings.HasSuffix(name, ".jar"):
119 return name
Colin Cross2acdae82017-09-15 19:44:24 -0700120 default:
Colin Cross8649b262017-09-27 18:03:17 -0700121 return filepath.Join(buildDir, ".intermediates", name, "android_common", "classes-compiled.jar")
Colin Cross2acdae82017-09-15 19:44:24 -0700122 }
123}
124
Colin Cross72bb3632017-07-13 16:23:21 -0700125func TestSimple(t *testing.T) {
126 ctx := testJava(t, `
127 java_library {
128 name: "foo",
129 srcs: ["a.java"],
Colin Crosse8dc34a2017-07-19 11:22:16 -0700130 libs: ["bar"],
131 static_libs: ["baz"],
Colin Cross72bb3632017-07-13 16:23:21 -0700132 }
133
134 java_library {
135 name: "bar",
136 srcs: ["b.java"],
137 }
138
139 java_library {
140 name: "baz",
141 srcs: ["c.java"],
142 }
Colin Crossd5934c82017-10-02 13:55:26 -0700143 `)
Colin Cross72bb3632017-07-13 16:23:21 -0700144
Colin Cross4c428df2017-09-15 17:36:05 -0700145 javac := ctx.ModuleForTests("foo", "android_common").Rule("javac")
146 combineJar := ctx.ModuleForTests("foo", "android_common").Rule("combineJar")
Colin Cross72bb3632017-07-13 16:23:21 -0700147
148 if len(javac.Inputs) != 1 || javac.Inputs[0].String() != "a.java" {
149 t.Errorf(`foo inputs %v != ["a.java"]`, javac.Inputs)
150 }
151
Colin Cross8649b262017-09-27 18:03:17 -0700152 bar := filepath.Join(buildDir, ".intermediates", "bar", "android_common", "classes-compiled.jar")
153 baz := filepath.Join(buildDir, ".intermediates", "baz", "android_common", "classes-compiled.jar")
Colin Cross0a6e0072017-08-30 14:24:55 -0700154
Colin Cross72bb3632017-07-13 16:23:21 -0700155 if !strings.Contains(javac.Args["classpath"], bar) {
156 t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], bar)
157 }
158
Colin Cross0a6e0072017-08-30 14:24:55 -0700159 if !strings.Contains(javac.Args["classpath"], baz) {
160 t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], baz)
161 }
162
163 if len(combineJar.Inputs) != 2 || combineJar.Inputs[1].String() != baz {
164 t.Errorf("foo combineJar inputs %v does not contain %q", combineJar.Inputs, baz)
Colin Cross72bb3632017-07-13 16:23:21 -0700165 }
166}
167
Colin Crossd5934c82017-10-02 13:55:26 -0700168func TestArchSpecific(t *testing.T) {
169 ctx := testJava(t, `
170 java_library {
171 name: "foo",
172 srcs: ["a.java"],
173 target: {
174 android: {
175 srcs: ["b.java"],
176 },
177 },
178 }
179 `)
180
181 javac := ctx.ModuleForTests("foo", "android_common").Rule("javac")
182 if len(javac.Inputs) != 2 || javac.Inputs[0].String() != "a.java" || javac.Inputs[1].String() != "b.java" {
183 t.Errorf(`foo inputs %v != ["a.java", "b.java"]`, javac.Inputs)
184 }
185}
186
Colin Cross2acdae82017-09-15 19:44:24 -0700187var classpathTestcases = []struct {
188 name string
Colin Cross965714f2017-10-03 20:57:01 -0700189 moduleType string
Colin Cross2acdae82017-09-15 19:44:24 -0700190 host android.OsClass
191 properties string
192 bootclasspath []string
193 classpath []string
194}{
195 {
196 name: "default",
197 bootclasspath: []string{"core-oj", "core-libart"},
198 classpath: []string{"ext", "framework", "okhttp"},
199 },
200 {
201 name: "blank sdk version",
202 properties: `sdk_version: "",`,
203 bootclasspath: []string{"core-oj", "core-libart"},
204 classpath: []string{"ext", "framework", "okhttp"},
205 },
206 {
Colin Cross4c428df2017-09-15 17:36:05 -0700207
Colin Cross2acdae82017-09-15 19:44:24 -0700208 name: "sdk v14",
209 properties: `sdk_version: "14",`,
Colin Crossfc3674a2017-09-18 17:41:52 -0700210 bootclasspath: []string{`""`},
211 classpath: []string{"prebuilts/sdk/14/android.jar"},
Colin Cross2acdae82017-09-15 19:44:24 -0700212 },
213 {
Colin Cross72bb3632017-07-13 16:23:21 -0700214
Colin Cross2acdae82017-09-15 19:44:24 -0700215 name: "current",
216 properties: `sdk_version: "current",`,
217 bootclasspath: []string{"android_stubs_current"},
218 classpath: []string{},
219 },
220 {
Colin Cross72bb3632017-07-13 16:23:21 -0700221
Colin Cross2acdae82017-09-15 19:44:24 -0700222 name: "system_current",
223 properties: `sdk_version: "system_current",`,
224 bootclasspath: []string{"android_system_stubs_current"},
225 classpath: []string{},
226 },
227 {
Colin Cross72bb3632017-07-13 16:23:21 -0700228
Colin Cross2acdae82017-09-15 19:44:24 -0700229 name: "test_current",
230 properties: `sdk_version: "test_current",`,
231 bootclasspath: []string{"android_test_stubs_current"},
232 classpath: []string{},
233 },
234 {
Colin Cross72bb3632017-07-13 16:23:21 -0700235
Colin Cross2acdae82017-09-15 19:44:24 -0700236 name: "nostdlib",
237 properties: `no_standard_libs: true`,
238 bootclasspath: []string{`""`},
239 classpath: []string{},
240 },
241 {
Colin Cross72bb3632017-07-13 16:23:21 -0700242
Colin Cross2acdae82017-09-15 19:44:24 -0700243 name: "host default",
Colin Cross965714f2017-10-03 20:57:01 -0700244 moduleType: "java_library_host",
Colin Cross2acdae82017-09-15 19:44:24 -0700245 properties: ``,
Colin Cross965714f2017-10-03 20:57:01 -0700246 host: android.Host,
Colin Cross2acdae82017-09-15 19:44:24 -0700247 classpath: []string{},
248 },
249 {
250 name: "host nostdlib",
Colin Cross965714f2017-10-03 20:57:01 -0700251 moduleType: "java_library_host",
Colin Cross2acdae82017-09-15 19:44:24 -0700252 host: android.Host,
253 properties: `no_standard_libs: true`,
254 classpath: []string{},
255 },
Colin Cross965714f2017-10-03 20:57:01 -0700256 {
257
258 name: "host supported default",
259 host: android.Host,
260 properties: `host_supported: true,`,
261 classpath: []string{},
262 },
263 {
264 name: "host supported nostdlib",
265 host: android.Host,
266 properties: `host_supported: true, no_standard_libs: true`,
267 classpath: []string{},
268 },
Colin Cross2acdae82017-09-15 19:44:24 -0700269}
Colin Cross72bb3632017-07-13 16:23:21 -0700270
Colin Cross2acdae82017-09-15 19:44:24 -0700271func TestClasspath(t *testing.T) {
272 for _, testcase := range classpathTestcases {
273 t.Run(testcase.name, func(t *testing.T) {
Colin Cross965714f2017-10-03 20:57:01 -0700274 moduleType := "java_library"
275 if testcase.moduleType != "" {
276 moduleType = testcase.moduleType
Colin Cross2acdae82017-09-15 19:44:24 -0700277 }
Colin Cross965714f2017-10-03 20:57:01 -0700278 ctx := testJava(t, moduleType+` {
Colin Cross2acdae82017-09-15 19:44:24 -0700279 name: "foo",
280 srcs: ["a.java"],
281 `+testcase.properties+`
282 }
283 `)
Colin Cross72bb3632017-07-13 16:23:21 -0700284
Colin Cross2acdae82017-09-15 19:44:24 -0700285 convertModulesToPaths := func(cp []string) []string {
286 ret := make([]string, len(cp))
287 for i, e := range cp {
288 ret[i] = moduleToPath(e)
289 }
290 return ret
291 }
Colin Cross72bb3632017-07-13 16:23:21 -0700292
Colin Cross2acdae82017-09-15 19:44:24 -0700293 bootclasspath := convertModulesToPaths(testcase.bootclasspath)
294 classpath := convertModulesToPaths(testcase.classpath)
Colin Cross72bb3632017-07-13 16:23:21 -0700295
Colin Cross2acdae82017-09-15 19:44:24 -0700296 variant := "android_common"
297 if testcase.host == android.Host {
298 variant = android.BuildOs.String() + "_common"
299 }
300 javac := ctx.ModuleForTests("foo", variant).Rule("javac")
301
Colin Cross72bb3632017-07-13 16:23:21 -0700302 got := strings.TrimPrefix(javac.Args["bootClasspath"], "-bootclasspath ")
Colin Cross2acdae82017-09-15 19:44:24 -0700303 bc := strings.Join(bootclasspath, ":")
304 if got != bc {
305 t.Errorf("bootclasspath expected %q != got %q", bc, got)
Colin Cross72bb3632017-07-13 16:23:21 -0700306 }
Colin Cross72bb3632017-07-13 16:23:21 -0700307
Colin Cross2acdae82017-09-15 19:44:24 -0700308 got = strings.TrimPrefix(javac.Args["classpath"], "-classpath ")
309 c := strings.Join(classpath, ":")
310 if got != c {
311 t.Errorf("classpath expected %q != got %q", c, got)
312 }
313
314 var deps []string
315 if len(bootclasspath) > 0 && bootclasspath[0] != `""` {
316 deps = append(deps, bootclasspath...)
317 }
318 deps = append(deps, classpath...)
319
320 if !reflect.DeepEqual(javac.Implicits.Strings(), deps) {
321 t.Errorf("implicits expected %q != got %q", deps, javac.Implicits.Strings())
322 }
323 })
Colin Cross72bb3632017-07-13 16:23:21 -0700324 }
325
Colin Cross72bb3632017-07-13 16:23:21 -0700326}
327
328func TestPrebuilts(t *testing.T) {
329 ctx := testJava(t, `
330 java_library {
331 name: "foo",
332 srcs: ["a.java"],
Colin Crosse8dc34a2017-07-19 11:22:16 -0700333 libs: ["bar"],
334 static_libs: ["baz"],
Colin Cross72bb3632017-07-13 16:23:21 -0700335 }
336
Colin Cross74d73e22017-08-02 11:05:49 -0700337 java_import {
Colin Cross72bb3632017-07-13 16:23:21 -0700338 name: "bar",
Colin Cross74d73e22017-08-02 11:05:49 -0700339 jars: ["a.jar"],
Colin Cross72bb3632017-07-13 16:23:21 -0700340 }
341
Colin Cross74d73e22017-08-02 11:05:49 -0700342 java_import {
Colin Cross72bb3632017-07-13 16:23:21 -0700343 name: "baz",
Colin Cross74d73e22017-08-02 11:05:49 -0700344 jars: ["b.jar"],
Colin Cross72bb3632017-07-13 16:23:21 -0700345 }
346 `)
347
Colin Cross4c428df2017-09-15 17:36:05 -0700348 javac := ctx.ModuleForTests("foo", "android_common").Rule("javac")
349 combineJar := ctx.ModuleForTests("foo", "android_common").Rule("combineJar")
Colin Cross72bb3632017-07-13 16:23:21 -0700350
351 bar := "a.jar"
352 if !strings.Contains(javac.Args["classpath"], bar) {
353 t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], bar)
354 }
355
Colin Cross0a6e0072017-08-30 14:24:55 -0700356 if len(combineJar.Inputs) != 2 || combineJar.Inputs[1].String() != "b.jar" {
357 t.Errorf("foo combineJar inputs %v does not contain %q", combineJar.Inputs, "b.jar")
Colin Cross72bb3632017-07-13 16:23:21 -0700358 }
359}
360
Colin Cross89536d42017-07-07 14:35:50 -0700361func TestDefaults(t *testing.T) {
362 ctx := testJava(t, `
363 java_defaults {
364 name: "defaults",
365 srcs: ["a.java"],
366 libs: ["bar"],
367 static_libs: ["baz"],
368 }
369
370 java_library {
371 name: "foo",
372 defaults: ["defaults"],
373 }
374
375 java_library {
376 name: "bar",
377 srcs: ["b.java"],
378 }
379
380 java_library {
381 name: "baz",
382 srcs: ["c.java"],
383 }
384 `)
385
Colin Cross4c428df2017-09-15 17:36:05 -0700386 javac := ctx.ModuleForTests("foo", "android_common").Rule("javac")
387 combineJar := ctx.ModuleForTests("foo", "android_common").Rule("combineJar")
Colin Cross89536d42017-07-07 14:35:50 -0700388
389 if len(javac.Inputs) != 1 || javac.Inputs[0].String() != "a.java" {
390 t.Errorf(`foo inputs %v != ["a.java"]`, javac.Inputs)
391 }
392
Colin Cross8649b262017-09-27 18:03:17 -0700393 bar := filepath.Join(buildDir, ".intermediates", "bar", "android_common", "classes-compiled.jar")
Colin Cross89536d42017-07-07 14:35:50 -0700394 if !strings.Contains(javac.Args["classpath"], bar) {
395 t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], bar)
396 }
397
Colin Cross8649b262017-09-27 18:03:17 -0700398 baz := filepath.Join(buildDir, ".intermediates", "baz", "android_common", "classes-compiled.jar")
Colin Cross0a6e0072017-08-30 14:24:55 -0700399 if len(combineJar.Inputs) != 2 || combineJar.Inputs[1].String() != baz {
400 t.Errorf("foo combineJar inputs %v does not contain %q", combineJar.Inputs, baz)
Colin Cross89536d42017-07-07 14:35:50 -0700401 }
402}
403
Colin Cross0f37af02017-09-27 17:42:05 -0700404func TestResources(t *testing.T) {
405 var table = []struct {
406 name string
407 prop string
408 extra string
409 args string
410 }{
411 {
Colin Crossaf9c55b2017-10-03 14:50:08 -0700412 // Test that a module with java_resource_dirs includes the files
Colin Cross0f37af02017-09-27 17:42:05 -0700413 name: "resource dirs",
414 prop: `java_resource_dirs: ["res"]`,
Colin Crossaf9c55b2017-10-03 14:50:08 -0700415 args: "-C res -f res/a -f res/b",
Colin Cross0f37af02017-09-27 17:42:05 -0700416 },
417 {
418 // Test that a module with java_resources includes the files
419 name: "resource files",
420 prop: `java_resources: ["res/a", "res/b"]`,
Colin Crossaf9c55b2017-10-03 14:50:08 -0700421 args: "-C . -f res/a -f res/b",
Colin Cross0f37af02017-09-27 17:42:05 -0700422 },
423 {
424 // Test that a module with a filegroup in java_resources includes the files with the
425 // path prefix
426 name: "resource filegroup",
427 prop: `java_resources: [":foo-res"]`,
428 extra: `
429 filegroup {
430 name: "foo-res",
431 path: "res",
432 srcs: ["res/a", "res/b"],
433 }`,
Colin Crossaf9c55b2017-10-03 14:50:08 -0700434 args: "-C res -f res/a -f res/b",
Colin Cross0f37af02017-09-27 17:42:05 -0700435 },
436 {
437 // Test that a module with "include_srcs: true" includes its source files in the resources jar
438 name: "include sources",
439 prop: `include_srcs: true`,
Colin Crossaf9c55b2017-10-03 14:50:08 -0700440 args: "-C . -f a.java -f b.java -f c.java",
Colin Cross0f37af02017-09-27 17:42:05 -0700441 },
442 }
443
444 for _, test := range table {
445 t.Run(test.name, func(t *testing.T) {
446 ctx := testJava(t, `
447 java_library {
448 name: "foo",
449 srcs: [
450 "a.java",
451 "b.java",
452 "c.java",
453 ],
454 `+test.prop+`,
455 }
456 `+test.extra)
457
458 foo := ctx.ModuleForTests("foo", "android_common").Output("classes.jar")
459 fooRes := ctx.ModuleForTests("foo", "android_common").Output("res.jar")
460
461 if !inList(fooRes.Output.String(), foo.Inputs.Strings()) {
462 t.Errorf("foo combined jars %v does not contain %q",
463 foo.Inputs.Strings(), fooRes.Output.String())
464 }
465
Colin Crossaf9c55b2017-10-03 14:50:08 -0700466 if fooRes.Args["jarArgs"] != test.args {
467 t.Errorf("foo resource jar args %q is not %q",
Colin Cross0f37af02017-09-27 17:42:05 -0700468 fooRes.Args["jarArgs"], test.args)
469 }
470 })
471 }
472}
473
Colin Cross0532fb02017-10-02 16:57:40 -0700474func TestExcludeResources(t *testing.T) {
475 ctx := testJava(t, `
476 java_library {
477 name: "foo",
478 srcs: ["a.java"],
479 java_resource_dirs: ["res", "res2"],
480 exclude_java_resource_dirs: ["res2"],
481 }
482
483 java_library {
484 name: "bar",
485 srcs: ["a.java"],
486 java_resources: ["res/*"],
487 exclude_java_resources: ["res/b"],
488 }
489 `)
490
491 fooRes := ctx.ModuleForTests("foo", "android_common").Output("res.jar")
492
Colin Crossaf9c55b2017-10-03 14:50:08 -0700493 expected := "-C res -f res/a -f res/b"
Colin Cross0532fb02017-10-02 16:57:40 -0700494 if fooRes.Args["jarArgs"] != expected {
495 t.Errorf("foo resource jar args %q is not %q",
496 fooRes.Args["jarArgs"], expected)
497
498 }
499
500 barRes := ctx.ModuleForTests("bar", "android_common").Output("res.jar")
501
502 expected = "-C . -f res/a"
503 if barRes.Args["jarArgs"] != expected {
504 t.Errorf("bar resource jar args %q is not %q",
505 barRes.Args["jarArgs"], expected)
506
507 }
508}
509
Colin Cross54190b32017-10-09 15:34:10 -0700510func TestGeneratedSources(t *testing.T) {
511 ctx := testJava(t, `
512 java_library {
513 name: "foo",
514 srcs: [
515 "a*.java",
516 ":gen",
517 "b*.java",
518 ],
519 }
520
521 genrule {
522 name: "gen",
523 tool_files: ["res/a"],
524 out: ["gen.java"],
525 }
526 `)
527
528 javac := ctx.ModuleForTests("foo", "android_common").Rule("javac")
529 genrule := ctx.ModuleForTests("gen", "").Rule("generator")
530
531 if len(genrule.Outputs) != 1 || filepath.Base(genrule.Outputs[0].String()) != "gen.java" {
532 t.Fatalf(`gen output file %v is not [".../gen.java"]`, genrule.Outputs.Strings())
533 }
534
535 if len(javac.Inputs) != 3 ||
536 javac.Inputs[0].String() != "a.java" ||
537 javac.Inputs[1].String() != genrule.Outputs[0].String() ||
538 javac.Inputs[2].String() != "b.java" {
539 t.Errorf(`foo inputs %v != ["a.java", ".../gen.java", "b.java"]`, javac.Inputs)
540 }
541}
542
Colin Cross72bb3632017-07-13 16:23:21 -0700543func fail(t *testing.T, errs []error) {
544 if len(errs) > 0 {
545 for _, err := range errs {
546 t.Error(err)
547 }
548 t.FailNow()
549 }
550}