Commit graph

339 commits

Author SHA1 Message Date
Paul Duffin
4aa7faf487 Merge "Remove unused java testing methods" 2021-03-31 21:41:42 +00:00
Paul Duffin
535e0a105e Remove unused java testing methods
Also, stops exporting methods that are no longer used outside the java
package.

Bug: 181070625
Test: m nothing
Change-Id: I23d35bbc21f82f2dae802aa53badda4c58b41024
2021-03-31 16:20:12 +01:00
Paul Duffin
55e740e9a6 Remove varargs from RunTest(t *testing.T)
Use GroupFixturePreparers instead.

Bug: 182885307
Test: m nothing
Change-Id: Iaedb0ddc9d6a704f4d41363e705f3025a1291dc8
2021-03-31 16:03:59 +01:00
Paul Duffin
a71a67a4f5 Remove extraneous calls to TestingBuildParams.RelativeToTop()
Deprecated the method to try and prevent any other uses being added.

Bug: 183650682
Test: m nothing
Change-Id: Ia6f43851e5a00c9d96af780e3bd21e03175e1a2f
2021-03-30 20:03:22 +01:00
Paul Duffin
e8366da1f6 Automatically call TestingBuildParams.RelativeToTop()
Fixes the few tests that break due to this and which cannot easily be
separated into their own changes.

Bug: 183650682
Test: m nothing
Change-Id: Ia2f31213a1f114a78e66a81d89279ecde9f4c465
2021-03-30 19:35:35 +01:00
Colin Cross
2207f87756 Split droidstubs out of droiddoc.go
Split part of droiddoc.go into droidstubs.go.  Also split droiddoc_test.go
and droidstubs_test.go out of java_test.go.

Test: go test ./java
Change-Id: Iea742e75b6925b135016f7bbf3a168c696a6c433
2021-03-25 11:11:34 -07:00
Colin Cross
ce3a51dc96 Support multiple rsp files in RuleBuilder
The lint rule is manually creating a second rsp file because Ninja
only supports on per rule.  Move the support into RuleBuilder so
that it can apply the same rewrites that it does to the primary
one.

Test: TestRuleBuilder_Build
Change-Id: Iec250a2d60e74ccf1b4ad085a960fec6867ea559
2021-03-25 11:06:45 -07:00
Paul Duffin
4dd6cdb3bc Fix TestDroiddoc's reliance on absolute paths
TestDroiddoc compares the value returned by OutputFiles(""), which will
usually be absolute paths including the temporary buildDir, against
paths returned from TestingBuildParam.RelativeToTop(), which does not
currently change the Path contents and so will include absolute
temporary paths. However, a follow up change to this will make the
TestingBuildParam.RelativeToTop() also change the Path contents at
which point this test would be comparing relative to absolute paths.

So, this change makes sure that they are all converted to relative to
top paths before comparison.

Bug: 183650682
Test: m droid
Change-Id: Ia4478f527af27a920945f5849525e5031cc5b8b6
2021-03-25 13:14:37 +00:00
Paul Duffin
76e5c8a37f Convert test that disallows non existent paths to use fixtures
This change needed to add some additional files to the registered
files for PrepareForTestWithJavaDefaultModules because otherwise they
would fail when "TestAllowNonExistentPaths = false". Those files were
being added by the TestJavaLintRequiresCustomLintFileToExist (albeit in
some cases in different locations to that required by the default
modules but as the files are needed by the modules defined in
PrepareForTestWithJavaDefaultModules they should be defined in it.

A couple of other places also provided some files so moving them into
PrepareForTestWithJavaDefaultModules caused some conflicts which needed
to be resolved.

Bug: 183184375
Test: m nothing
Change-Id: I76ce9f1673c1c1c4000635b76b8377d582224bf1
2021-03-24 22:08:05 +00:00
Paul Duffin
a35178b105 Fix "filename too long" issue on Luci caused by test name
Stop including fields in the test name for TestJavaSdkLibraryEnforce to
reduce its length to avoid the filename too long limit.

Test: m nothing
      Check the lengths before (~240) and after (~74) to make sure
      there was a sizeable reduction.
Change-Id: I275a1110e5102b8ea8376759f28c7c6333a5efee
2021-03-24 15:09:37 +00:00
Paul Duffin
9fc9f53423 Group all the preparations needed for testing dexpreopt
Make it easier to test dexpreopt functionality by grouping all the
fixture preparations together.

Bug: 177892522
Test: m nothing
Change-Id: I94f66e3ec82efc4fd791f4fdab678d298565e452
2021-03-24 08:30:27 +00:00
Paul Duffin
71ae59412b Remove javaFixtureFactory
Replaces uses of javaFixtureFactory with prepareForJavaTest and removes
the unused javaFixtureFactory.

Bug: 182885307
Test: m nothing
Change-Id: I809772d14af2af211b9e15ad676fbdc06b07cd46
2021-03-24 01:07:12 +00:00
Paul Duffin
d6339af0b6 Remove unused test methods and buildDir
Bug: 182885307
Test: m nothing
Change-Id: I251145a82479428a82f19cbde6b415d149acd619
2021-03-24 01:07:12 +00:00
Paul Duffin
414ea5eb73 Remove uses of buildDir from java/java_test.go and java/sdk_test.go
Remove any uses, either direct (or indirect via testJavaConfig or
similar methods), of the package level buildDir variable from this
file.

Bug: 182885307
Test: m nothing
Change-Id: I4d9dc39d3b1e5c37ba1f9e72da94048949c0fd17
2021-03-24 01:07:12 +00:00
Paul Duffin
c029c43c99 Register java_plugin in PrepareForTestWithJavaBuildComponents
Bug: 182885307
Test: m nothing
Change-Id: I550d39ba46c548b6b099d8dc6a9c458ca931b2fa
2021-03-24 00:01:15 +00:00
Paul Duffin
04ba70d665 Register the propagateRROEnforcementMutator
This adds the registration of the mutator to the existing register...
method which will include it in PrepareForTestWithJavaBuildComponents.

Bug: 182885307
Test: m nothing
Change-Id: I6cea716a3ff4d8abdb80543b7e0ddf22246ffa30
2021-03-22 22:09:53 +00:00
Paul Duffin
42da69d784 Add preparer for overlay pre-singleton registration
It appears as though this is the first pre-singleton type to actually
be registered with the InitRegistrationContext as it failed due to an
uninitialized map, so this change also fixes that.

Bug: 182885307
Test: m nothing
Change-Id: Ibbf6d0db5f3c2fcc89291a16aa5f16b8b5009bd3
2021-03-22 22:09:53 +00:00
Paul Duffin
70d3bee3e0 Remove emptyFixtureFactory from apex and java
Bug: 183235980
Test: m nothing
Change-Id: I350b45e2f57430fb158f4141a566e75de17208cd
2021-03-22 18:31:53 +00:00
Colin Cross
d2db7953a0 Merge changes Iab4e09d9,Icf2f24dd,I15be5ef1,Ic0db9619
* changes:
  Run lint actions in sbox
  Support sbox-in-RBE
  Move android package on top of remotexec
  Support sandboxing inputs in RuleBuilder
2021-03-19 17:25:14 +00:00
Paul Duffin
54a5e9a467 Merge "Remove javaMockFS()" 2021-03-19 14:18:46 +00:00
Paul Duffin
89fbdb2387 Merge "Fix TestTurbine to work without javaMockFS()" 2021-03-19 11:11:42 +00:00
Paul Duffin
903a8a08ab Merge "Convert TestClasspath to test fixtures" 2021-03-19 11:08:17 +00:00
Colin Cross
1661aff8be Run lint actions in sbox
Run lint actions in sbox with RuleBuilder.SandboxInputs.  This
copies all input files into the sandbox, which prevents the lint
tool from finding nearby source files that were not presented to it.

Using SandboxInputs requires use of PathForInput or PathForOutput
anywhere a path is used outside of the RuleBuilderCommand methods
that take paths so that they can be translated to the paths that
will be used in the sandbox.

Bug: 181681346
Test: lint_test.go
Test: m lint-check dist
Test: m USE_RBE=true RBE_LINT=true lint-check dist
Test: m USE_RBE=true RBE_LINT=true RBE_LINT_EXEC_STRATEGY=remote lint-check dist
Change-Id: Iab4e09d961891ef182643583d4d456e413bc5e39
2021-03-18 16:17:34 -07:00
Paul Duffin
c3f89bece1 Merge "Clean up java package use of python build components" 2021-03-18 17:02:44 +00:00
Paul Duffin
1efdb30182 Remove javaMockFS()
Also, removes the workaround that allowed preparers to override files
added in javaMockFS().

The performance of the java tests was determined by running:
  m nothing
  rm -fr out/soong/.bootstrap/soong-java/test/
  time m nothing

Prior to starting this work that returned:
  real  1m30.060s
  user  33m3.028s
  sys   13m25.413s

Immediately prior to this change that returned:
  real  1m2.777s
  user  14m14.352s
  sys   9m40.745s

After applying this change that returned:
  real  0m20.282s
  user  3m7.429s
  sys   0m43.601s

So, this reduced the real time cost of running the java tests from 90
seconds to 20 seconds.

Bug: 182638834
Test: m nothing
Change-Id: I30490fd40ddb0684a5a4975ce1811bab5dc79e4e
2021-03-18 08:02:38 +00:00
Paul Duffin
3d9f268437 Fix TestTurbine to work without javaMockFS()
Bug: 182638834
Test: m nothing
Change-Id: Idf400b5f0d171a504acf006425cbfc514b391e74
2021-03-18 08:02:38 +00:00
Paul Duffin
76101fa5ec Convert TestClasspath to test fixtures
The main complication with this change was that many of the tests check
paths that are provided by the default java modules. The location of
them is different in the test fixtures that it is when using
testConfig() and so the test needed to be changed.

Bug: 182638834
Test: m nothing
Change-Id: I6d325dbd3ba39e5de7e53c576d7cfe07bd95a965
2021-03-18 08:02:38 +00:00
Paul Duffin
220ddd7a6b Clean up java package use of python build components
Bug: 182885307
Test: m nothing
Change-Id: I206ebc075c568a09008ec8b63122922dd87ba318
2021-03-17 23:56:58 +00:00
Paul Duffin
afeee22c17 Add emptyFixtureFactory in java package
Bug: 182402754
Test: m nothing
Change-Id: I6a01b846a8aee5a0ace9e6ac056ee439bf6f12f7
2021-03-17 17:50:22 +00:00
Yuexi Ma
b96a04ba49 Merge "Export a few utility methods" 2021-03-17 01:40:51 +00:00
Yuexi Ma
627263fece Export a few utility methods
Add a few utility methods to support generating TradeFed test plan in C-Suite

Test: go test .
Change-Id: I86a505068b5d5aa0f5a37b3e3a2465839a7480ef
2021-03-16 15:57:59 -07:00
Paul Duffin
163043d615 Fix TestJavaSdkLibrary... tests to work without javaMockFS()
Bug: 182638834
Test: m nothing
Change-Id: I140b88b3fdf2c532d266a196fee84675c518d859
2021-03-16 14:25:21 +00:00
Paul Duffin
22b77cd538 Convert JavaSdkLibrary... tests in java package to test fixtures
These tests rely on files provided by javaMockFS() so need to are being
converted to test fixtures to allow them to remove that dependency
which will allow javaMockFS() to be removed.

Bug: 182638834
Test: m nothing
Change-Id: If736b95d134fe73c0a0ccd438ec31e93568fb929
2021-03-16 14:25:21 +00:00
Paul Duffin
05f72de083 Convert TestJavaSdkLibraryEnforce to test fixtures
Bug: 182638834
Test: m nothing
Change-Id: I99efe76008f9ca0996177f47923274ca594a6858
2021-03-15 17:17:43 +00:00
Paul Duffin
aa6caa7fa8 Create sub tests for each test in TestJavaSdkLibraryEnforce
Bug: 182638834
Test: m nothing
Change-Id: I509b071ee4e470da45159b2174aae7acf1b0eb1a
2021-03-15 17:17:43 +00:00
Paul Duffin
bf028b533d Extract PrepareForTestWithJavaSdkLibraryFiles from javaMockFS()
Needed for tests in both java and sdk packages.

Bug: 182638834
Test: m nothing
Change-Id: Ia8c5e7db47d8b63bf8dcf2965b3af60a4d35a9e5
2021-03-14 01:08:26 +00:00
Paul Duffin
6bac49c560 Convert testJavaError to test fixtures
Bug: 182638834
Test: m nothing
Change-Id: If6de91cd60fea36c945f2b0d51a04e26c838e4af
2021-03-14 01:08:26 +00:00
Paul Duffin
db284be913 Separate system modules tests into their own file
java_test.go is getting too big.

Bug: 182402568
Test: m nothing
Change-Id: I9c3818f1d747a230fcb66687319a3a14d557a57c
2021-03-11 08:21:49 +00:00
Paul Duffin
95bdab4000 Support test fixtures in java package
Restructures the java package test setup code to create FixturePreparer
instances for setting up a test fixture and converts some tests to
use it.

The goal with this change is not to switch all the java tests over to
directly using the new model but instead to ensure that the majority of
the java tests run with the new model, to allow existing tests to
easily switch to the new model when needed and to allow dependent
packages to be switched to the new model.

Bug: 181070625
Test: m nothing
Change-Id: I1c9d96ddbc973aaf9733dcd7fa0479f79b0f471f
2021-03-10 10:13:09 +00:00
Paul Duffin
d6ceb8600c Clean up cc.RegisterRequiredBuildComponentsForTest()
Changes this function so it only registers components from the cc
package by pushing the call to genrule.RegisterGenruleBuildComponents()
down into those packages whose tests need it.

This will make it easier to migrate cc package tests to test fixtures
as the RegisterRequiredBuildComponentsForTest() no longer overlaps with
preparers from the genrule packages.

Bug: 181070625
Test: m nothing
Change-Id: Ic00c7e480dc738d7a88d038aca6ab95a1502a24a
2021-03-05 18:20:33 +00:00
Paul Duffin
ec0fe1775b Avoid hiddenapi ignoring prebuilt with missing dex implementation jar
Previously, when a prebuilt was preferred but did not provide a
suitable boot dex jar both the source and the prebuilt were silently
ignored which meant that the "hiddenapi list" command was not given a
complete set of boot dex jars. That could either lead to incorrect
hiddenapi flags being set or the "hiddenapi list" command failing if it
could not find a class. Debugging the cause of either of those cases
can be very time consuming so this change fails early and makes the
cause very explicit.

Bug: 181267622
Test: m nothing
Change-Id: I6763ddb9ba90ed2e501d0cf7984f6655237e905d
2021-03-01 12:58:28 +00:00
Paul Duffin
eafc16bf14 Allow pre-singleton types to be registered in RegistrationContext
Bug: 181070625
Test: m droid
Change-Id: I708b78ed0b42ec55b0442307f40531cfe1233c2b
2021-02-24 10:17:19 +00:00
Treehugger Robot
277303f042 Merge "Add ctx to AndroidMkExtraEntriesFunc" 2021-02-22 22:40:31 +00:00
Colin Cross
aa2555387d Add ctx to AndroidMkExtraEntriesFunc
Add a ctx parameter to AndroidMkExtraEntriesFunc to allow them to
access providers.

Test: m checkbuild
Change-Id: Id6becc1e425c3c3d8519248f8c0ce80777fac7cc
Merged-In: Id6becc1e425c3c3d8519248f8c0ce80777fac7cc
2021-02-19 23:05:40 +00:00
Pedro Loureiro
5d190cc24e Add support for lint baseline files
Test: m droid
Test: go test ^TestJavaLint # (from soong/build/java)

Change-Id: I249a0a0597b0bf8495460ed283b476ad2eb36edc
2021-02-18 11:15:30 +00:00
Paul Duffin
635aa0834f Make dexpreopt tools available for all java tests
Bug: 177892522
Test: m nothing
Change-Id: I594bddae692ef76dc8c3da504934d0151b13d4c9
2021-01-25 19:15:19 +00:00
Paul Duffin
9f04524673 Allow createGlobalSoongConfig() to be used from tests
Previously, the createGlobalSoongConfig() function was explicitly
prevented from being used in tests because it would fail. However, it
turns out that is no longer the case and it does now work.

That allows the following changes to be made:
* Tests no longer need to use GlobalSoongConfigForTests() to
  prepopulate the cache.
* GlobalSoongConfigForTests() is only needed in the dexpreopt
  package.

Bug: 177892522
Test: m nothing
Change-Id: Ifcbb1a44254c5d2d10c1d02ab23227488d1d1ed1
2021-01-21 15:44:30 +00:00
Paul Duffin
c059c8c9a0 Add java.RegisterRequiredBuildComponentsForTest function
Insulate tests that exercise code in the java package from having to
register the build components provided by the java package by providing
a single function that registers them all. This follows the pattern
currently used in the cc and rust packages.

This change is in preparation for switching the dex_bootjars singleton
from a singleton, which does not require a module definition in order
to be instantiated, to a singleton module which does. That will require
adding a module definition into java.GatherRequiredDepsForTest() and
this change ensures that the required components will have been
registered in every test.

Bug: 177892522
Test: m nothing
Change-Id: I6475db8240894947dd07c89a940a3e4f201aa598
2021-01-21 11:47:32 +00:00
JaeMan Park
90e75350d7 Make TestJavaSdkLibraryEnforce faster
TestJavaSdkLibraryEnforce is too slow because it tests all
combinations of options. Change TestJavaSdkLibraryEnforce to
run test on specific test cases, not all combinations.

Bug: 177323052
Test: go test -timeout 10s -run ^TestJavaSdkLibraryEnforce$ android/soong/java
Change-Id: Ie7fe4e22b570a3e25259a6ad4bd37936805c6604
2021-01-15 13:24:09 +09:00
Jooyung Han
e197d8b174 Add "aidl.flags:" property for cc_/java_ modules
The property can be used to pass additional flags to the AIDL compiler.
For example,

  cc_library {
    ..
    srcs: ["Foo.aidl"],
    aidl: {
      flags: [
        "-Werror",      // warnings as error
        "-Weverything", // turn on all warnings
      ],
    },
  }

Bug: 168028537
Test: soong test
Change-Id: I8120eeae7cd7b1acdd34c554af996a29e760a368
2021-01-05 10:40:22 +09:00