Colin Cross | 1d2b6b3 | 2021-06-01 13:18:08 -0700 | [diff] [blame] | 1 | // Copyright 2021 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 java |
| 16 | |
| 17 | import ( |
| 18 | "android/soong/android" |
| 19 | "fmt" |
| 20 | "path/filepath" |
| 21 | "regexp" |
| 22 | "testing" |
| 23 | |
| 24 | "github.com/google/blueprint/proptools" |
| 25 | ) |
| 26 | |
| 27 | func TestJavaSdkLibrary(t *testing.T) { |
| 28 | result := android.GroupFixturePreparers( |
| 29 | prepareForJavaTest, |
| 30 | PrepareForTestWithJavaSdkLibraryFiles, |
| 31 | FixtureWithPrebuiltApis(map[string][]string{ |
| 32 | "28": {"foo"}, |
| 33 | "29": {"foo"}, |
| 34 | "30": {"bar", "barney", "baz", "betty", "foo", "fred", "quuz", "wilma"}, |
| 35 | }), |
| 36 | ).RunTestWithBp(t, ` |
| 37 | droiddoc_exported_dir { |
| 38 | name: "droiddoc-templates-sdk", |
| 39 | path: ".", |
| 40 | } |
| 41 | java_sdk_library { |
| 42 | name: "foo", |
| 43 | srcs: ["a.java", "b.java"], |
| 44 | api_packages: ["foo"], |
| 45 | } |
| 46 | java_sdk_library { |
| 47 | name: "bar", |
| 48 | srcs: ["a.java", "b.java"], |
| 49 | api_packages: ["bar"], |
| 50 | } |
| 51 | java_library { |
| 52 | name: "baz", |
| 53 | srcs: ["c.java"], |
| 54 | libs: ["foo", "bar.stubs"], |
| 55 | sdk_version: "system_current", |
| 56 | } |
| 57 | java_sdk_library { |
| 58 | name: "barney", |
| 59 | srcs: ["c.java"], |
| 60 | api_only: true, |
| 61 | } |
| 62 | java_sdk_library { |
| 63 | name: "betty", |
| 64 | srcs: ["c.java"], |
| 65 | shared_library: false, |
| 66 | } |
| 67 | java_sdk_library_import { |
| 68 | name: "quuz", |
| 69 | public: { |
| 70 | jars: ["c.jar"], |
| 71 | }, |
| 72 | } |
| 73 | java_sdk_library_import { |
| 74 | name: "fred", |
| 75 | public: { |
| 76 | jars: ["b.jar"], |
| 77 | }, |
| 78 | } |
| 79 | java_sdk_library_import { |
| 80 | name: "wilma", |
| 81 | public: { |
| 82 | jars: ["b.jar"], |
| 83 | }, |
| 84 | shared_library: false, |
| 85 | } |
| 86 | java_library { |
| 87 | name: "qux", |
| 88 | srcs: ["c.java"], |
| 89 | libs: ["baz", "fred", "quuz.stubs", "wilma", "barney", "betty"], |
| 90 | sdk_version: "system_current", |
| 91 | } |
| 92 | java_library { |
| 93 | name: "baz-test", |
| 94 | srcs: ["c.java"], |
| 95 | libs: ["foo"], |
| 96 | sdk_version: "test_current", |
| 97 | } |
| 98 | java_library { |
| 99 | name: "baz-29", |
| 100 | srcs: ["c.java"], |
| 101 | libs: ["foo"], |
| 102 | sdk_version: "system_29", |
| 103 | } |
| 104 | java_library { |
| 105 | name: "baz-module-30", |
| 106 | srcs: ["c.java"], |
| 107 | libs: ["foo"], |
| 108 | sdk_version: "module_30", |
| 109 | } |
Pedro Loureiro | 826863c | 2021-09-07 17:21:59 +0000 | [diff] [blame^] | 110 | `) |
Colin Cross | 1d2b6b3 | 2021-06-01 13:18:08 -0700 | [diff] [blame] | 111 | |
| 112 | // check the existence of the internal modules |
Paul Duffin | b97b157 | 2021-04-29 21:50:40 +0100 | [diff] [blame] | 113 | foo := result.ModuleForTests("foo", "android_common") |
Colin Cross | 1d2b6b3 | 2021-06-01 13:18:08 -0700 | [diff] [blame] | 114 | result.ModuleForTests(apiScopePublic.stubsLibraryModuleName("foo"), "android_common") |
| 115 | result.ModuleForTests(apiScopeSystem.stubsLibraryModuleName("foo"), "android_common") |
| 116 | result.ModuleForTests(apiScopeTest.stubsLibraryModuleName("foo"), "android_common") |
| 117 | result.ModuleForTests(apiScopePublic.stubsSourceModuleName("foo"), "android_common") |
| 118 | result.ModuleForTests(apiScopeSystem.stubsSourceModuleName("foo"), "android_common") |
| 119 | result.ModuleForTests(apiScopeTest.stubsSourceModuleName("foo"), "android_common") |
| 120 | result.ModuleForTests("foo"+sdkXmlFileSuffix, "android_common") |
| 121 | result.ModuleForTests("foo.api.public.28", "") |
| 122 | result.ModuleForTests("foo.api.system.28", "") |
| 123 | result.ModuleForTests("foo.api.test.28", "") |
| 124 | |
Paul Duffin | 9fc208e | 2021-06-27 20:42:04 +0100 | [diff] [blame] | 125 | exportedComponentsInfo := result.ModuleProvider(foo.Module(), android.ExportedComponentsInfoProvider).(android.ExportedComponentsInfo) |
Paul Duffin | b97b157 | 2021-04-29 21:50:40 +0100 | [diff] [blame] | 126 | expectedFooExportedComponents := []string{ |
| 127 | "foo.stubs", |
| 128 | "foo.stubs.source", |
| 129 | "foo.stubs.source.system", |
| 130 | "foo.stubs.source.test", |
| 131 | "foo.stubs.system", |
| 132 | "foo.stubs.test", |
| 133 | } |
| 134 | android.AssertArrayString(t, "foo exported components", expectedFooExportedComponents, exportedComponentsInfo.Components) |
| 135 | |
Colin Cross | 1d2b6b3 | 2021-06-01 13:18:08 -0700 | [diff] [blame] | 136 | bazJavac := result.ModuleForTests("baz", "android_common").Rule("javac") |
| 137 | // tests if baz is actually linked to the stubs lib |
| 138 | android.AssertStringDoesContain(t, "baz javac classpath", bazJavac.Args["classpath"], "foo.stubs.system.jar") |
| 139 | // ... and not to the impl lib |
| 140 | android.AssertStringDoesNotContain(t, "baz javac classpath", bazJavac.Args["classpath"], "foo.jar") |
| 141 | // test if baz is not linked to the system variant of foo |
| 142 | android.AssertStringDoesNotContain(t, "baz javac classpath", bazJavac.Args["classpath"], "foo.stubs.jar") |
| 143 | |
| 144 | bazTestJavac := result.ModuleForTests("baz-test", "android_common").Rule("javac") |
| 145 | // tests if baz-test is actually linked to the test stubs lib |
| 146 | android.AssertStringDoesContain(t, "baz-test javac classpath", bazTestJavac.Args["classpath"], "foo.stubs.test.jar") |
| 147 | |
| 148 | baz29Javac := result.ModuleForTests("baz-29", "android_common").Rule("javac") |
| 149 | // tests if baz-29 is actually linked to the system 29 stubs lib |
| 150 | android.AssertStringDoesContain(t, "baz-29 javac classpath", baz29Javac.Args["classpath"], "prebuilts/sdk/29/system/foo.jar") |
| 151 | |
| 152 | bazModule30Javac := result.ModuleForTests("baz-module-30", "android_common").Rule("javac") |
| 153 | // tests if "baz-module-30" is actually linked to the module 30 stubs lib |
| 154 | android.AssertStringDoesContain(t, "baz-module-30 javac classpath", bazModule30Javac.Args["classpath"], "prebuilts/sdk/30/module-lib/foo.jar") |
| 155 | |
| 156 | // test if baz has exported SDK lib names foo and bar to qux |
| 157 | qux := result.ModuleForTests("qux", "android_common") |
| 158 | if quxLib, ok := qux.Module().(*Library); ok { |
Ulya Trafimovich | fc0f6e3 | 2021-08-12 16:16:11 +0100 | [diff] [blame] | 159 | requiredSdkLibs, optionalSdkLibs := quxLib.ClassLoaderContexts().UsesLibs() |
Ulya Trafimovich | e443287 | 2021-08-18 16:57:11 +0100 | [diff] [blame] | 160 | android.AssertDeepEquals(t, "qux exports (required)", []string{"fred", "quuz", "foo", "bar"}, requiredSdkLibs) |
Ulya Trafimovich | fc0f6e3 | 2021-08-12 16:16:11 +0100 | [diff] [blame] | 161 | android.AssertDeepEquals(t, "qux exports (optional)", []string{}, optionalSdkLibs) |
Colin Cross | 1d2b6b3 | 2021-06-01 13:18:08 -0700 | [diff] [blame] | 162 | } |
| 163 | } |
| 164 | |
Pedro Loureiro | 826863c | 2021-09-07 17:21:59 +0000 | [diff] [blame^] | 165 | func TestJavaSdkLibrary_UpdatableLibrary(t *testing.T) { |
| 166 | result := android.GroupFixturePreparers( |
| 167 | prepareForJavaTest, |
| 168 | PrepareForTestWithJavaSdkLibraryFiles, |
| 169 | FixtureWithPrebuiltApis(map[string][]string{ |
| 170 | "28": {"foo"}, |
| 171 | "29": {"foo"}, |
| 172 | "30": {"foo", "fooUpdatable", "fooUpdatableErr"}, |
| 173 | }), |
| 174 | ).RunTestWithBp(t, |
| 175 | ` |
| 176 | java_sdk_library { |
| 177 | name: "fooUpdatable", |
| 178 | srcs: ["a.java", "b.java"], |
| 179 | api_packages: ["foo"], |
| 180 | on_bootclasspath_since: "29", |
| 181 | on_bootclasspath_before: "30", |
| 182 | min_device_sdk: "R", |
| 183 | max_device_sdk: "current", |
| 184 | } |
| 185 | java_sdk_library { |
| 186 | name: "foo", |
| 187 | srcs: ["a.java", "b.java"], |
| 188 | api_packages: ["foo"], |
| 189 | } |
| 190 | `) |
| 191 | // test that updatability attributes are passed on correctly |
| 192 | fooUpdatable := result.ModuleForTests("fooUpdatable.xml", "android_common").Rule("java_sdk_xml") |
| 193 | android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `on_bootclasspath_since=\"29\"`) |
| 194 | android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `on_bootclasspath_before=\"30\"`) |
| 195 | android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `min_device_sdk=\"30\"`) |
| 196 | android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `max_device_sdk=\"10000\"`) |
| 197 | |
| 198 | // double check that updatability attributes are not written if they don't exist in the bp file |
| 199 | // the permissions file for the foo library defined above |
| 200 | fooPermissions := result.ModuleForTests("foo.xml", "android_common").Rule("java_sdk_xml") |
| 201 | android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `on_bootclasspath_since`) |
| 202 | android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `on_bootclasspath_before`) |
| 203 | android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `min_device_sdk`) |
| 204 | android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `max_device_sdk`) |
| 205 | } |
| 206 | |
| 207 | func TestJavaSdkLibrary_UpdatableLibrary_Validation(t *testing.T) { |
| 208 | android.GroupFixturePreparers( |
| 209 | prepareForJavaTest, |
| 210 | PrepareForTestWithJavaSdkLibraryFiles, |
| 211 | FixtureWithPrebuiltApis(map[string][]string{ |
| 212 | "30": {"fooUpdatable", "fooUpdatableErr"}, |
| 213 | }), |
| 214 | ).ExtendWithErrorHandler(android.FixtureExpectsAllErrorsToMatchAPattern( |
| 215 | []string{ |
| 216 | `on_bootclasspath_since: "aaa" could not be parsed as an integer and is not a recognized codename`, |
| 217 | `on_bootclasspath_before: "bbc" could not be parsed as an integer and is not a recognized codename`, |
| 218 | `min_device_sdk: "ccc" could not be parsed as an integer and is not a recognized codename`, |
| 219 | `max_device_sdk: "ddd" could not be parsed as an integer and is not a recognized codename`, |
| 220 | })).RunTestWithBp(t, |
| 221 | ` |
| 222 | java_sdk_library { |
| 223 | name: "fooUpdatableErr", |
| 224 | srcs: ["a.java", "b.java"], |
| 225 | api_packages: ["foo"], |
| 226 | on_bootclasspath_since: "aaa", |
| 227 | on_bootclasspath_before: "bbc", |
| 228 | min_device_sdk: "ccc", |
| 229 | max_device_sdk: "ddd", |
| 230 | } |
| 231 | `) |
| 232 | } |
| 233 | |
Colin Cross | 1d2b6b3 | 2021-06-01 13:18:08 -0700 | [diff] [blame] | 234 | func TestJavaSdkLibrary_StubOrImplOnlyLibs(t *testing.T) { |
| 235 | result := android.GroupFixturePreparers( |
| 236 | prepareForJavaTest, |
| 237 | PrepareForTestWithJavaSdkLibraryFiles, |
| 238 | FixtureWithLastReleaseApis("sdklib"), |
| 239 | ).RunTestWithBp(t, ` |
| 240 | java_sdk_library { |
| 241 | name: "sdklib", |
| 242 | srcs: ["a.java"], |
| 243 | libs: ["lib"], |
| 244 | static_libs: ["static-lib"], |
| 245 | impl_only_libs: ["impl-only-lib"], |
| 246 | stub_only_libs: ["stub-only-lib"], |
| 247 | stub_only_static_libs: ["stub-only-static-lib"], |
| 248 | } |
| 249 | java_defaults { |
| 250 | name: "defaults", |
| 251 | srcs: ["a.java"], |
| 252 | sdk_version: "current", |
| 253 | } |
| 254 | java_library { name: "lib", defaults: ["defaults"] } |
| 255 | java_library { name: "static-lib", defaults: ["defaults"] } |
| 256 | java_library { name: "impl-only-lib", defaults: ["defaults"] } |
| 257 | java_library { name: "stub-only-lib", defaults: ["defaults"] } |
| 258 | java_library { name: "stub-only-static-lib", defaults: ["defaults"] } |
| 259 | `) |
| 260 | var expectations = []struct { |
| 261 | lib string |
| 262 | on_impl_classpath bool |
| 263 | on_stub_classpath bool |
| 264 | in_impl_combined bool |
| 265 | in_stub_combined bool |
| 266 | }{ |
| 267 | {lib: "lib", on_impl_classpath: true}, |
| 268 | {lib: "static-lib", in_impl_combined: true}, |
| 269 | {lib: "impl-only-lib", on_impl_classpath: true}, |
| 270 | {lib: "stub-only-lib", on_stub_classpath: true}, |
| 271 | {lib: "stub-only-static-lib", in_stub_combined: true}, |
| 272 | } |
| 273 | verify := func(sdklib, dep string, cp, combined bool) { |
| 274 | sdklibCp := result.ModuleForTests(sdklib, "android_common").Rule("javac").Args["classpath"] |
| 275 | expected := cp || combined // Every combined jar is also on the classpath. |
| 276 | android.AssertStringContainsEquals(t, "bad classpath for "+sdklib, sdklibCp, "/"+dep+".jar", expected) |
| 277 | |
| 278 | combineJarInputs := result.ModuleForTests(sdklib, "android_common").Rule("combineJar").Inputs.Strings() |
| 279 | depPath := filepath.Join("out", "soong", ".intermediates", dep, "android_common", "turbine-combined", dep+".jar") |
| 280 | android.AssertStringListContainsEquals(t, "bad combined inputs for "+sdklib, combineJarInputs, depPath, combined) |
| 281 | } |
| 282 | for _, expectation := range expectations { |
| 283 | verify("sdklib", expectation.lib, expectation.on_impl_classpath, expectation.in_impl_combined) |
| 284 | verify("sdklib.impl", expectation.lib, expectation.on_impl_classpath, expectation.in_impl_combined) |
| 285 | |
| 286 | stubName := apiScopePublic.stubsLibraryModuleName("sdklib") |
| 287 | verify(stubName, expectation.lib, expectation.on_stub_classpath, expectation.in_stub_combined) |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | func TestJavaSdkLibrary_DoNotAccessImplWhenItIsNotBuilt(t *testing.T) { |
| 292 | result := android.GroupFixturePreparers( |
| 293 | prepareForJavaTest, |
| 294 | PrepareForTestWithJavaSdkLibraryFiles, |
| 295 | FixtureWithLastReleaseApis("foo"), |
| 296 | ).RunTestWithBp(t, ` |
| 297 | java_sdk_library { |
| 298 | name: "foo", |
| 299 | srcs: ["a.java"], |
| 300 | api_only: true, |
| 301 | public: { |
| 302 | enabled: true, |
| 303 | }, |
| 304 | } |
| 305 | |
| 306 | java_library { |
| 307 | name: "bar", |
| 308 | srcs: ["b.java"], |
| 309 | libs: ["foo"], |
| 310 | } |
| 311 | `) |
| 312 | |
| 313 | // The bar library should depend on the stubs jar. |
| 314 | barLibrary := result.ModuleForTests("bar", "android_common").Rule("javac") |
| 315 | if expected, actual := `^-classpath .*:out/soong/[^:]*/turbine-combined/foo\.stubs\.jar$`, barLibrary.Args["classpath"]; !regexp.MustCompile(expected).MatchString(actual) { |
| 316 | t.Errorf("expected %q, found %#q", expected, actual) |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | func TestJavaSdkLibrary_UseSourcesFromAnotherSdkLibrary(t *testing.T) { |
| 321 | android.GroupFixturePreparers( |
| 322 | prepareForJavaTest, |
| 323 | PrepareForTestWithJavaSdkLibraryFiles, |
| 324 | FixtureWithLastReleaseApis("foo"), |
| 325 | ).RunTestWithBp(t, ` |
| 326 | java_sdk_library { |
| 327 | name: "foo", |
| 328 | srcs: ["a.java"], |
| 329 | api_packages: ["foo"], |
| 330 | public: { |
| 331 | enabled: true, |
| 332 | }, |
| 333 | } |
| 334 | |
| 335 | java_library { |
| 336 | name: "bar", |
| 337 | srcs: ["b.java", ":foo{.public.stubs.source}"], |
| 338 | } |
| 339 | `) |
| 340 | } |
| 341 | |
| 342 | func TestJavaSdkLibrary_AccessOutputFiles_MissingScope(t *testing.T) { |
| 343 | android.GroupFixturePreparers( |
| 344 | prepareForJavaTest, |
| 345 | PrepareForTestWithJavaSdkLibraryFiles, |
| 346 | FixtureWithLastReleaseApis("foo"), |
| 347 | ). |
| 348 | ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`"foo" does not provide api scope system`)). |
| 349 | RunTestWithBp(t, ` |
| 350 | java_sdk_library { |
| 351 | name: "foo", |
| 352 | srcs: ["a.java"], |
| 353 | api_packages: ["foo"], |
| 354 | public: { |
| 355 | enabled: true, |
| 356 | }, |
| 357 | } |
| 358 | |
| 359 | java_library { |
| 360 | name: "bar", |
| 361 | srcs: ["b.java", ":foo{.system.stubs.source}"], |
| 362 | } |
| 363 | `) |
| 364 | } |
| 365 | |
| 366 | func TestJavaSdkLibrary_Deps(t *testing.T) { |
| 367 | result := android.GroupFixturePreparers( |
| 368 | prepareForJavaTest, |
| 369 | PrepareForTestWithJavaSdkLibraryFiles, |
| 370 | FixtureWithLastReleaseApis("sdklib"), |
| 371 | ).RunTestWithBp(t, ` |
| 372 | java_sdk_library { |
| 373 | name: "sdklib", |
| 374 | srcs: ["a.java"], |
| 375 | sdk_version: "none", |
| 376 | system_modules: "none", |
| 377 | public: { |
| 378 | enabled: true, |
| 379 | }, |
| 380 | } |
| 381 | `) |
| 382 | |
| 383 | CheckModuleDependencies(t, result.TestContext, "sdklib", "android_common", []string{ |
| 384 | `dex2oatd`, |
| 385 | `sdklib.impl`, |
| 386 | `sdklib.stubs`, |
| 387 | `sdklib.stubs.source`, |
| 388 | `sdklib.xml`, |
| 389 | }) |
| 390 | } |
| 391 | |
| 392 | func TestJavaSdkLibraryImport_AccessOutputFiles(t *testing.T) { |
| 393 | prepareForJavaTest.RunTestWithBp(t, ` |
| 394 | java_sdk_library_import { |
| 395 | name: "foo", |
| 396 | public: { |
| 397 | jars: ["a.jar"], |
| 398 | stub_srcs: ["a.java"], |
| 399 | current_api: "api/current.txt", |
| 400 | removed_api: "api/removed.txt", |
| 401 | }, |
| 402 | } |
| 403 | |
| 404 | java_library { |
| 405 | name: "bar", |
| 406 | srcs: [":foo{.public.stubs.source}"], |
| 407 | java_resources: [ |
| 408 | ":foo{.public.api.txt}", |
| 409 | ":foo{.public.removed-api.txt}", |
| 410 | ], |
| 411 | } |
| 412 | `) |
| 413 | } |
| 414 | |
| 415 | func TestJavaSdkLibraryImport_AccessOutputFiles_Invalid(t *testing.T) { |
| 416 | bp := ` |
| 417 | java_sdk_library_import { |
| 418 | name: "foo", |
| 419 | public: { |
| 420 | jars: ["a.jar"], |
| 421 | }, |
| 422 | } |
| 423 | ` |
| 424 | |
| 425 | t.Run("stubs.source", func(t *testing.T) { |
| 426 | prepareForJavaTest. |
| 427 | ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`stubs.source not available for api scope public`)). |
| 428 | RunTestWithBp(t, bp+` |
| 429 | java_library { |
| 430 | name: "bar", |
| 431 | srcs: [":foo{.public.stubs.source}"], |
| 432 | java_resources: [ |
| 433 | ":foo{.public.api.txt}", |
| 434 | ":foo{.public.removed-api.txt}", |
| 435 | ], |
| 436 | } |
| 437 | `) |
| 438 | }) |
| 439 | |
| 440 | t.Run("api.txt", func(t *testing.T) { |
| 441 | prepareForJavaTest. |
| 442 | ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`api.txt not available for api scope public`)). |
| 443 | RunTestWithBp(t, bp+` |
| 444 | java_library { |
| 445 | name: "bar", |
| 446 | srcs: ["a.java"], |
| 447 | java_resources: [ |
| 448 | ":foo{.public.api.txt}", |
| 449 | ], |
| 450 | } |
| 451 | `) |
| 452 | }) |
| 453 | |
| 454 | t.Run("removed-api.txt", func(t *testing.T) { |
| 455 | prepareForJavaTest. |
| 456 | ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`removed-api.txt not available for api scope public`)). |
| 457 | RunTestWithBp(t, bp+` |
| 458 | java_library { |
| 459 | name: "bar", |
| 460 | srcs: ["a.java"], |
| 461 | java_resources: [ |
| 462 | ":foo{.public.removed-api.txt}", |
| 463 | ], |
| 464 | } |
| 465 | `) |
| 466 | }) |
| 467 | } |
| 468 | |
| 469 | func TestJavaSdkLibrary_InvalidScopes(t *testing.T) { |
| 470 | prepareForJavaTest. |
| 471 | ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "foo": enabled api scope "system" depends on disabled scope "public"`)). |
| 472 | RunTestWithBp(t, ` |
| 473 | java_sdk_library { |
| 474 | name: "foo", |
| 475 | srcs: ["a.java", "b.java"], |
| 476 | api_packages: ["foo"], |
| 477 | // Explicitly disable public to test the check that ensures the set of enabled |
| 478 | // scopes is consistent. |
| 479 | public: { |
| 480 | enabled: false, |
| 481 | }, |
| 482 | system: { |
| 483 | enabled: true, |
| 484 | }, |
| 485 | } |
| 486 | `) |
| 487 | } |
| 488 | |
| 489 | func TestJavaSdkLibrary_SdkVersion_ForScope(t *testing.T) { |
| 490 | android.GroupFixturePreparers( |
| 491 | prepareForJavaTest, |
| 492 | PrepareForTestWithJavaSdkLibraryFiles, |
| 493 | FixtureWithLastReleaseApis("foo"), |
| 494 | ).RunTestWithBp(t, ` |
| 495 | java_sdk_library { |
| 496 | name: "foo", |
| 497 | srcs: ["a.java", "b.java"], |
| 498 | api_packages: ["foo"], |
| 499 | system: { |
| 500 | enabled: true, |
| 501 | sdk_version: "module_current", |
| 502 | }, |
| 503 | } |
| 504 | `) |
| 505 | } |
| 506 | |
| 507 | func TestJavaSdkLibrary_ModuleLib(t *testing.T) { |
| 508 | android.GroupFixturePreparers( |
| 509 | prepareForJavaTest, |
| 510 | PrepareForTestWithJavaSdkLibraryFiles, |
| 511 | FixtureWithLastReleaseApis("foo"), |
| 512 | ).RunTestWithBp(t, ` |
| 513 | java_sdk_library { |
| 514 | name: "foo", |
| 515 | srcs: ["a.java", "b.java"], |
| 516 | api_packages: ["foo"], |
| 517 | system: { |
| 518 | enabled: true, |
| 519 | }, |
| 520 | module_lib: { |
| 521 | enabled: true, |
| 522 | }, |
| 523 | } |
| 524 | `) |
| 525 | } |
| 526 | |
| 527 | func TestJavaSdkLibrary_SystemServer(t *testing.T) { |
| 528 | android.GroupFixturePreparers( |
| 529 | prepareForJavaTest, |
| 530 | PrepareForTestWithJavaSdkLibraryFiles, |
| 531 | FixtureWithLastReleaseApis("foo"), |
| 532 | ).RunTestWithBp(t, ` |
| 533 | java_sdk_library { |
| 534 | name: "foo", |
| 535 | srcs: ["a.java", "b.java"], |
| 536 | api_packages: ["foo"], |
| 537 | system: { |
| 538 | enabled: true, |
| 539 | }, |
| 540 | system_server: { |
| 541 | enabled: true, |
| 542 | }, |
| 543 | } |
| 544 | `) |
| 545 | } |
| 546 | |
| 547 | func TestJavaSdkLibrary_MissingScope(t *testing.T) { |
| 548 | prepareForJavaTest. |
| 549 | ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`requires api scope module-lib from foo but it only has \[\] available`)). |
| 550 | RunTestWithBp(t, ` |
| 551 | java_sdk_library { |
| 552 | name: "foo", |
| 553 | srcs: ["a.java"], |
| 554 | public: { |
| 555 | enabled: false, |
| 556 | }, |
| 557 | } |
| 558 | |
| 559 | java_library { |
| 560 | name: "baz", |
| 561 | srcs: ["a.java"], |
| 562 | libs: ["foo"], |
| 563 | sdk_version: "module_current", |
| 564 | } |
| 565 | `) |
| 566 | } |
| 567 | |
| 568 | func TestJavaSdkLibrary_FallbackScope(t *testing.T) { |
| 569 | android.GroupFixturePreparers( |
| 570 | prepareForJavaTest, |
| 571 | PrepareForTestWithJavaSdkLibraryFiles, |
| 572 | FixtureWithLastReleaseApis("foo"), |
| 573 | ).RunTestWithBp(t, ` |
| 574 | java_sdk_library { |
| 575 | name: "foo", |
| 576 | srcs: ["a.java"], |
| 577 | system: { |
| 578 | enabled: true, |
| 579 | }, |
| 580 | } |
| 581 | |
| 582 | java_library { |
| 583 | name: "baz", |
| 584 | srcs: ["a.java"], |
| 585 | libs: ["foo"], |
| 586 | // foo does not have module-lib scope so it should fallback to system |
| 587 | sdk_version: "module_current", |
| 588 | } |
| 589 | `) |
| 590 | } |
| 591 | |
| 592 | func TestJavaSdkLibrary_DefaultToStubs(t *testing.T) { |
| 593 | result := android.GroupFixturePreparers( |
| 594 | prepareForJavaTest, |
| 595 | PrepareForTestWithJavaSdkLibraryFiles, |
| 596 | FixtureWithLastReleaseApis("foo"), |
| 597 | ).RunTestWithBp(t, ` |
| 598 | java_sdk_library { |
| 599 | name: "foo", |
| 600 | srcs: ["a.java"], |
| 601 | system: { |
| 602 | enabled: true, |
| 603 | }, |
| 604 | default_to_stubs: true, |
| 605 | } |
| 606 | |
| 607 | java_library { |
| 608 | name: "baz", |
| 609 | srcs: ["a.java"], |
| 610 | libs: ["foo"], |
| 611 | // does not have sdk_version set, should fallback to module, |
| 612 | // which will then fallback to system because the module scope |
| 613 | // is not enabled. |
| 614 | } |
| 615 | `) |
| 616 | // The baz library should depend on the system stubs jar. |
| 617 | bazLibrary := result.ModuleForTests("baz", "android_common").Rule("javac") |
| 618 | if expected, actual := `^-classpath .*:out/soong/[^:]*/turbine-combined/foo\.stubs.system\.jar$`, bazLibrary.Args["classpath"]; !regexp.MustCompile(expected).MatchString(actual) { |
| 619 | t.Errorf("expected %q, found %#q", expected, actual) |
| 620 | } |
| 621 | } |
| 622 | |
| 623 | func TestJavaSdkLibraryImport(t *testing.T) { |
| 624 | result := prepareForJavaTest.RunTestWithBp(t, ` |
| 625 | java_library { |
| 626 | name: "foo", |
| 627 | srcs: ["a.java"], |
| 628 | libs: ["sdklib"], |
| 629 | sdk_version: "current", |
| 630 | } |
| 631 | |
| 632 | java_library { |
| 633 | name: "foo.system", |
| 634 | srcs: ["a.java"], |
| 635 | libs: ["sdklib"], |
| 636 | sdk_version: "system_current", |
| 637 | } |
| 638 | |
| 639 | java_library { |
| 640 | name: "foo.test", |
| 641 | srcs: ["a.java"], |
| 642 | libs: ["sdklib"], |
| 643 | sdk_version: "test_current", |
| 644 | } |
| 645 | |
| 646 | java_sdk_library_import { |
| 647 | name: "sdklib", |
| 648 | public: { |
| 649 | jars: ["a.jar"], |
| 650 | }, |
| 651 | system: { |
| 652 | jars: ["b.jar"], |
| 653 | }, |
| 654 | test: { |
| 655 | jars: ["c.jar"], |
| 656 | stub_srcs: ["c.java"], |
| 657 | }, |
| 658 | } |
| 659 | `) |
| 660 | |
| 661 | for _, scope := range []string{"", ".system", ".test"} { |
| 662 | fooModule := result.ModuleForTests("foo"+scope, "android_common") |
| 663 | javac := fooModule.Rule("javac") |
| 664 | |
| 665 | sdklibStubsJar := result.ModuleForTests("sdklib.stubs"+scope, "android_common").Rule("combineJar").Output |
| 666 | android.AssertStringDoesContain(t, "foo classpath", javac.Args["classpath"], sdklibStubsJar.String()) |
| 667 | } |
| 668 | |
| 669 | CheckModuleDependencies(t, result.TestContext, "sdklib", "android_common", []string{ |
| 670 | `prebuilt_sdklib.stubs`, |
| 671 | `prebuilt_sdklib.stubs.source.test`, |
| 672 | `prebuilt_sdklib.stubs.system`, |
| 673 | `prebuilt_sdklib.stubs.test`, |
| 674 | }) |
| 675 | } |
| 676 | |
| 677 | func TestJavaSdkLibraryImport_WithSource(t *testing.T) { |
| 678 | result := android.GroupFixturePreparers( |
| 679 | prepareForJavaTest, |
| 680 | PrepareForTestWithJavaSdkLibraryFiles, |
| 681 | FixtureWithLastReleaseApis("sdklib"), |
| 682 | ).RunTestWithBp(t, ` |
| 683 | java_sdk_library { |
| 684 | name: "sdklib", |
| 685 | srcs: ["a.java"], |
| 686 | sdk_version: "none", |
| 687 | system_modules: "none", |
| 688 | public: { |
| 689 | enabled: true, |
| 690 | }, |
| 691 | } |
| 692 | |
| 693 | java_sdk_library_import { |
| 694 | name: "sdklib", |
| 695 | public: { |
| 696 | jars: ["a.jar"], |
| 697 | }, |
| 698 | } |
| 699 | `) |
| 700 | |
| 701 | CheckModuleDependencies(t, result.TestContext, "sdklib", "android_common", []string{ |
| 702 | `dex2oatd`, |
| 703 | `prebuilt_sdklib`, |
| 704 | `sdklib.impl`, |
| 705 | `sdklib.stubs`, |
| 706 | `sdklib.stubs.source`, |
| 707 | `sdklib.xml`, |
| 708 | }) |
| 709 | |
| 710 | CheckModuleDependencies(t, result.TestContext, "prebuilt_sdklib", "android_common", []string{ |
| 711 | `prebuilt_sdklib.stubs`, |
| 712 | `sdklib.impl`, |
| 713 | // This should be prebuilt_sdklib.stubs but is set to sdklib.stubs because the |
| 714 | // dependency is added after prebuilts may have been renamed and so has to use |
| 715 | // the renamed name. |
| 716 | `sdklib.xml`, |
| 717 | }) |
| 718 | } |
| 719 | |
| 720 | func TestJavaSdkLibraryImport_Preferred(t *testing.T) { |
| 721 | result := android.GroupFixturePreparers( |
| 722 | prepareForJavaTest, |
| 723 | PrepareForTestWithJavaSdkLibraryFiles, |
| 724 | FixtureWithLastReleaseApis("sdklib"), |
| 725 | ).RunTestWithBp(t, ` |
| 726 | java_sdk_library { |
| 727 | name: "sdklib", |
| 728 | srcs: ["a.java"], |
| 729 | sdk_version: "none", |
| 730 | system_modules: "none", |
| 731 | public: { |
| 732 | enabled: true, |
| 733 | }, |
| 734 | } |
| 735 | |
| 736 | java_sdk_library_import { |
| 737 | name: "sdklib", |
| 738 | prefer: true, |
| 739 | public: { |
| 740 | jars: ["a.jar"], |
| 741 | }, |
| 742 | } |
| 743 | `) |
| 744 | |
| 745 | CheckModuleDependencies(t, result.TestContext, "sdklib", "android_common", []string{ |
| 746 | `dex2oatd`, |
| 747 | `prebuilt_sdklib`, |
| 748 | `sdklib.impl`, |
| 749 | `sdklib.stubs`, |
| 750 | `sdklib.stubs.source`, |
| 751 | `sdklib.xml`, |
| 752 | }) |
| 753 | |
| 754 | CheckModuleDependencies(t, result.TestContext, "prebuilt_sdklib", "android_common", []string{ |
| 755 | `prebuilt_sdklib.stubs`, |
| 756 | `sdklib.impl`, |
| 757 | `sdklib.xml`, |
| 758 | }) |
| 759 | } |
| 760 | |
| 761 | func TestJavaSdkLibraryEnforce(t *testing.T) { |
| 762 | partitionToBpOption := func(partition string) string { |
| 763 | switch partition { |
| 764 | case "system": |
| 765 | return "" |
| 766 | case "vendor": |
| 767 | return "soc_specific: true," |
| 768 | case "product": |
| 769 | return "product_specific: true," |
| 770 | default: |
| 771 | panic("Invalid partition group name: " + partition) |
| 772 | } |
| 773 | } |
| 774 | |
| 775 | type testConfigInfo struct { |
| 776 | libraryType string |
| 777 | fromPartition string |
| 778 | toPartition string |
| 779 | enforceVendorInterface bool |
| 780 | enforceProductInterface bool |
| 781 | enforceJavaSdkLibraryCheck bool |
| 782 | allowList []string |
| 783 | } |
| 784 | |
| 785 | createPreparer := func(info testConfigInfo) android.FixturePreparer { |
| 786 | bpFileTemplate := ` |
| 787 | java_library { |
| 788 | name: "foo", |
| 789 | srcs: ["foo.java"], |
| 790 | libs: ["bar"], |
| 791 | sdk_version: "current", |
| 792 | %s |
| 793 | } |
| 794 | |
| 795 | %s { |
| 796 | name: "bar", |
| 797 | srcs: ["bar.java"], |
| 798 | sdk_version: "current", |
| 799 | %s |
| 800 | } |
| 801 | ` |
| 802 | |
| 803 | bpFile := fmt.Sprintf(bpFileTemplate, |
| 804 | partitionToBpOption(info.fromPartition), |
| 805 | info.libraryType, |
| 806 | partitionToBpOption(info.toPartition)) |
| 807 | |
| 808 | return android.GroupFixturePreparers( |
| 809 | PrepareForTestWithJavaSdkLibraryFiles, |
| 810 | FixtureWithLastReleaseApis("bar"), |
| 811 | android.FixtureWithRootAndroidBp(bpFile), |
| 812 | android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { |
| 813 | variables.EnforceProductPartitionInterface = proptools.BoolPtr(info.enforceProductInterface) |
| 814 | if info.enforceVendorInterface { |
| 815 | variables.DeviceVndkVersion = proptools.StringPtr("current") |
| 816 | } |
| 817 | variables.EnforceInterPartitionJavaSdkLibrary = proptools.BoolPtr(info.enforceJavaSdkLibraryCheck) |
| 818 | variables.InterPartitionJavaLibraryAllowList = info.allowList |
| 819 | }), |
| 820 | ) |
| 821 | } |
| 822 | |
| 823 | runTest := func(t *testing.T, info testConfigInfo, expectedErrorPattern string) { |
| 824 | t.Run(fmt.Sprintf("%v", info), func(t *testing.T) { |
| 825 | errorHandler := android.FixtureExpectsNoErrors |
| 826 | if expectedErrorPattern != "" { |
| 827 | errorHandler = android.FixtureExpectsAtLeastOneErrorMatchingPattern(expectedErrorPattern) |
| 828 | } |
| 829 | android.GroupFixturePreparers( |
| 830 | prepareForJavaTest, |
| 831 | createPreparer(info), |
| 832 | ). |
| 833 | ExtendWithErrorHandler(errorHandler). |
| 834 | RunTest(t) |
| 835 | }) |
| 836 | } |
| 837 | |
| 838 | errorMessage := "is not allowed across the partitions" |
| 839 | |
| 840 | runTest(t, testConfigInfo{ |
| 841 | libraryType: "java_library", |
| 842 | fromPartition: "product", |
| 843 | toPartition: "system", |
| 844 | enforceVendorInterface: true, |
| 845 | enforceProductInterface: true, |
| 846 | enforceJavaSdkLibraryCheck: false, |
| 847 | }, "") |
| 848 | |
| 849 | runTest(t, testConfigInfo{ |
| 850 | libraryType: "java_library", |
| 851 | fromPartition: "product", |
| 852 | toPartition: "system", |
| 853 | enforceVendorInterface: true, |
| 854 | enforceProductInterface: false, |
| 855 | enforceJavaSdkLibraryCheck: true, |
| 856 | }, "") |
| 857 | |
| 858 | runTest(t, testConfigInfo{ |
| 859 | libraryType: "java_library", |
| 860 | fromPartition: "product", |
| 861 | toPartition: "system", |
| 862 | enforceVendorInterface: true, |
| 863 | enforceProductInterface: true, |
| 864 | enforceJavaSdkLibraryCheck: true, |
| 865 | }, errorMessage) |
| 866 | |
| 867 | runTest(t, testConfigInfo{ |
| 868 | libraryType: "java_library", |
| 869 | fromPartition: "vendor", |
| 870 | toPartition: "system", |
| 871 | enforceVendorInterface: true, |
| 872 | enforceProductInterface: true, |
| 873 | enforceJavaSdkLibraryCheck: true, |
| 874 | }, errorMessage) |
| 875 | |
| 876 | runTest(t, testConfigInfo{ |
| 877 | libraryType: "java_library", |
| 878 | fromPartition: "vendor", |
| 879 | toPartition: "system", |
| 880 | enforceVendorInterface: true, |
| 881 | enforceProductInterface: true, |
| 882 | enforceJavaSdkLibraryCheck: true, |
| 883 | allowList: []string{"bar"}, |
| 884 | }, "") |
| 885 | |
| 886 | runTest(t, testConfigInfo{ |
| 887 | libraryType: "java_library", |
| 888 | fromPartition: "vendor", |
| 889 | toPartition: "product", |
| 890 | enforceVendorInterface: true, |
| 891 | enforceProductInterface: true, |
| 892 | enforceJavaSdkLibraryCheck: true, |
| 893 | }, errorMessage) |
| 894 | |
| 895 | runTest(t, testConfigInfo{ |
| 896 | libraryType: "java_sdk_library", |
| 897 | fromPartition: "product", |
| 898 | toPartition: "system", |
| 899 | enforceVendorInterface: true, |
| 900 | enforceProductInterface: true, |
| 901 | enforceJavaSdkLibraryCheck: true, |
| 902 | }, "") |
| 903 | |
| 904 | runTest(t, testConfigInfo{ |
| 905 | libraryType: "java_sdk_library", |
| 906 | fromPartition: "vendor", |
| 907 | toPartition: "system", |
| 908 | enforceVendorInterface: true, |
| 909 | enforceProductInterface: true, |
| 910 | enforceJavaSdkLibraryCheck: true, |
| 911 | }, "") |
| 912 | |
| 913 | runTest(t, testConfigInfo{ |
| 914 | libraryType: "java_sdk_library", |
| 915 | fromPartition: "vendor", |
| 916 | toPartition: "product", |
| 917 | enforceVendorInterface: true, |
| 918 | enforceProductInterface: true, |
| 919 | enforceJavaSdkLibraryCheck: true, |
| 920 | }, "") |
| 921 | } |
Colin Cross | 30c491b | 2021-06-01 13:39:09 -0700 | [diff] [blame] | 922 | |
| 923 | func TestJavaSdkLibraryDist(t *testing.T) { |
| 924 | result := android.GroupFixturePreparers( |
| 925 | PrepareForTestWithJavaBuildComponents, |
| 926 | PrepareForTestWithJavaDefaultModules, |
| 927 | PrepareForTestWithJavaSdkLibraryFiles, |
Colin Cross | 67c17ae | 2021-06-02 13:02:51 -0700 | [diff] [blame] | 928 | FixtureWithLastReleaseApis( |
| 929 | "sdklib_no_group", |
| 930 | "sdklib_group_foo", |
| 931 | "sdklib_owner_foo", |
| 932 | "foo"), |
Colin Cross | 30c491b | 2021-06-01 13:39:09 -0700 | [diff] [blame] | 933 | ).RunTestWithBp(t, ` |
| 934 | java_sdk_library { |
Colin Cross | 59b92bf | 2021-06-01 14:07:56 -0700 | [diff] [blame] | 935 | name: "sdklib_no_group", |
Colin Cross | 30c491b | 2021-06-01 13:39:09 -0700 | [diff] [blame] | 936 | srcs: ["foo.java"], |
| 937 | } |
| 938 | |
| 939 | java_sdk_library { |
Colin Cross | 986b69a | 2021-06-01 13:13:40 -0700 | [diff] [blame] | 940 | name: "sdklib_group_foo", |
Colin Cross | 986b69a | 2021-06-01 13:13:40 -0700 | [diff] [blame] | 941 | srcs: ["foo.java"], |
| 942 | dist_group: "foo", |
| 943 | } |
| 944 | |
| 945 | java_sdk_library { |
Colin Cross | 30c491b | 2021-06-01 13:39:09 -0700 | [diff] [blame] | 946 | name: "sdklib_owner_foo", |
Colin Cross | 30c491b | 2021-06-01 13:39:09 -0700 | [diff] [blame] | 947 | srcs: ["foo.java"], |
| 948 | owner: "foo", |
| 949 | } |
| 950 | |
| 951 | java_sdk_library { |
| 952 | name: "sdklib_stem_foo", |
Colin Cross | 30c491b | 2021-06-01 13:39:09 -0700 | [diff] [blame] | 953 | srcs: ["foo.java"], |
| 954 | dist_stem: "foo", |
| 955 | } |
Colin Cross | 30c491b | 2021-06-01 13:39:09 -0700 | [diff] [blame] | 956 | `) |
| 957 | |
| 958 | type testCase struct { |
| 959 | module string |
| 960 | distDir string |
| 961 | distStem string |
| 962 | } |
| 963 | testCases := []testCase{ |
| 964 | { |
Colin Cross | 59b92bf | 2021-06-01 14:07:56 -0700 | [diff] [blame] | 965 | module: "sdklib_no_group", |
Colin Cross | 3dd6625 | 2021-06-01 14:05:09 -0700 | [diff] [blame] | 966 | distDir: "apistubs/unknown/public", |
Colin Cross | 59b92bf | 2021-06-01 14:07:56 -0700 | [diff] [blame] | 967 | distStem: "sdklib_no_group.jar", |
Colin Cross | 30c491b | 2021-06-01 13:39:09 -0700 | [diff] [blame] | 968 | }, |
| 969 | { |
Colin Cross | 986b69a | 2021-06-01 13:13:40 -0700 | [diff] [blame] | 970 | module: "sdklib_group_foo", |
| 971 | distDir: "apistubs/foo/public", |
| 972 | distStem: "sdklib_group_foo.jar", |
| 973 | }, |
| 974 | { |
Colin Cross | 59b92bf | 2021-06-01 14:07:56 -0700 | [diff] [blame] | 975 | // Owner doesn't affect distDir after b/186723288. |
Colin Cross | 30c491b | 2021-06-01 13:39:09 -0700 | [diff] [blame] | 976 | module: "sdklib_owner_foo", |
Colin Cross | 59b92bf | 2021-06-01 14:07:56 -0700 | [diff] [blame] | 977 | distDir: "apistubs/unknown/public", |
Colin Cross | 30c491b | 2021-06-01 13:39:09 -0700 | [diff] [blame] | 978 | distStem: "sdklib_owner_foo.jar", |
| 979 | }, |
| 980 | { |
| 981 | module: "sdklib_stem_foo", |
Colin Cross | 3dd6625 | 2021-06-01 14:05:09 -0700 | [diff] [blame] | 982 | distDir: "apistubs/unknown/public", |
Colin Cross | 30c491b | 2021-06-01 13:39:09 -0700 | [diff] [blame] | 983 | distStem: "foo.jar", |
| 984 | }, |
Colin Cross | 30c491b | 2021-06-01 13:39:09 -0700 | [diff] [blame] | 985 | } |
| 986 | |
| 987 | for _, tt := range testCases { |
| 988 | t.Run(tt.module, func(t *testing.T) { |
| 989 | m := result.ModuleForTests(tt.module+".stubs", "android_common").Module().(*Library) |
| 990 | dists := m.Dists() |
| 991 | if len(dists) != 1 { |
| 992 | t.Fatalf("expected exactly 1 dist entry, got %d", len(dists)) |
| 993 | } |
| 994 | if g, w := String(dists[0].Dir), tt.distDir; g != w { |
| 995 | t.Errorf("expected dist dir %q, got %q", w, g) |
| 996 | } |
| 997 | if g, w := String(dists[0].Dest), tt.distStem; g != w { |
| 998 | t.Errorf("expected dist stem %q, got %q", w, g) |
| 999 | } |
| 1000 | }) |
| 1001 | } |
| 1002 | } |