This involves some minor changes to testing infrastructure.
This is a rollforward of aosp/2628496 with a couple of minor changes:
- In ParseBuildFiles, filter out all build files that are kept due
to ShouldKeepExistingBuildFileForDir
- Add some minor test infrastructure for StubbedBuildDefinitions, with a
couple of proof of concept tests used to demonstrate its usage. This
pattern will become immensely more common as we implement allowlist v2
(as we will need to update all tests which today simulate build
definitions that have missing deps)
Bug: 285631638
Fixes: 286545783
Test: bp2build.sh
Test: m nothing
Change-Id: I7c3a03b02098e39dd8e51d327482b440f294478f
This allows us to set product variables as build settings instead
of loading them from a target's provider, which further allows us
to read product config variables in transitions.
Bug: 287539062
Bug: 269577299
Test: Presubmits
Change-Id: I8497703f706162572ceb3486240e1eb02a37f5f6
This involves some minor changes to testing infrastructure.
Bug: 285631638
Fixes: 286545783
Test: unit test
Change-Id: If64ba29308d99e63a1cc5526feaf077f2cb14478
Previously, the fixture test infrastructure was hard coded to
initialize itself in preparation for invoking the PrepareBuildActions()
method. That meant it could not be used for testing the bp2build and
apiBp2build modes which required different initialization and called a
different method.
This change extracts that behavior into a FixtureTestRunner and adds an
implementation that allows it to test the above two modes. It then uses
that to implement the runBp2BuildTestCaseWithSetup method.
The TestPrebuiltLibraryAdditionalAttrs was the only test which broke as
it supplied an invalid path to the MockFS (it does not support using a
trailing / to represent an empty build directory). So, it was modified
to add a couple of files inside those directories instead.
Test: m nothing
Change-Id: I6798a4f761160af8d1bfed81d46de9628bda3eb9
Previously, the NewTextContext created a context that always called
NewNameResolver with a export filter that always returned true.
This change fixes that by:
1. Changing NewNameResolver to take a Config parameter instead of a
filter parameter and pushing the code to create the filter from the
Config from newNameResolver() in cmd/soong_build/main.go into the
NewNameResolver function.
2. Extracting a newTestContextForFixture that does not create a
NameResolver or set it on the context. That avoids creating a
NameResolver before the test has prepared the config.
3. Modify the fixture to create and set the NameResolver in the Context
after the config has been prepared by the test.
4. Added test to verify that it all works.
Bug: 234825639
Test: m nothing
Change-Id: Ie4b13f18093dc01a0ab65a9ecfd143585d843b55
The AIDL source generation rule sets include flags based on the relative
path of .aidl sources. For .aidl sources provided by Bazel targets, e.g.
in a filegroup, the same directory could be added to the include path
twice. Instead we need to ensure that if a Bazel source provides the
include path, that we don't add it again from a Soong source.
Bug: 229251008
Test: USE_BAZEL_ANALYSIS=1 m api-stubs-docs-non-updatable
Change-Id: I4997039003242b43e0e52ccf41729acb4ad11324
Indented the bp contents to make it easier to differentiate between
them and the directory in which they belong.
Bug: 181070625
Test: m nothing
Change-Id: Iae7495fb7c88769dc688006a41f4d21f57cf03b8
These are just out/ and out/soong/ and the old names were quite
confusing.
Test: Presubmits.
Merged-In: I999ca62162062f27e449f83ffb00fa580d4065b8
Merged-In: I2fcd80a9e376a6842a06aa104a9f6f5c5e16f8c7
Change-Id: Ib481d2aac40df8da1b74174dc8ec576c1cb48be0
Simplifies the process of debugging failing tests by making it easy for
the test fixture to produce debug output on a case by case basis.
Bug: 181070625
Test: m nothing
Change-Id: I22620a1bfb1737cffd017bdf7bbbfb609b60468c
Prior to this FixtureFactory was basically a FixturePreparer with the
additional support for buildDirSupplier. This makes that a reality by
moving the functionality of FixtureFactory into FixturePreparer and
making FixtureFactory extend that with buildDirSupplier.
This also deprecates the Extend() method in favour of simply using the
GroupFixturePreparers() method.
Once all usages of buildDir have been removed so the buildDirSupplier
is no longer required then FixtureFactory will be removed altogether.
In the meantime follow up changes will migrate those tests that do not
require a buildDirSupplier to just use FixturePreparers in preparation
for the eventual removal of FixtureFactory.
Bug: 183235980
Test: m nothing
Change-Id: Ibb4e5bfec2f76ee34dd7de6aed6bbbfe27d337b8
The visit() method was dropped in favor of a list() method as the
latter makes it easier to treat fixtureFactory, simpleFixturePreparer
and compositeFixturePreparer as simple collections of already flattened
and deduped *simpleFixturePreparers. That will be used in a follow up
change.
Bug: 183235980
Test: m nothing
Change-Id: Ia41ae9bd4f9c39c85865ba698e0da6be00519caf
The ExtendWithErrorHandler method simply wraps the FixtureErrorHandler
in a FixturePreparer that will set the error handler in the fixture.
Bug: 183235980
Test: m nothing
Change-Id: Icf9a5f62cb532efc120300c2f906cd3397aa6763
The Preparer() method allows for another test to be run using the same
preparers as were used to create the TestResult. That is useful when
testing functionality like the sdk snapshot mechanism that generates an
Android.bp and a set of files that are intended to be reconsumed by
Soong. This method allows the test to process that output to ensure
that it is valid. A follow up change will migrate the CheckSnapshot()
method to use this as part of the migration of the sdk package to the
test fixture model.
Previously, the dedupAndFlattenPreparers() would not construct a list
containing all the preparers passed to it as it was trying to avoid
constructing such a list unless necessary. However, as every usage of
this method now needs to construct such a list that functionality has
been added to it.
Bug: 181070625
Test: m nothing
Change-Id: Iab34e2c861bdfd05c44e982224f70c5abc19e468
Sometimes it is necessary to optionally add a preparer. e.g. There are
many parameterized tests where one of the parameters is some additional
test setup but not every test provides it so it will default to the
"zero" value of whatever type is used for the test setup parameter
Migrating those tests to use test fixtures will typically require that
the test setup parameter be changed to a FixturePreparer, which by
default will be nil.
Attempting to use a nil FixturePreparer in the test fixtures will fail
so the OptionalFixturePreparer was added to wrap a possibly nil
FixturePreparer and thereby avoiding complicating each test with
similar logic.
Bug: 182885307
Test: m nothing
Change-Id: Ia12b2af2105fdc69af4e0b909a37a7b86f1af299
If a FixtureFactory was created with a nil buildDirSupplier then this
change will cause it to create a test specific directory instead. This
will allow packages whose tests have been fully converted to the test
fixture model to remove the need for the package level buildDir
variable.
Bug: 182885307
Test: m nothing
Change-Id: Ifa70acadbd90356fadbe39675bac3214d925aa2f
This change is in preparation for removing testing.T from TestResult.
Bug: 181070625
Test: m nothing
Change-Id: Iac627cc3c9f922ec4a41ce657442e4139fe7defb
Although they are intended to be used together they are separate pieces
of functionality so should be separate.
Bug: 181070625
Test: m nothing
Change-Id: I3b2ccf66748a3c53b63c112256a8eb20e0448179
* changes:
Support test fixtures in sh package
Support test fixtures in bpf package
Support test fixtures in cc package
Add temporary RunTestWithConfig method to simplify migration
Support test fixtures in etc package
Convert license tests to use test fixtures
As part of the work on the new fixture mechanism some of the TestHelper
functionality was moved into the android/fixture.go package. This moves
the rest and removes the now duplicated TestHelper from the sdk
package.
Also removed some unnecessary & operators.
Bug: 181070625
Test: m nothing
Change-Id: Ia09a5d05e4fab3a4e28cf44b2d947a33541e3925
Previously, there was a bug that caused tests which ran successfully on
their own to fail when run together in parallel. They each extended the
same factory and ended up sharing the preparers slice which meant that
they overwrote each other's preparers causing the tests to fail.
This change fixes that by creating a new slice for each factory.
Bug: 181070625
Test: m nothing
Change-Id: If340c125c5b03a9d5c36a59ff4da4ec189808f9b
A lot of existing tests that expect errors to be reported do not check
the returned result. This change treats failures of the error handler
in that situation as fatal.
The default error handler already behaved that way. The others did not.
FixtureExpectsAllErrorsToMatchAPattern uses
CheckErrorsAgainstExpectations and it was safe to just make that func
treat any unmatching errors as fatal as all the existing usages are at
the end of test functions.
FixtureExpectsAtLeastOneErrorMatchingPattern uses the
FailIfNoMatchingErrors function which is used in a number of places
(including CheckErrorsAgainstExpectations) that do not want to treat
a test failure as fatal. So, that was modified to return false if no
matching error was found and the error handler treated that as fatal.
Bug: 181070625
Test: m nothing
Change-Id: I6e4df53f93250348bc050d4ff098134e6314ae30
A FixtureFactory is supposed to be immutable to allow them to be safely
shared but unfortunately the implementation of SetErrorHandler broke
that constraint. That made it very easy to mistakenly add an error
handler specific to a test to a shared factory breaking other tests
that use that factory.
This change causes SetErrorHandler to create a new instance of the
factory to avoid that.
Bug: 181070625
Test: m nothing
Change-Id: Ia5356a04189099c88880a2a521af29ab72560f30
FixturePreparers is a bad name for a method that creates a collection
of FixturePreparers for a couple of reasons:
* Conventionally it would be used as the name for []FixturePreparer if
it is necessary to add behavior to that.
* There are many different types of collection, particularly when order
matters.
Bug: 181070625
Test: m nothing
Change-Id: I55394ff369375dcac2d7b72e4d803a4818762d36
Adds support for customizing the error handling behavior of test
fixtures and converts a test to use it.
Bug: 181070625
Test: m nothing
Change-Id: I736c41311819d57d8688fc3b0e021dbb50c491c1
Adds the test fixture support and converts a few tests to exercise the
code and show how it works.
Bug: 181070625
Test: m nothing
Change-Id: I0a2b40fff93b6041f9aa8c4ef0aba91da1bc8bf3